From afcb3878fa29ca547bfc936a771a4d88c77176f2 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 | 19 ++++-- templates/cluster/azure-hosted-cp/values.yaml | 7 ++ .../templates/k0scontrolplane.yaml | 15 ++++- .../cluster/azure-standalone-cp/values.yaml | 7 ++ .../templates/k0smotroncontrolplane.yaml | 25 ++++++- .../cluster/vsphere-hosted-cp/values.yaml | 7 ++ .../templates/k0scontrolplane.yaml | 65 ++++++++++--------- .../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 + .../service/ingress-nginx-4-11-0/values.yaml | 3 + templates/service/kyverno/values.yaml | 3 + 20 files changed, 176 insertions(+), 45 deletions(-) create mode 100644 templates/service/ingress-nginx-4-11-0/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 08e84081c..8a5a0e06a 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 c19e244b7..eebc3d571 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.31.1+k0s.1 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" 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 13499710a..03f6d5bd8 100644 --- a/templates/cluster/aws-standalone-cp/values.yaml +++ b/templates/cluster/aws-standalone-cp/values.yaml @@ -47,3 +47,10 @@ worker: # K0s parameters k0s: version: v1.31.1+k0s.1 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" diff --git a/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml b/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml index 856da34f6..82867c6f6 100644 --- a/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml +++ b/templates/cluster/azure-hosted-cp/templates/k0smotroncontrolplane.yaml @@ -25,19 +25,28 @@ spec: extensions: helm: repositories: - - name: mirantis + - name: cloud-provider-azure + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://charts.mirantis.com + {{- 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 - chartname: mirantis/cloud-provider-azure + chartname: cloud-provider-azure/cloud-provider-azure version: 1.31.2 order: 1 values: | cloudControllerManager: cloudConfigSecretName: azure-cloud-provider + imageRepository: {{ .Values.image.repository }} nodeSelector: node-role.kubernetes.io/control-plane: null - name: azuredisk-csi-driver @@ -46,9 +55,7 @@ spec: version: 1.30.3 order: 2 values: | - controller: - cloudConfigSecretName: azure-cloud-provider - node: - cloudConfigSecretName: azure-cloud-provider + 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 79aa4929a..8359db9f0 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.31.1+k0s.1 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" diff --git a/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml b/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml index 415108296..6499eece6 100644 --- a/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml +++ b/templates/cluster/azure-standalone-cp/templates/k0scontrolplane.yaml @@ -27,10 +27,18 @@ spec: extensions: helm: repositories: - - name: mirantis + - name: cloud-provider-azure + {{- if .Values.extensionsChartRepository }} + url: {{ .Values.extensionsChartRepository }} + {{- else }} url: https://charts.mirantis.com + {{- 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 @@ -40,8 +48,9 @@ spec: values: | cloudControllerManager: cloudConfigSecretName: azure-cloud-provider + 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 @@ -52,6 +61,8 @@ spec: cloudConfigSecretName: azure-cloud-provider node: cloudConfigSecretName: azure-cloud-provider + 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 801889805..d33d37cc8 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.31.1+k0s.1 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" diff --git a/templates/cluster/vsphere-hosted-cp/templates/k0smotroncontrolplane.yaml b/templates/cluster/vsphere-hosted-cp/templates/k0smotroncontrolplane.yaml index 375afe4bc..f568165f5 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 @@ -39,6 +47,7 @@ spec: config: enabled: false daemonset: + image: {{ .Values.image.repository }}/cloud-provider-vsphere affinity: null tolerations: - effect: NoSchedule @@ -72,6 +81,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 9af1941b7..bba5edbbf 100644 --- a/templates/cluster/vsphere-hosted-cp/values.yaml +++ b/templates/cluster/vsphere-hosted-cp/values.yaml @@ -42,3 +42,10 @@ k0smotron: # K0s parameters k0s: version: v1.31.1+k0s.1 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" diff --git a/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml b/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml index 0b18d1813..bdb63dbdf 100644 --- a/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml +++ b/templates/cluster/vsphere-standalone-cp/templates/k0scontrolplane.yaml @@ -34,46 +34,30 @@ 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: enabled: false daemonset: + image: {{ .Values.image.repository }}/cloud-provider-vsphere + affinity: null tolerations: - effect: NoSchedule key: node.cloudprovider.kubernetes.io/uninitialized @@ -93,20 +77,41 @@ spec: - name: vsphere-csi chartname: mirantis/vsphere-csi-driver version: 0.0.2 - order: 3 + order: 2 namespace: kube-system values: | vcenterConfig: - enabled: false + enabled: true + clusterID: {{ include "cluster.name" . }} + vcenter: {{ .Values.vsphere.server }} + 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 67d95c472..d70d783aa 100644 --- a/templates/cluster/vsphere-standalone-cp/values.yaml +++ b/templates/cluster/vsphere-standalone-cp/values.yaml @@ -46,3 +46,10 @@ worker: # K0s parameters k0s: version: v1.31.1+k0s.1 + +image: + repository: "" + +# extensionsChartRepository specifies a custom Helm chart repository for +# hosting k0s extension charts +extensionsChartRepository: "" 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-4-11-0/values.yaml b/templates/service/ingress-nginx-4-11-0/values.yaml new file mode 100644 index 000000000..0d2249229 --- /dev/null +++ b/templates/service/ingress-nginx-4-11-0/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