Skip to content

Commit

Permalink
Bug fixes and value defaulting
Browse files Browse the repository at this point in the history
  • Loading branch information
I308301 committed Mar 5, 2020
1 parent fbacbe2 commit 37c64d7
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 15 deletions.
21 changes: 16 additions & 5 deletions charts/etcd/templates/etcd-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,23 @@ spec:
command:
- etcdbrctl
- server
{{- if .Values.etcd.defragmentationSchedule }}
- --defragmentation-schedule={{ .Values.etcd.defragmentationSchedule }}
{{- end }}
{{- if .Values.backup.fullSnapshotSchedule }}
- --schedule={{ .Values.backup.fullSnapshotSchedule }}
{{- end }}
- --garbage-collection-policy={{ .Values.backup.garbageCollectionPolicy }}
{{- if eq .Values.backup.garbageCollectionPolicy "LimitBased" }}
- --max-backups={{ .Values.backup.maxBackups }}
{{- end }}
- --data-dir=/var/etcd/data/new.etcd
{{- if .Values.store.storageProvider }}
- --storage-provider={{ .Values.store.storageProvider }}
{{- end }}
{{- if .Values.store.storePrefix }}
- --store-prefix={{ .Values.store.storePrefix }}
{{- end }}
{{- if .Values.backup.etcdQuotaBytes }}
- --embedded-etcd-quota-bytes={{ int $.Values.backup.etcdQuotaBytes }}
{{- end }}
Expand All @@ -132,22 +140,25 @@ spec:
- --insecure-transport=false
- --insecure-skip-tls-verify=false
- --endpoints=https://{{ .Values.name }}-local:{{ .Values.etcd.clientPort }}
# enable TLS on backup-restore server reusing etcd cert bundle
- --server-cert=/var/etcd/ssl/server/tls.crt
- --server-key=/var/etcd/ssl/server/tls.key
{{ else }}
- --insecure-transport=true
- --insecure-skip-tls-verify=true
- --endpoints=http://{{ .Values.name }}-local:{{ .Values.etcd.clientPort }}
{{- end }}
- --etcd-connection-timeout={{ .Values.backup.etcdConnectionTimeout }}
- --delta-snapshot-period={{ int $.Values.backup.deltaSnapshotPeriod }}
{{- if .Values.backup.deltaSnapshotPeriod }}
- --delta-snapshot-period={{ .Values.backup.deltaSnapshotPeriod }}
{{- end }}
{{- if .Values.backup.deltaSnapshotMemoryLimit }}
- --delta-snapshot-memory-limit={{ int $.Values.backup.deltaSnapshotMemoryLimit }}
{{- end }}
# {{- if and .Values.etcd.username .Values.etcd.password }}
# - --etcd-username={{ .Values.etcd.username }}
# - --etcd-password={{ .Values.etcd.password }}
# {{- end }}
- --garbage-collection-period={{int $.Values.backup.garbageCollectionPeriod }}
{{- if .Values.backup.garbageCollectionPeriod }}
- --garbage-collection-period={{ .Values.backup.garbageCollectionPeriod }}
{{- end }}
- --snapstore-temp-directory={{ .Values.backup.snapstoreTempDir }}
image: {{ .Values.backup.image }}
imagePullPolicy: {{ .Values.backup.pullPolicy }}
Expand Down
27 changes: 23 additions & 4 deletions charts/etcd/values.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
replicas: 1
name: test
uid: uid: uuid-of-etcd
serviceName: test
configMapName: test

storageCapacity: 16Gi
replicas: 1

tlsServerSecret: etcd-server-tls
tlsClientSecret: etcd-client-tls
tlsCASecret: ca-etcd
podAnnotations: {}
annotations: {}
labels: {}

etcd:
initialClusterToken: initial
initialClusterState: new
enableTLS: false
pullPolicy: IfNotPresent
metrics: basic
clientPort: 2379
serverPort: 2380
Expand All @@ -22,6 +30,12 @@ etcd:
#password: password

