From 7daeda0a16c2d9e597a03d21a26031ecf15b3e06 Mon Sep 17 00:00:00 2001 From: Prajyot Parab Date: Wed, 8 Jan 2025 20:35:37 +0530 Subject: [PATCH] remove deprecated v1 provider id format Signed-off-by: Prajyot Parab --- Makefile | 1 - cloud/scope/machine.go | 2 - cloud/scope/powervs_machine.go | 5 - cloud/scope/powervs_machine_test.go | 10 - main.go | 10 +- pkg/options/options.go | 7 - templates/cluster-template-powervs.yaml | 296 ------------------ templates/cluster-template-powervs/kcp.yaml | 16 - .../kubeadm-config.yaml | 11 - .../kustomization.yaml | 9 - 10 files changed, 3 insertions(+), 364 deletions(-) delete mode 100644 templates/cluster-template-powervs.yaml delete mode 100644 templates/cluster-template-powervs/kcp.yaml delete mode 100644 templates/cluster-template-powervs/kubeadm-config.yaml delete mode 100644 templates/cluster-template-powervs/kustomization.yaml diff --git a/Makefile b/Makefile index 0407fc6b3..2c0436b96 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,6 @@ generate-go-conversions: $(CONVERSION_GEN) ## Generate conversions go code .PHONY: generate-templates generate-templates: $(KUSTOMIZE) ## Generate cluster templates $(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template.yaml - $(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs.yaml $(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-cloud-provider.yaml $(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-powervs-clusterclass.yaml $(KUSTOMIZE) build $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass --load-restrictor LoadRestrictionsNone > $(TEMPLATES_DIR)/cluster-template-vpc-clusterclass.yaml diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index 30d28f18b..a9f3f2103 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -1083,8 +1083,6 @@ func (m *MachineScope) SetProviderID(id *string) error { return err } m.IBMVPCMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("ibm://%s///%s/%s", accountID, m.Machine.Spec.ClusterName, *id)) - } else { - m.IBMVPCMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("ibmvpc://%s/%s", m.Machine.Spec.ClusterName, m.IBMVPCMachine.Name)) } return nil } diff --git a/cloud/scope/powervs_machine.go b/cloud/scope/powervs_machine.go index 31aa88011..cea5c02e0 100644 --- a/cloud/scope/powervs_machine.go +++ b/cloud/scope/powervs_machine.go @@ -64,7 +64,6 @@ import ( "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/cloud/services/vpc" "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/endpoints" ignV2Types "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/ignition" - "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/options" "sigs.k8s.io/cluster-api-provider-ibmcloud/pkg/record" ) @@ -954,10 +953,6 @@ func (m *PowerVSMachineScope) GetServiceInstanceID() (string, error) { // SetProviderID will set the provider id for the machine. func (m *PowerVSMachineScope) SetProviderID(instanceID string) error { // Based on the ProviderIDFormat version the providerID format will be decided. - if options.ProviderIDFormatType(options.ProviderIDFormat) == options.ProviderIDFormatV1 { - m.IBMPowerVSMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("ibmpowervs://%s/%s", m.Machine.Spec.ClusterName, m.IBMPowerVSMachine.Name)) - return nil - } m.V(3).Info("setting provider id in v2 format") serviceInstanceID, err := m.GetServiceInstanceID() diff --git a/cloud/scope/powervs_machine_test.go b/cloud/scope/powervs_machine_test.go index 331f011b9..79fc8199a 100644 --- a/cloud/scope/powervs_machine_test.go +++ b/cloud/scope/powervs_machine_test.go @@ -912,16 +912,6 @@ func TestGetMachineInternalIP(t *testing.T) { func TestSetProviderID(t *testing.T) { providerID := "foo-provider-id" - t.Run("Set Provider ID in v1 format", func(t *testing.T) { - g := NewWithT(t) - scope := setupPowerVSMachineScope(clusterName, machineName, ptr.To(pvsImage), ptr.To(pvsNetwork), true, nil) - options.ProviderIDFormat = string(options.ProviderIDFormatV1) - err := scope.SetProviderID("foo-providerID") - expectedProviderID := ptr.To(fmt.Sprintf("ibmpowervs://%s/%s", scope.Machine.Spec.ClusterName, scope.IBMPowerVSMachine.Name)) - g.Expect(*scope.IBMPowerVSMachine.Spec.ProviderID).To(Equal(*expectedProviderID)) - g.Expect(err).To(BeNil()) - }) - t.Run("failed to get service instance ID", func(t *testing.T) { g := NewWithT(t) scope := PowerVSMachineScope{ diff --git a/main.go b/main.go index f8ab2e5ff..b9524c9bf 100644 --- a/main.go +++ b/main.go @@ -135,14 +135,10 @@ func initFlags(fs *pflag.FlagSet) { } func validateFlags() error { - switch options.ProviderIDFormatType(options.ProviderIDFormat) { - // Deprecated: ProviderIDFormatV1 is deprecated and will be removed in a future release. - case options.ProviderIDFormatV1: - setupLog.Info("Using v1 version of ProviderID format.V1 is deprecated and will be removed in a future release.Instead use V2.") - case options.ProviderIDFormatV2: + if options.ProviderIDFormatType(options.ProviderIDFormat) == options.ProviderIDFormatV2 { setupLog.Info("Using v2 version of ProviderID format") - default: - return fmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s, %s ", options.ProviderIDFormat, options.ProviderIDFormatV1, options.ProviderIDFormatV2) + } else { + return fmt.Errorf("invalid value for flag provider-id-fmt: %s, Supported values: %s ", options.ProviderIDFormat, options.ProviderIDFormatV2) } if err := logsv1.ValidateAndApply(logOptions, nil); err != nil { diff --git a/pkg/options/options.go b/pkg/options/options.go index 0630eae2e..19e37ae70 100644 --- a/pkg/options/options.go +++ b/pkg/options/options.go @@ -20,13 +20,6 @@ package options type ProviderIDFormatType string const ( - // ProviderIDFormatV1 will set provider id to machine as follows - // For VPC machines: ibmvpc:/// - // For Power VS machines: ibmpowervs:/// - // Deprecated: ProviderIDFormatV1 is deprecated and will be removed in a future release. see https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/issues/1868 for more details. - // use ProviderIDFormatV2 instead ProviderIDFormatV1. - ProviderIDFormatV1 ProviderIDFormatType = "v1" - // ProviderIDFormatV2 will set provider id to machine as follows // For VPC machines: ibm:////// // For Power VS machines: ibmpowervs:///// diff --git a/templates/cluster-template-powervs.yaml b/templates/cluster-template-powervs.yaml deleted file mode 100644 index dfd33b1a5..000000000 --- a/templates/cluster-template-powervs.yaml +++ /dev/null @@ -1,296 +0,0 @@ -apiVersion: cluster.x-k8s.io/v1beta1 -kind: Cluster -metadata: - labels: - cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} - name: ${CLUSTER_NAME} -spec: - clusterNetwork: - pods: - cidrBlocks: - - ${POD_CIDR:="192.168.0.0/16"} - serviceDomain: ${SERVICE_DOMAIN:="cluster.local"} - services: - cidrBlocks: - - ${SERVICE_CIDR:="10.128.0.0/12"} - controlPlaneRef: - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - kind: KubeadmControlPlane - name: ${CLUSTER_NAME}-control-plane - infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 - kind: IBMPowerVSCluster - name: ${CLUSTER_NAME} ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 -kind: IBMPowerVSCluster -metadata: - labels: - cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} - name: ${CLUSTER_NAME} -spec: - controlPlaneEndpoint: - host: ${IBMPOWERVS_VIP_EXTERNAL} - port: ${API_SERVER_PORT:=6443} - network: - name: ${IBMPOWERVS_NETWORK_NAME} - serviceInstanceID: ${IBMPOWERVS_SERVICE_INSTANCE_ID} ---- -apiVersion: controlplane.cluster.x-k8s.io/v1beta1 -kind: KubeadmControlPlane -metadata: - name: ${CLUSTER_NAME}-control-plane -spec: - kubeadmConfigSpec: - clusterConfiguration: - apiServer: - certSANs: - - ${IBMPOWERVS_VIP} - - ${IBMPOWERVS_VIP_EXTERNAL} - controlPlaneEndpoint: ${IBMPOWERVS_VIP}:${API_SERVER_PORT:=6443} - controllerManager: - extraArgs: - enable-hostpath-provisioner: "true" - files: - - content: | - apiVersion: v1 - kind: Pod - metadata: - creationTimestamp: null - name: kube-vip - namespace: kube-system - spec: - containers: - - args: - - manager - env: - - name: vip_arp - value: "true" - - name: port - value: "${API_SERVER_PORT:=6443}" - - name: vip_interface - value: env2 - - name: vip_cidr - value: "${IBMPOWERVS_VIP_CIDR}" - - name: cp_enable - value: "true" - - name: cp_namespace - value: kube-system - - name: vip_ddns - value: "false" - - name: svc_enable - value: "true" - - name: vip_leaderelection - value: "true" - - name: vip_leaseduration - value: "5" - - name: vip_renewdeadline - value: "3" - - name: vip_retryperiod - value: "1" - - name: address - value: "${IBMPOWERVS_VIP}" - image: ghcr.io/kube-vip/kube-vip:v0.8.0 - imagePullPolicy: Always - name: kube-vip - resources: {} - securityContext: - capabilities: - add: - - NET_ADMIN - - NET_RAW - volumeMounts: - - mountPath: /etc/kubernetes/admin.conf - name: kubeconfig - - mountPath: /etc/hosts - name: etchosts - hostNetwork: true - volumes: - - hostPath: - path: /etc/kubernetes/admin.conf - name: kubeconfig - - hostPath: - path: /etc/kube-vip.hosts - type: File - name: etchosts - status: {} - owner: root:root - path: /etc/kubernetes/manifests/kube-vip.yaml - permissions: "0744" - - content: 127.0.0.1 localhost kubernetes - owner: root:root - path: /etc/kube-vip.hosts - permissions: "0644" - - content: | - #!/bin/bash - - # Copyright 2020 The Kubernetes Authors. - # - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - - set -e - - # Configure the workaround required for kubeadm init with kube-vip: - # xref: https://github.com/kube-vip/kube-vip/issues/684 - - # Nothing to do for kubernetes < v1.29 - KUBEADM_MINOR="$(kubeadm version -o short | cut -d '.' -f 2)" - if [[ "$KUBEADM_MINOR" -lt "29" ]]; then - exit 0 - fi - - IS_KUBEADM_INIT="false" - - # cloud-init kubeadm init - if [[ -f /run/kubeadm/kubeadm.yaml ]]; then - IS_KUBEADM_INIT="true" - fi - - # ignition kubeadm init - if [[ -f /etc/kubeadm.sh ]] && grep -q -e "kubeadm init" /etc/kubeadm.sh; then - IS_KUBEADM_INIT="true" - fi - - if [[ "$IS_KUBEADM_INIT" == "true" ]]; then - sed -i 's#path: /etc/kubernetes/admin.conf#path: /etc/kubernetes/super-admin.conf#' \ - /etc/kubernetes/manifests/kube-vip.yaml - fi - owner: root:root - path: /etc/pre-kubeadm-commands/50-kube-vip-prepare.sh - permissions: "0700" - initConfiguration: - nodeRegistration: - criSocket: /var/run/containerd/containerd.sock - kubeletExtraArgs: - cloud-provider: external - eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - name: '{{ v1.local_hostname }}' - joinConfiguration: - discovery: - bootstrapToken: - apiServerEndpoint: ${IBMPOWERVS_VIP}:${API_SERVER_PORT:=6443} - caCertHashes: [] - token: "" - unsafeSkipCAVerification: false - nodeRegistration: - criSocket: /var/run/containerd/containerd.sock - kubeletExtraArgs: - cloud-provider: external - eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - name: '{{ v1.local_hostname }}' - preKubeadmCommands: - - hostname "{{ v1.local_hostname }}" - - echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts - - echo "127.0.0.1 localhost" >>/etc/hosts - - echo "127.0.0.1 {{ v1.local_hostname }}" >>/etc/hosts - - echo "{{ v1.local_hostname }}" >/etc/hostname - - mkdir -p /etc/pre-kubeadm-commands - - for script in $(find /etc/pre-kubeadm-commands/ -name '*.sh' -type f | sort); - do echo "Running script $script"; "$script"; done - useExperimentalRetryJoin: true - machineTemplate: - infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 - kind: IBMPowerVSMachineTemplate - name: ${CLUSTER_NAME}-control-plane - replicas: ${CONTROL_PLANE_MACHINE_COUNT} - version: ${KUBERNETES_VERSION} ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 -kind: IBMPowerVSMachineTemplate -metadata: - name: ${CLUSTER_NAME}-control-plane -spec: - template: - spec: - image: - name: ${IBMPOWERVS_IMAGE_NAME} - memoryGiB: ${IBMPOWERVS_CONTROL_PLANE_MEMORY:=4} - network: - name: ${IBMPOWERVS_NETWORK_NAME} - processorType: ${IBMPOWERVS_CONTROL_PLANE_PROCTYPE:="Shared"} - processors: ${IBMPOWERVS_CONTROL_PLANE_PROCESSORS:="0.25"} - serviceInstanceID: ${IBMPOWERVS_SERVICE_INSTANCE_ID} - sshKey: ${IBMPOWERVS_SSHKEY_NAME} - systemType: ${IBMPOWERVS_CONTROL_PLANE_SYSTYPE:="s922"} ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineDeployment -metadata: - name: ${CLUSTER_NAME}-md-0 -spec: - clusterName: ${CLUSTER_NAME} - replicas: ${WORKER_MACHINE_COUNT} - template: - spec: - bootstrap: - configRef: - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - name: ${CLUSTER_NAME}-md-0 - clusterName: ${CLUSTER_NAME} - infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 - kind: IBMPowerVSMachineTemplate - name: ${CLUSTER_NAME}-md-0 - version: ${KUBERNETES_VERSION} ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 -kind: IBMPowerVSMachineTemplate -metadata: - name: ${CLUSTER_NAME}-md-0 -spec: - template: - spec: - image: - name: ${IBMPOWERVS_IMAGE_NAME} - memoryGiB: ${IBMPOWERVS_COMPUTE_MEMORY:=4} - network: - name: ${IBMPOWERVS_NETWORK_NAME} - processorType: ${IBMPOWERVS_COMPUTE_PROCTYPE:="Shared"} - processors: ${IBMPOWERVS_COMPUTE_PROCESSORS:="0.25"} - serviceInstanceID: ${IBMPOWERVS_SERVICE_INSTANCE_ID} - sshKey: ${IBMPOWERVS_SSHKEY_NAME} - systemType: ${IBMPOWERVS_COMPUTE_SYSTYPE:="s922"} ---- -apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -kind: KubeadmConfigTemplate -metadata: - labels: - cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} - name: ${CLUSTER_NAME}-md-0 -spec: - template: - spec: - joinConfiguration: - discovery: - bootstrapToken: - apiServerEndpoint: ${IBMPOWERVS_VIP}:${API_SERVER_PORT:=6443} - caCertHashes: [] - token: "" - unsafeSkipCAVerification: false - nodeRegistration: - criSocket: /var/run/containerd/containerd.sock - kubeletExtraArgs: - cloud-provider: external - eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - name: '{{ v1.local_hostname }}' - preKubeadmCommands: - - hostname "{{ v1.local_hostname }}" - - echo "::1 ipv6-localhost ipv6-loopback" >/etc/hosts - - echo "127.0.0.1 localhost" >>/etc/hosts - - echo "127.0.0.1 {{ v1.local_hostname }}" >>/etc/hosts - - echo "{{ v1.local_hostname }}" >/etc/hostname diff --git a/templates/cluster-template-powervs/kcp.yaml b/templates/cluster-template-powervs/kcp.yaml deleted file mode 100644 index d5200d353..000000000 --- a/templates/cluster-template-powervs/kcp.yaml +++ /dev/null @@ -1,16 +0,0 @@ -kind: KubeadmControlPlane -apiVersion: controlplane.cluster.x-k8s.io/v1beta1 -metadata: - name: "${CLUSTER_NAME}-control-plane" -spec: - kubeadmConfigSpec: - initConfiguration: - nodeRegistration: - kubeletExtraArgs: - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - name: '{{ v1.local_hostname }}' - joinConfiguration: - nodeRegistration: - kubeletExtraArgs: - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - diff --git a/templates/cluster-template-powervs/kubeadm-config.yaml b/templates/cluster-template-powervs/kubeadm-config.yaml deleted file mode 100644 index d690de6c2..000000000 --- a/templates/cluster-template-powervs/kubeadm-config.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -kind: KubeadmConfigTemplate -metadata: - name: "${CLUSTER_NAME}-md-0" -spec: - template: - spec: - joinConfiguration: - nodeRegistration: - kubeletExtraArgs: - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' diff --git a/templates/cluster-template-powervs/kustomization.yaml b/templates/cluster-template-powervs/kustomization.yaml deleted file mode 100644 index 158a96dac..000000000 --- a/templates/cluster-template-powervs/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ -resources: -- ../bases/powervs - -patches: -- path: kcp.yaml -- path: kubeadm-config.yaml - -sortOptions: - order: fifo