From a2b54dcb6c0ce1bf4ed393bd603383583954b78d Mon Sep 17 00:00:00 2001 From: deepakm-ntnx Date: Wed, 20 Dec 2023 11:20:55 -0800 Subject: [PATCH] added controlPlaneEnpoint variable in clusterclass --- clusterctl.yaml.tmpl | 1 + templates/cluster-template-clusterclass.yaml | 29 +++++- templates/cluster-template-topology.yaml | 4 + templates/clusterclass/clusterclass.yaml | 92 ++++++++++++------- templates/clusterclass/nct.yaml | 5 +- templates/topology/cluster-with-topology.yaml | 6 +- 6 files changed, 94 insertions(+), 43 deletions(-) diff --git a/clusterctl.yaml.tmpl b/clusterctl.yaml.tmpl index 3345f8721b..a7c472064f 100644 --- a/clusterctl.yaml.tmpl +++ b/clusterctl.yaml.tmpl @@ -1,5 +1,6 @@ CLUSTERCTL_LOG_LEVEL: 10 EXP_CLUSTER_RESOURCE_SET: "true" +CLUSTER_TOPOLOGY: "true" NUTANIX_ENDPOINT: "" # IP or FQDN of Prism Central NUTANIX_USER: "" # Prism Central user diff --git a/templates/cluster-template-clusterclass.yaml b/templates/cluster-template-clusterclass.yaml index 8350677e40..3e8e52676c 100644 --- a/templates/cluster-template-clusterclass.yaml +++ b/templates/cluster-template-clusterclass.yaml @@ -359,13 +359,37 @@ spec: names: - ${CLUSTER_CLASS_NAME}-worker name: add-ssh-user + - definitions: + - jsonPatches: + - op: add + path: /spec/template/spec/controlPlaneEndpoint + valueFrom: + template: | + host: '{{ .controlPlaneEndpoint.IP }}' + port: {{ .controlPlaneEndpoint.Port }} + selector: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: NutanixClusterTemplate + matchResources: + infrastructureCluster: true + name: add-control-plane-endpoint variables: - name: sshKey - required: false + required: true schema: openAPIV3Schema: description: Public key to SSH onto the cluster nodes. type: string + - name: controlPlaneEndpoint + required: true + schema: + openAPIV3Schema: + properties: + IP: + type: string + Port: + type: integer + type: object workers: machineDeployments: - class: ${CLUSTER_CLASS_NAME}-worker @@ -526,9 +550,6 @@ metadata: spec: template: spec: - controlPlaneEndpoint: - host: ${CONTROL_PLANE_ENDPOINT_IP} - port: ${CONTROL_PLANE_ENDPOINT_PORT=6443} failureDomains: [] prismCentral: additionalTrustBundle: diff --git a/templates/cluster-template-topology.yaml b/templates/cluster-template-topology.yaml index ab0ac4a03f..d3177de849 100644 --- a/templates/cluster-template-topology.yaml +++ b/templates/cluster-template-topology.yaml @@ -23,6 +23,10 @@ spec: variables: - name: sshKey value: ${NUTANIX_SSH_AUTHORIZED_KEY} + - name: controlPlaneEndpoint + value: + IP: ${CONTROL_PLANE_ENDPOINT_IP} + Port: ${CONTROL_PLANE_ENDPOINT_PORT=6443} version: ${KUBERNETES_VERSION} workers: machineDeployments: diff --git a/templates/clusterclass/clusterclass.yaml b/templates/clusterclass/clusterclass.yaml index c256b50f18..a488ff352c 100644 --- a/templates/clusterclass/clusterclass.yaml +++ b/templates/clusterclass/clusterclass.yaml @@ -83,43 +83,67 @@ spec: namespace: ${NAMESPACE} patches: - definitions: - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/users - valueFrom: - template: | - - name: capxuser - lockPassword: false - sudo: ALL=(ALL) NOPASSWD:ALL - sshAuthorizedKeys: - - '{{ .sshKey }}' - selector: - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - kind: KubeadmControlPlaneTemplate - matchResources: - controlPlane: true - - jsonPatches: - - op: add - path: /spec/template/spec/users - valueFrom: - template: | - - name: capxuser - lockPassword: false - sudo: ALL=(ALL) NOPASSWD:ALL - sshAuthorizedKeys: - - '{{ .sshKey }}' - selector: - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - matchResources: - machineDeploymentClass: - names: - - ${CLUSTER_CLASS_NAME}-worker + - jsonPatches: + - op: add + path: /spec/template/spec/kubeadmConfigSpec/users + valueFrom: + template: | + - name: capxuser + lockPassword: false + sudo: ALL=(ALL) NOPASSWD:ALL + sshAuthorizedKeys: + - '{{ .sshKey }}' + selector: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlaneTemplate + matchResources: + controlPlane: true + - jsonPatches: + - op: add + path: /spec/template/spec/users + valueFrom: + template: | + - name: capxuser + lockPassword: false + sudo: ALL=(ALL) NOPASSWD:ALL + sshAuthorizedKeys: + - '{{ .sshKey }}' + selector: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + matchResources: + machineDeploymentClass: + names: + - ${CLUSTER_CLASS_NAME}-worker name: add-ssh-user + - definitions: + - jsonPatches: + - op: add + path: /spec/template/spec/controlPlaneEndpoint + valueFrom: + template: | + host: '{{ .controlPlaneEndpoint.IP }}' + port: {{ .controlPlaneEndpoint.Port }} + selector: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: NutanixClusterTemplate + matchResources: + infrastructureCluster: true + name: add-control-plane-endpoint variables: - name: sshKey - required: false + required: true schema: openAPIV3Schema: description: Public key to SSH onto the cluster nodes. - type: string \ No newline at end of file + type: string + - name: controlPlaneEndpoint + required: true + schema: + openAPIV3Schema: + properties: + IP: + type: string + Port: + type: integer + type: object \ No newline at end of file diff --git a/templates/clusterclass/nct.yaml b/templates/clusterclass/nct.yaml index a0c4a60ca5..f3f47bba8a 100644 --- a/templates/clusterclass/nct.yaml +++ b/templates/clusterclass/nct.yaml @@ -15,7 +15,4 @@ spec: kind: Secret additionalTrustBundle: name: ${CLUSTER_NAME}-pc-trusted-ca-bundle - kind: ConfigMap - controlPlaneEndpoint: - host: "${CONTROL_PLANE_ENDPOINT_IP}" - port: ${CONTROL_PLANE_ENDPOINT_PORT=6443} \ No newline at end of file + kind: ConfigMap \ No newline at end of file diff --git a/templates/topology/cluster-with-topology.yaml b/templates/topology/cluster-with-topology.yaml index 2d8fbc0a32..cfe2d83d6f 100644 --- a/templates/topology/cluster-with-topology.yaml +++ b/templates/topology/cluster-with-topology.yaml @@ -25,4 +25,8 @@ spec: metadata: {} variables: - name: sshKey - value: '${NUTANIX_SSH_AUTHORIZED_KEY}' \ No newline at end of file + value: '${NUTANIX_SSH_AUTHORIZED_KEY}' + - name: controlPlaneEndpoint + value: + IP: "${CONTROL_PLANE_ENDPOINT_IP}" + Port: ${CONTROL_PLANE_ENDPOINT_PORT=6443} \ No newline at end of file