Skip to content

Commit

Permalink
Allow feature gates to be added to etcd-druid and vendor `etcd-drui…
Browse files Browse the repository at this point in the history
…d@v0.19.1` (gardener#8300)

* Added feature gates to etcd-druid

* Vendor etcd-druid@v0.19.0 and update CRDs

* Updated helm chart and examples

* Adapt PR to etcd-druid:v0.19.1
  • Loading branch information
aaronfern authored Aug 9, 2023
1 parent e0469dc commit 4a58216
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 12 deletions.
2 changes: 2 additions & 0 deletions charts/gardener/gardenlet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ config:
# backupLeaderElection:
# reelectionPeriod: 5s
# etcdConnectionTimeout: 5s
# featureGates:
# UseEtcdWrapper: true
# logging:
# enabled: false
# monitoring:
Expand Down
2 changes: 2 additions & 0 deletions charts/gardener/operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ config:
# backupLeaderElection:
# reelectionPeriod: 5s
# etcdConnectionTimeout: 5s
# featureGates:
# UseEtcdWrapper: true
gardenCare:
syncPeriod: 1m
conditionThresholds:
Expand Down
2 changes: 2 additions & 0 deletions example/20-componentconfig-gardenlet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ etcdConfig:
# backupLeaderElection:
# reelectionPeriod: 5s
# etcdConnectionTimeout: 5s
# featureGates:
# UseEtcdWrapper: true
# monitoring:
# shoot:
# enabled: true
Expand Down
3 changes: 3 additions & 0 deletions example/gardener-local/gardenlet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ config:
# If disabled, a Shoot cluster in local setup won't be able to use the registry cache
# (it will be still able to pull images but registry cache won't be used).
ContainerdRegistryHostsDir: true
etcdConfig:
featureGates:
UseEtcdWrapper: false
logging:
enabled: true
vali:
Expand Down
2 changes: 2 additions & 0 deletions example/operator/10-componentconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ controllers:
enableBackupCompaction: false
eventsThreshold: 1000000
activeDeadlineDuration: "3h"
# featureGates:
# UseEtcdWrapper: true
gardenCare:
syncPeriod: 1m
conditionThresholds:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2
github.com/fluent/fluent-operator/v2 v2.2.0
github.com/gardener/dependency-watchdog v1.1.1
github.com/gardener/etcd-druid v0.18.4
github.com/gardener/etcd-druid v0.19.1
github.com/gardener/hvpa-controller/api v0.5.0
github.com/gardener/machine-controller-manager v0.48.1
github.com/go-logr/logr v1.2.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/gardener/dependency-watchdog v1.1.1 h1:jS5KcZJ/XKBdHniL3NYy2mRUOtGsrNqK0NWuj1L24mI=
github.com/gardener/dependency-watchdog v1.1.1/go.mod h1:mShlo0jeS+YD0lq/GYVj/VU55B7lT0mfjqC2knFAnLk=
github.com/gardener/etcd-druid v0.18.4 h1:CyDQRRBPDXYSoNPaSnrs4lw3Ht+aD3LuQZQliJz+Gw0=
github.com/gardener/etcd-druid v0.18.4/go.mod h1:NfBcP/xYSrbbtbPPFzEQ7CSQ73l+GtNQgx466Gv7FW0=
github.com/gardener/etcd-druid v0.19.1 h1:ENy1GTYNz6CREr6czLBhQPlACtlOsWYkZlvcg9Ne/lQ=
github.com/gardener/etcd-druid v0.19.1/go.mod h1:l4pOUbvQS7lWAcLssOtM7jtFex8YtwoT7o5LggNSz/Y=
github.com/gardener/hvpa-controller/api v0.5.0 h1:f4F3O7YUrenwh4S3TgPREPiB287JjjUiUL18OqPLyAA=
github.com/gardener/hvpa-controller/api v0.5.0/go.mod h1:QQl3ELkCaki+8RhXl0FZMfvnm0WCGwGJlGmrxJj6lvM=
github.com/gardener/machine-controller-manager v0.48.1 h1:Oxr5e6gRm7P40Ds4nGlga/0nmfF7cH4rOfjthR6Mm38=
Expand Down
5 changes: 5 additions & 0 deletions pkg/component/etcd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ func getDruidDeployCommands(etcdConfig *config.ETCDConfig) []string {
command = append(command, "--active-deadline-duration="+etcdConfig.BackupCompactionController.ActiveDeadlineDuration.Duration.String())
}

// Add feature gates to the etcd druid command
if etcdConfig.FeatureGates != nil {
command = append(command, kubernetesutils.FeatureGatesToCommandLineParameter(etcdConfig.FeatureGates))
}

return command
}