backup:
pullPolicy: IfNotPresent
snapstoreTempDir: "/tmp"
etcdConnectionTimeout: 30
etcdQuotaBytes: 8Gi
garbageCollectionPolicy: LimitBased
maxBackups: 7
resources:
limits:
cpu: 100m
Expand All @@ -30,6 +44,11 @@ backup:
cpu: 50m
memory: 128Mi

volumeClaimTemplateName: test
storageClass: ""
storageCapacity: 16Gi

store:
storageProvider: ""
storePrefix: ""
storePrefix: ""
storageContainer: ""
11 changes: 6 additions & 5 deletions config/samples/druid_v1alpha1_etcd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ metadata:
role: test
spec:
selector:
app: etcd-statefulset
garden.sapcloud.io/role: controlplane
role: test
matchLabels:
app: etcd-statefulset
garden.sapcloud.io/role: controlplane
role: test
annotations:
app: etcd-statefulset
garden.sapcloud.io/role: controlplane
Expand All @@ -36,14 +37,14 @@ spec:
clientPort: 2379
serverPort: 2380
backup:
image: eu.gcr.io/gardener-project/gardener/etcdbrctl:0.8.0-dev-dd26b65a2ab4efd77805584b33e8c559dd3c6d53
image: eu.gcr.io/gardener-project/gardener/etcdbrctl:0.8.0
port: 8080
fullSnapshotSchedule: '0 */24 * * *'
resources:
limits: {cpu: 500m, memory: 2Gi}
requests: {cpu: 23m, memory: 128Mi}
garbageCollectionPolicy: Exponential
Quota: 8Gi
quota: 8Gi
garbageCollectionPeriod: 43200s
deltaSnapshotPeriod: 300s
deltaSnapshotMemoryLimit: 1Gi
Expand Down
29 changes: 28 additions & 1 deletion controllers/etcd_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,12 @@ func (r *EtcdReconciler) getMapFromEtcd(etcd *druidv1alpha1.Etcd) (map[string]in
if etcd.Spec.Etcd.Quota != nil {
quota = etcd.Spec.Etcd.Quota.Value()
}

var deltaSnapshotMemoryLimit int64 = 0
if etcd.Spec.Backup.DeltaSnapshotMemoryLimit != nil {
deltaSnapshotMemoryLimit = etcd.Spec.Backup.DeltaSnapshotMemoryLimit.Value()
}

backupValues := map[string]interface{}{
"image": etcd.Spec.Backup.Image,
"fullSnapshotSchedule": etcd.Spec.Backup.FullSnapshotSchedule,
Expand All @@ -700,7 +706,7 @@ func (r *EtcdReconciler) getMapFromEtcd(etcd *druidv1alpha1.Etcd) (map[string]in
"snapstoreTempDir": "/tmp",
"garbageCollectionPeriod": etcd.Spec.Backup.GarbageCollectionPeriod,
"deltaSnapshotPeriod": etcd.Spec.Backup.DeltaSnapshotPeriod,
"deltaSnapshotMemoryLimit": etcd.Spec.Backup.DeltaSnapshotMemoryLimit,
"deltaSnapshotMemoryLimit": deltaSnapshotMemoryLimit,
}

values := map[string]interface{}{
Expand Down Expand Up @@ -883,6 +889,27 @@ func (r *EtcdReconciler) removeFinalizersToDependantSecrets(etcd *druidv1alpha1.
}
}
}

caSecret := corev1.Secret{}
err = r.Client.Get(context.TODO(), types.NamespacedName{
Name: etcd.Spec.Etcd.TLS.TLSCASecretRef.Name,
Namespace: etcd.Namespace,
}, &caSecret)

if err != nil && !errors.IsNotFound(err) {
return err
}
if err == nil {
if finalizers := sets.NewString(caSecret.Finalizers...); finalizers.Has(FinalizerName) {
logger.Infof("Removing finalizer (%s) from secret %s", FinalizerName, caSecret.GetName())
caSecretCopy := caSecret.DeepCopy()
finalizers.Delete(FinalizerName)
caSecretCopy.Finalizers = finalizers.UnsortedList()
if err := r.Update(context.TODO(), caSecretCopy); err != nil && !errors.IsNotFound(err) {
return err
}
}
}
}
return nil
}
Expand Down

0 comments on commit 37c64d7

Please sign in to comment.