Skip to content

Commit

Permalink
Merge pull request #536 from kahirokunn/kubeadm-feature-flag
Browse files Browse the repository at this point in the history
✨ Add featureGates to ControlPlaneProvider
  • Loading branch information
k8s-ci-robot authored Dec 12, 2024
2 parents e70a9ee + 80c8b64 commit 7eb2d57
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 1 deletion.
15 changes: 14 additions & 1 deletion hack/charts/cluster-api-operator/templates/control-plane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ metadata:
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "2"
{{- if or $controlPlaneVersion $.Values.configSecret.name }}
{{- if or $controlPlaneVersion $.Values.configSecret.name $.Values.manager }}
spec:
{{- end}}
{{- if $controlPlaneVersion }}
version: {{ $controlPlaneVersion }}
{{- end }}
{{- if $.Values.manager }}
manager:
{{- if hasKey $.Values.manager.featureGates $controlPlaneName }}
{{- range $key, $value := $.Values.manager.featureGates }}
{{- if eq $key $controlPlaneName }}
featureGates:
{{- range $k, $v := $value }}
{{ $k }}: {{ $v }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if $.Values.configSecret.name }}
configSecret:
name: {{ $.Values.configSecret.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ metadata:
"argocd.argoproj.io/sync-wave": "2"
{{- with .Values.configSecret }}
spec:
{{- if $.Values.manager }}
manager:
{{- if and $.Values.manager.featureGates $.Values.manager.featureGates.kubeadm }}
featureGates:
{{- range $key, $value := $.Values.manager.featureGates.kubeadm }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
{{- end }}
configSecret:
name: {{ .name }}
{{- if .namespace }}
Expand Down
16 changes: 16 additions & 0 deletions test/e2e/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,20 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(MatchYAML(string(expectedManifests)))
})
It("should deploy kubeadm control plane with manager specified", func() {
manifests, err := helmChart.Run(map[string]string{
"core": "cluster-api",
"controlPlane": "kubeadm",
"bootstrap": "kubeadm",
"infrastructure": "docker",
"addon": "helm",
"manager.featureGates.kubeadm.ClusterTopology": "true",
"manager.featureGates.kubeadm.MachinePool": "true",
})
Expect(err).ToNot(HaveOccurred())
Expect(manifests).ToNot(BeEmpty())
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "kubeadm-manager-defined.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(MatchYAML(string(expectedManifests)))
})
})
108 changes: 108 additions & 0 deletions test/e2e/resources/kubeadm-manager-defined.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
# Source: cluster-api-operator/templates/addon.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "1"
"argocd.argoproj.io/sync-wave": "1"
name: helm-addon-system
---
# Source: cluster-api-operator/templates/bootstrap.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "1"
name: kubeadm-bootstrap-system
---
# Source: cluster-api-operator/templates/control-plane.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "1"
name: kubeadm-control-plane-system
---
# Source: cluster-api-operator/templates/core.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "1"
name: capi-system
---
# Source: cluster-api-operator/templates/infra.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "1"
"argocd.argoproj.io/sync-wave": "1"
name: docker-infrastructure-system
---
# Source: cluster-api-operator/templates/addon.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: AddonProvider
metadata:
name: helm
namespace: helm-addon-system
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "2"
"argocd.argoproj.io/sync-wave": "2"
---
# Source: cluster-api-operator/templates/bootstrap.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: BootstrapProvider
metadata:
name: kubeadm
namespace: kubeadm-bootstrap-system
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "2"
---
# Source: cluster-api-operator/templates/control-plane.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: ControlPlaneProvider
metadata:
name: kubeadm
namespace: kubeadm-control-plane-system
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "2"
spec:
manager:
featureGates:
ClusterTopology: true
MachinePool: true
---
# Source: cluster-api-operator/templates/core.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: CoreProvider
metadata:
name: cluster-api
namespace: capi-system
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "2"
"argocd.argoproj.io/sync-wave": "2"
manager:
---
# Source: cluster-api-operator/templates/infra.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: InfrastructureProvider
metadata:
name: docker
namespace: docker-infrastructure-system
annotations:
"helm.sh/hook": "post-install,post-upgrade"
"helm.sh/hook-weight": "2"
"argocd.argoproj.io/sync-wave": "2"
spec:
manager:

0 comments on commit 7eb2d57

Please sign in to comment.