Skip to content

Commit

Permalink
chore: etcd powered by rsm (#5272)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8f6e37f)
  • Loading branch information
free6om committed Oct 31, 2023
1 parent 41555c1 commit bd86e26
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 112 deletions.
22 changes: 1 addition & 21 deletions deploy/etcd-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,2 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "etcd-cluster.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "etcd-cluster.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "etcd-cluster.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "etcd-cluster.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
kubectl get svc --namespace {{ .Release.Namespace }}
61 changes: 0 additions & 61 deletions deploy/etcd-cluster/templates/ingress.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions deploy/etcd-cluster/templates/tests/test-connection.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions deploy/etcd-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ resources: { }
persistence:
## @param shard[*].persistence.enabled Enable persistence using Persistent Volume Claims
##
enabled: false
enabled: true
## `data` volume settings
##
data:
Expand All @@ -71,7 +71,7 @@ persistence:
storageClassName:
## @param shard[*].persistence.size Size of data volume
##
size: 10Gi
size: 1Gi

ingress:
## @param ingress.enabled Enable ingress record generation for etcd
Expand Down
32 changes: 20 additions & 12 deletions deploy/etcd/templates/clusterdefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@ spec:
- name: etcd
characterType: etcd
workloadType: Consensus
consensusSpec:
leader:
name: "leader"
accessMode: ReadWrite
followers:
- name: "follower"
rsmSpec:
roles:
- name: leader
accessMode: ReadWrite
updateStrategy: BestEffortParallel
probes:
isLeader: true
canVote: true
- name: follower
accessMode: ReadWrite
isLeader: false
canVote: true
roleProbe:
periodSeconds: 1
failureThreshold: 3
customHandler:
- image: quay.io/coreos/etcd:v3.5.6
command:
- |
Status=$(etcdctl --endpoints=127.0.0.1:2379 endpoint status -w simple --command-timeout=300ms --dial-timeout=100m) &&
IsLeader=$(echo $Status | awk -F ', ' '{print $5}') &&
IsLearner=$(echo $Status | awk -F ', ' '{print $6}') &&
if [ "true" = "$IsLeader" ]; then echo -n "leader"; elif [ "true" = "$IsLearner" ]; then echo -n "learner"; else echo -n "follower"; fi
roleUpdateMechanism: DirectAPIServerEventUpdate
memberUpdateStrategy: BestEffortParallel
service:
ports:
- name: client
Expand Down Expand Up @@ -61,13 +70,12 @@ spec:
# TODO: clusterDomain 'cluster.local' requires configurable
MY_PEER=$KB_POD_FQDN{{ .Values.clusterDomain }}
exec etcd --name ${HOSTNAME} \
--experimental-initial-corrupt-check=true \
--listen-peer-urls http://0.0.0.0:2380 \
--listen-client-urls http://0.0.0.0:2379 \
--advertise-client-urls http://${MY_PEER}:2379 \
--initial-advertise-peer-urls http://${MY_PEER}:2380 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster ${PEERS} \
--initial-cluster-state new \
--data-dir /var/run/etcd/default.etcd
connectionCredential:
username: root
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/testdata/smoketest/etcd/00_etcdcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ spec:
monitor: false
replicas: 3
serviceAccountName: kb-etcd-cluster
volumeClaimTemplates:
- name: data # ref clusterdefinition components.containers.volumeMounts.name
spec:
storageClassName:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
2 changes: 1 addition & 1 deletion test/e2e/testdata/smoketest/etcd/03_vscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ spec:
- componentName: etcd
requests:
cpu: "500m"
memory: 500Mi
memory: 500Mi

0 comments on commit bd86e26

Please sign in to comment.