Expand Down
78 changes: 78 additions & 0 deletions pkg/component/etcd/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ var _ = Describe("Etcd", func() {
imageVectorOverwriteEmpty *string
imageVectorOverwriteFull = pointer.String("some overwrite")
priorityClassName = "some-priority-class"
useEtcdWrapper = "UseEtcdWrapper"

managedResourceName = "etcd-druid"
managedResourceSecretName = "managedresource-" + managedResourceName
Expand Down Expand Up @@ -433,6 +434,58 @@ spec:
name: ` + configMapName + `
name: imagevector-overwrite
status: {}
`
deploymentWithFeatureGates = `apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
gardener.cloud/role: etcd-druid
high-availability-config.resources.gardener.cloud/type: controller
name: etcd-druid
namespace: ` + namespace + `
spec:
replicas: 1
revisionHistoryLimit: 1
selector:
matchLabels:
gardener.cloud/role: etcd-druid
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
gardener.cloud/role: etcd-druid
networking.gardener.cloud/to-dns: allowed
networking.gardener.cloud/to-runtime-apiserver: allowed
spec:
containers:
- command:
- /etcd-druid
- --enable-leader-election=true
- --ignore-operation-annotation=false
- --disable-etcd-serviceaccount-automount=true
- --workers=25
- --custodian-workers=3
- --compaction-workers=3
- --enable-backup-compaction=true
- --etcd-events-threshold=1000000
- --active-deadline-duration=3h0m0s
- --feature-gates=UseEtcdWrapper=true
image: ` + etcdDruidImage + `
imagePullPolicy: IfNotPresent
name: etcd-druid
ports:
- containerPort: 8080
resources:
limits:
memory: 512Mi
requests:
cpu: 50m
memory: 128Mi
priorityClassName: ` + priorityClassName + `
serviceAccountName: etcd-druid
status: {}
`
serviceYAML = `apiVersion: v1
kind: Service
Expand Down Expand Up @@ -581,6 +634,31 @@ status:

Expect(bootstrapper.Deploy(ctx)).To(Succeed())
})

It("should successfully deploy all the resources (w/ feature gates being present in etcd config)", func() {
etcdConfig.FeatureGates = map[string]bool{
useEtcdWrapper: true,
}
managedResourceSecret.Data["deployment__"+namespace+"__etcd-druid.yaml"] = []byte(deploymentWithFeatureGates)

utilruntime.Must(kubernetesutils.MakeUnique(managedResourceSecret))
gomock.InOrder(
c.EXPECT().Get(ctx, kubernetesutils.Key(namespace, managedResourceSecret.Name), gomock.AssignableToTypeOf(&corev1.Secret{})),
c.EXPECT().Update(ctx, gomock.AssignableToTypeOf(&corev1.Secret{})).Do(func(ctx context.Context, obj client.Object, opts ...client.UpdateOption) {
Expect(obj).To(Equal(managedResourceSecret))
}),
c.EXPECT().Get(ctx, kubernetesutils.Key(namespace, managedResourceName), gomock.AssignableToTypeOf(&resourcesv1alpha1.ManagedResource{})),
c.EXPECT().Get(ctx, kubernetesutils.Key(namespace, managedResourceSecret.Name), gomock.AssignableToTypeOf(&corev1.Secret{})),
c.EXPECT().Patch(ctx, gomock.AssignableToTypeOf(&corev1.Secret{}), gomock.Any()),
c.EXPECT().Update(ctx, gomock.AssignableToTypeOf(&resourcesv1alpha1.ManagedResource{})).Do(func(ctx context.Context, obj client.Object, opts ...client.UpdateOption) {
managedResource.Spec.SecretRefs = []corev1.LocalObjectReference{{Name: managedResourceSecret.Name}}
utilruntime.Must(references.InjectAnnotations(managedResource))
Expect(obj).To(DeepEqual(managedResource))
}),
)

Expect(bootstrapper.Deploy(ctx)).To(Succeed())
})
})

Describe("#Wait", func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Source: https://github.com/gardener/etcd-druid/blob/v0.18.4/charts/druid/charts/crds/templates/10-crd-druid.gardener.cloud_etcdcopybackupstasks.yaml
# Source: https://github.com/gardener/etcd-druid/blob/v0.19.1/charts/druid/charts/crds/templates/10-crd-druid.gardener.cloud_etcdcopybackupstasks.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Source: https://github.com/gardener/etcd-druid/blob/v0.18.4/charts/druid/charts/crds/templates/10-crd-druid.gardener.cloud_etcds.yaml
# Source: https://github.com/gardener/etcd-druid/blob/v0.19.1/charts/druid/charts/crds/templates/10-crd-druid.gardener.cloud_etcds.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
5 changes: 5 additions & 0 deletions pkg/gardenlet/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ type ETCDConfig struct {
BackupCompactionController *BackupCompactionController
// BackupLeaderElection contains configuration for the leader election for the etcd backup-restore sidecar.
BackupLeaderElection *ETCDBackupLeaderElection
// FeatureGates is a map of feature names to bools that enable or disable alpha/experimental
// features. This field modifies piecemeal the built-in default values from
// "github.com/gardener/etcd-druid/pkg/features/features.go".
// Default: nil
FeatureGates map[string]bool
}

// ETCDController contains config specific to ETCD controller
Expand Down
6 changes: 6 additions & 0 deletions pkg/gardenlet/apis/config/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ type ETCDConfig struct {
// BackupLeaderElection contains configuration for the leader election for the etcd backup-restore sidecar.
// +optional
BackupLeaderElection *ETCDBackupLeaderElection `json:"backupLeaderElection,omitempty"`
// FeatureGates is a map of feature names to bools that enable or disable alpha/experimental
// features. This field modifies piecemeal the built-in default values from
// "github.com/gardener/etcd-druid/pkg/features/features.go".
// Default: nil
// +optional
FeatureGates map[string]bool `json:"featureGates,omitempty"`
}

// ETCDController contains config specific to ETCD controller
Expand Down
2 changes: 2 additions & 0 deletions pkg/gardenlet/apis/config/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/gardenlet/apis/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/gardenlet/apis/config/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/gardener/etcd-druid/pkg/utils/lease.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ github.com/fsnotify/fsnotify
## explicit; go 1.20
github.com/gardener/dependency-watchdog/api/prober
github.com/gardener/dependency-watchdog/api/weeder
# github.com/gardener/etcd-druid v0.18.4
# github.com/gardener/etcd-druid v0.19.1
## explicit; go 1.20
github.com/gardener/etcd-druid/api/v1alpha1
github.com/gardener/etcd-druid/api/validation
Expand Down

0 comments on commit 4a58216

Please sign in to comment.