From c7480ab845ebacaaf540db6df6690da5ac2ef08f Mon Sep 17 00:00:00 2001 From: Kyle Squizzato Date: Tue, 15 Oct 2024 16:05:18 -0700 Subject: [PATCH] Add support for custom image.repository and chartExtensionRepository across templates In order to support airgap, users will need to be able to specify custom image.repository values and chartExtensionRepository URLs to be able to download extension images and charts on 'ManagedClusters'. These additions across the helm templates allow them to do so. Signed-off-by: Kyle Squizzato --- config/dev/aws-managedcluster.yaml | 4 +- .../templates/k0smotroncontrolplane.yaml | 11 ++++ templates/cluster/aws-hosted-cp/values.yaml | 7 +++ .../templates/k0scontrolplane.yaml | 19 ++++-- .../cluster/aws-standalone-cp/values.yaml | 7 +++ .../templates/k0smotroncontrolplane.yaml | 11 ++++ templates/cluster/azure-hosted-cp/values.yaml | 7 +++ .../templates/k0scontrolplane.yaml | 13 ++++- .../cluster/azure-standalone-cp/values.yaml | 7 +++ .../templates/k0smotroncontrolplane.yaml | 25 +++++++- .../cluster/vsphere-hosted-cp/values.yaml | 7 +++ .../templates/k0scontrolplane.yaml | 58 +++++++++---------- .../cluster/vsphere-standalone-cp/values.yaml | 7 +++ .../cluster-api-provider-aws/values.yaml | 3 + .../cluster-api-provider-azure/values.yaml | 3 + .../cluster-api-provider-vsphere/values.yaml | 3 + templates/provider/cluster-api/values.yaml | 3 + templates/provider/k0smotron/values.yaml | 3 + templates/service/ingress-nginx/values.yaml | 3 + templates/service/kyverno/values.yaml | 3 + 20 files changed, 167 insertions(+), 37 deletions(-) create mode 100644 templates/service/ingress-nginx/values.yaml create mode 100644 templates/service/kyverno/values.yaml diff --git a/config/dev/aws-managedcluster.yaml b/config/dev/aws-managedcluster.yaml index dd303141c..ccc73354a 100644 --- a/config/dev/aws-managedcluster.yaml +++ b/config/dev/aws-managedcluster.yaml @@ -1,7 +1,7 @@ apiVersion: hmc.mirantis.com/v1alpha1 kind: ManagedCluster metadata: - name: aws-dev + name: squizz-aws-dev namespace: ${NAMESPACE} spec: credential: aws-cluster-identity-cred @@ -13,7 +13,7 @@ spec: instanceType: t3.small controlPlaneNumber: 1 publicIP: true - region: us-west-2 + region: us-west-1 worker: instanceType: t3.small workersNumber: 1 diff --git a/templates/cluster/aws-hosted-cp/templates/k0smotroncontrolplane.yaml b/templates/cluster/aws-hosted-cp/templates/k0smotroncontrolplane.yaml index 5fb372752..cf0f2df81 100644 --- a/templates/cluster/aws-hosted-cp/templates/k0smotroncontrolplane.yaml +++ b/templates/cluster/aws-hosted-cp/templates/k0smotroncontrolplane.yaml @@ -27,9 +27,17 @@ spec: helm: repositories: - name: aws-cloud-controller-manager + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://kubernetes.github.io/cloud-provider-aws + {{- end }} - name: aws-ebs-csi-driver + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + {{- end }} charts: - name: aws-cloud-controller-manager namespace: kube-system @@ -37,6 +45,7 @@ spec: version: "0.0.8" values: | image: + repository: {{ .Values.image.repository }} tag: v1.30.3 args: - --v=2 @@ -53,6 +62,8 @@ spec: chartname: aws-ebs-csi-driver/aws-ebs-csi-driver version: 2.33.0 values: | + image: + repository: {{ .Values.image.repository }} defaultStorageClass: enabled: true node: diff --git a/templates/cluster/aws-hosted-cp/values.yaml b/templates/cluster/aws-hosted-cp/values.yaml index 4949d631b..4b15482b8 100644 --- a/templates/cluster/aws-hosted-cp/values.yaml +++ b/templates/cluster/aws-hosted-cp/values.yaml @@ -47,3 +47,10 @@ k0smotron: # K0s parameters k0s: version: v1.30.4+k0s.0 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" \ No newline at end of file diff --git a/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml b/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml index 8d17a3497..0003f93c8 100644 --- a/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml +++ b/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml @@ -27,10 +27,18 @@ spec: extensions: helm: repositories: - - name: aws-cloud-controller-manager - url: https://kubernetes.github.io/cloud-provider-aws - - name: aws-ebs-csi-driver - url: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + - name: aws-cloud-controller-manager + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} + url: https://kubernetes.github.io/cloud-provider-aws + {{- end }} + - name: aws-ebs-csi-driver + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} + url: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + {{- end }} charts: - name: aws-cloud-controller-manager namespace: kube-system @@ -40,6 +48,7 @@ spec: nodeSelector: node-role.kubernetes.io/control-plane: "true" image: + repository: {{ .Values.image.repository }} tag: v1.30.3 args: - --v=2 @@ -52,6 +61,8 @@ spec: chartname: aws-ebs-csi-driver/aws-ebs-csi-driver version: 2.33.0 values: | + image: + repository: {{ .Values.image.repository }} defaultStorageClass: enabled: true node: diff --git a/templates/cluster/aws-standalone-cp/values.yaml b/templates/cluster/aws-standalone-cp/values.yaml index 2d09cf5c8..f38ed10c7 100644 --- a/templates/cluster/aws-standalone-cp/values.yaml +++ b/templates/cluster/aws-standalone-cp/values.yaml @@ -51,3 +51,10 @@ k0s: # Optionally install applications defined under # templates/beachheadservices into target cluster installBeachHeadServices: false + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" \ No newline at end of file diff --git a/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml b/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml index c353a085b..e34f88d0d 100644 --- a/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml +++ b/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml @@ -26,9 +26,17 @@ spec: helm: repositories: - name: cloud-provider-azure + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo + {{- end }} - name: azuredisk-csi-driver + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/charts + {{- end }} charts: - name: cloud-provider-azure namespace: kube-system @@ -37,6 +45,7 @@ spec: order: 1 values: | cloudControllerManager: + imageRepository: {{ .Values.image.repository }} nodeSelector: node-role.kubernetes.io/control-plane: null - name: azuredisk-csi-driver @@ -45,5 +54,7 @@ spec: version: 1.30.3 order: 2 values: | + image: + baseRepo: {{ .Values.image.repository }} linux: kubelet: "/var/lib/k0s/kubelet" diff --git a/templates/cluster/azure-hosted-cp/values.yaml b/templates/cluster/azure-hosted-cp/values.yaml index 3440db477..53670b825 100644 --- a/templates/cluster/azure-hosted-cp/values.yaml +++ b/templates/cluster/azure-hosted-cp/values.yaml @@ -48,3 +48,10 @@ k0smotron: # K0s parameters k0s: version: v1.30.4+k0s.0 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" \ No newline at end of file diff --git a/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml b/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml index 95294cf93..2508c89f0 100644 --- a/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml +++ b/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml @@ -35,9 +35,17 @@ spec: helm: repositories: - name: cloud-provider-azure + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo + {{- end }} - name: azuredisk-csi-driver + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/charts + {{- end }} charts: - name: cloud-provider-azure namespace: kube-system @@ -46,14 +54,17 @@ spec: order: 1 values: | cloudControllerManager: + imageRepository: {{ .Values.image.repository }} nodeSelector: - node-role.kubernetes.io/control-plane: "true" + node-role.kubernetes.io/control-plane: null - name: azuredisk-csi-driver namespace: kube-system chartname: azuredisk-csi-driver/azuredisk-csi-driver version: 1.30.3 order: 2 values: | + image: + baseRepo: {{ .Values.image.repository }} linux: kubelet: "/var/lib/k0s/kubelet" machineTemplate: diff --git a/templates/cluster/azure-standalone-cp/values.yaml b/templates/cluster/azure-standalone-cp/values.yaml index 9b9bb0520..fbf534f97 100644 --- a/templates/cluster/azure-standalone-cp/values.yaml +++ b/templates/cluster/azure-standalone-cp/values.yaml @@ -46,3 +46,10 @@ worker: # K0s parameters k0s: version: v1.30.4+k0s.0 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" \ No newline at end of file diff --git a/templates/cluster/vsphere-hosted-cp/templates/k0smotroncontrolplane.yaml b/templates/cluster/vsphere-hosted-cp/templates/k0smotroncontrolplane.yaml index bf60832a4..e86e0733c 100644 --- a/templates/cluster/vsphere-hosted-cp/templates/k0smotroncontrolplane.yaml +++ b/templates/cluster/vsphere-hosted-cp/templates/k0smotroncontrolplane.yaml @@ -26,9 +26,17 @@ spec: helm: repositories: - name: vsphere-cpi + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://kubernetes.github.io/cloud-provider-vsphere - - name: mirantis + {{- end }} + - name: vsphere-csi-driver + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://charts.mirantis.com + {{- end }} charts: - name: vsphere-cpi chartname: vsphere-cpi/vsphere-cpi @@ -43,6 +51,7 @@ spec: username: "{{ .Values.vsphere.username }}" password: "{{ .Values.vsphere.password }}" daemonset: + image: {{ .Values.image.repository }}/cloud-provider-vsphere affinity: null tolerations: - effect: NoSchedule @@ -81,6 +90,20 @@ spec: enabled: true images: driver: + repo: {{ .Values.image.repository }}/csi-vsphere/driver tag: v3.1.2 syncer: + repo: {{ .Values.image.repository }}/csi-vsphere/syncer tag: v3.1.2 + nodeDriverRegistrar: + repo: {{ .Values.image.repository }}/sig-storage/csi-node-driver-registrar + csiAttacher: + repo: {{ .Values.image.repository }}/sig-storage/csi-attacher + csiResizer: + repo: {{ .Values.image.repository }}/sig-storage/csi-resizer + csiProvisioner: + repo: {{ .Values.image.repository }}/sig-storage/csi-provisioner + csiSnapshotter: + repo: {{ .Values.image.repository }}/sig-storage/csi-snapshotter + livenessProbe: + repo: {{ .Values.image.repository }}/csi-vsphere/livenessprobe diff --git a/templates/cluster/vsphere-hosted-cp/values.yaml b/templates/cluster/vsphere-hosted-cp/values.yaml index ca9334205..6901d39a9 100644 --- a/templates/cluster/vsphere-hosted-cp/values.yaml +++ b/templates/cluster/vsphere-hosted-cp/values.yaml @@ -48,3 +48,10 @@ k0smotron: # K0s parameters k0s: version: v1.30.4+k0s.0 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" \ No newline at end of file diff --git a/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml b/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml index 038fb1a93..c13ae7154 100644 --- a/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml +++ b/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml @@ -34,41 +34,23 @@ spec: extensions: helm: repositories: - - name: kube-vip - url: https://kube-vip.github.io/helm-charts - name: vsphere-cpi + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://kubernetes.github.io/cloud-provider-vsphere - - name: mirantis + {{- end }} + - name: vsphere-csi-driver + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://charts.mirantis.com + {{- end }} charts: - - name: kube-vip - chartname: kube-vip/kube-vip - version: 0.6.1 - order: 1 - namespace: kube-system - values: | - config: - address: {{ .Values.controlPlaneEndpointIP }} - env: - svc_enable: "true" - cp_enable: "true" - lb_enable: "false" - nodeSelector: - node-role.kubernetes.io/control-plane: "true" - tolerations: - - effect: NoSchedule - key: node-role.kubernetes.io/master - operator: Exists - - effect: NoSchedule - key: node-role.kubernetes.io/control-plane - operator: Exists - - effect: NoSchedule - key: node.cloudprovider.kubernetes.io/uninitialized - value: "true" - name: vsphere-cpi chartname: vsphere-cpi/vsphere-cpi version: 1.31.0 - order: 2 + order: 1 namespace: kube-system values: | config: @@ -78,6 +60,8 @@ spec: username: "{{ .Values.vsphere.username }}" password: "{{ .Values.vsphere.password }}" daemonset: + image: {{ .Values.image.repository }}/cloud-provider-vsphere + affinity: null tolerations: - effect: NoSchedule key: node.cloudprovider.kubernetes.io/uninitialized @@ -97,7 +81,7 @@ spec: - name: vsphere-csi chartname: mirantis/vsphere-csi-driver version: 0.0.2 - order: 3 + order: 2 namespace: kube-system values: | vcenterConfig: @@ -107,15 +91,31 @@ spec: user: "{{ .Values.vsphere.username }}" password: "{{ .Values.vsphere.password }}" datacenters: {{ .Values.vsphere.datacenter }} + controller: + nodeAffinity: null node: kubeletPath: /var/lib/k0s/kubelet defaultStorageClass: enabled: true images: driver: + repo: {{ .Values.image.repository }}/csi-vsphere/driver tag: v3.1.2 syncer: + repo: {{ .Values.image.repository }}/csi-vsphere/syncer tag: v3.1.2 + nodeDriverRegistrar: + repo: {{ .Values.image.repository }}/sig-storage/csi-node-driver-registrar + csiAttacher: + repo: {{ .Values.image.repository }}/sig-storage/csi-attacher + csiResizer: + repo: {{ .Values.image.repository }}/sig-storage/csi-resizer + csiProvisioner: + repo: {{ .Values.image.repository }}/sig-storage/csi-provisioner + csiSnapshotter: + repo: {{ .Values.image.repository }}/sig-storage/csi-snapshotter + livenessProbe: + repo: {{ .Values.image.repository }}/csi-vsphere/livenessprobe machineTemplate: infrastructureRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 diff --git a/templates/cluster/vsphere-standalone-cp/values.yaml b/templates/cluster/vsphere-standalone-cp/values.yaml index 71415b7d1..7fe5d8244 100644 --- a/templates/cluster/vsphere-standalone-cp/values.yaml +++ b/templates/cluster/vsphere-standalone-cp/values.yaml @@ -48,3 +48,10 @@ worker: # K0s parameters k0s: version: v1.30.4+k0s.0 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" \ No newline at end of file diff --git a/templates/provider/cluster-api-provider-aws/values.yaml b/templates/provider/cluster-api-provider-aws/values.yaml index 98a6fb0f3..fa429d3a4 100644 --- a/templates/provider/cluster-api-provider-aws/values.yaml +++ b/templates/provider/cluster-api-provider-aws/values.yaml @@ -5,3 +5,6 @@ configSecret: config: AWS_B64ENCODED_CREDENTIALS: Cg== + +image: + repository: "" \ No newline at end of file diff --git a/templates/provider/cluster-api-provider-azure/values.yaml b/templates/provider/cluster-api-provider-azure/values.yaml index dac04d5b0..83ab86d1d 100644 --- a/templates/provider/cluster-api-provider-azure/values.yaml +++ b/templates/provider/cluster-api-provider-azure/values.yaml @@ -4,3 +4,6 @@ configSecret: namespace: "" config: {} + +image: + repository: "" \ No newline at end of file diff --git a/templates/provider/cluster-api-provider-vsphere/values.yaml b/templates/provider/cluster-api-provider-vsphere/values.yaml index eba3767c9..1e8b4e465 100644 --- a/templates/provider/cluster-api-provider-vsphere/values.yaml +++ b/templates/provider/cluster-api-provider-vsphere/values.yaml @@ -20,3 +20,6 @@ config: VSPHERE_SSH_AUTHORIZED_KEY: "" VSPHERE_STORAGE_POLICY: "" CPI_IMAGE_K8S_VERSION: "" + +image: + repository: "" \ No newline at end of file diff --git a/templates/provider/cluster-api/values.yaml b/templates/provider/cluster-api/values.yaml index dac04d5b0..1b6059032 100644 --- a/templates/provider/cluster-api/values.yaml +++ b/templates/provider/cluster-api/values.yaml @@ -3,4 +3,7 @@ configSecret: name: "" namespace: "" +image: + repository: "" + config: {} diff --git a/templates/provider/k0smotron/values.yaml b/templates/provider/k0smotron/values.yaml index dac04d5b0..83ab86d1d 100644 --- a/templates/provider/k0smotron/values.yaml +++ b/templates/provider/k0smotron/values.yaml @@ -4,3 +4,6 @@ configSecret: namespace: "" config: {} + +image: + repository: "" \ No newline at end of file diff --git a/templates/service/ingress-nginx/values.yaml b/templates/service/ingress-nginx/values.yaml new file mode 100644 index 000000000..0d2249229 --- /dev/null +++ b/templates/service/ingress-nginx/values.yaml @@ -0,0 +1,3 @@ +global: + image: + registry: "" \ No newline at end of file diff --git a/templates/service/kyverno/values.yaml b/templates/service/kyverno/values.yaml new file mode 100644 index 000000000..0d2249229 --- /dev/null +++ b/templates/service/kyverno/values.yaml @@ -0,0 +1,3 @@ +global: + image: + registry: "" \ No newline at end of file