diff --git a/Makefile b/Makefile index b889c0f3c..40bd9db1f 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ TOOLS_DIR := hack/tools TOOLS_BIN_DIR := $(TOOLS_DIR)/bin GO_INSTALL = ./scripts/go_install.sh E2E_CONF_FILE_ENVSUBST := $(REPO_ROOT)/test/e2e/config/ibmcloud-e2e-envsubst.yaml +E2E_TEMPLATES := $(REPO_ROOT)/test/e2e/data/templates GO_APIDIFF := $(TOOLS_BIN_DIR)/go-apidiff GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint @@ -156,6 +157,10 @@ generate-go-conversions-core: $(CONVERSION_GEN) --output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \ --go-header-file=./hack/boilerplate/boilerplate.generatego.txt +.PHONY: generate-e2e-templates +generate-e2e-templates: $(KUSTOMIZE) + $(KUSTOMIZE) build $(E2E_TEMPLATES)/cluster-template-md-remediation --load-restrictor LoadRestrictionsNone > $(E2E_TEMPLATES)/cluster-template-md-remediation.yaml + .PHONY: modules modules: ## Runs go mod to ensure modules are up to date go mod tidy @@ -203,7 +208,7 @@ SKIP_CREATE_MGMT_CLUSTER ?= false # Run the end-to-end tests .PHONY: test-e2e -test-e2e: $(GINKGO) $(KUSTOMIZE) $(ENVSUBST) set-flavor e2e-image ## Run e2e tests +test-e2e: $(GINKGO) $(KUSTOMIZE) $(ENVSUBST) set-flavor e2e-image generate-e2e-templates ## Run e2e tests $(ENVSUBST) < $(E2E_CONF_FILE) > $(E2E_CONF_FILE_ENVSUBST) $(GINKGO) $(GINKGO_ARGS) ./test/e2e -- \ -e2e.artifacts-folder="$(ARTIFACTS)" \ diff --git a/test/e2e/config/ibmcloud-e2e-powervs.yaml b/test/e2e/config/ibmcloud-e2e-powervs.yaml index 7fd983293..870c0d54b 100644 --- a/test/e2e/config/ibmcloud-e2e-powervs.yaml +++ b/test/e2e/config/ibmcloud-e2e-powervs.yaml @@ -38,8 +38,6 @@ providers: files: - sourcePath: "${PWD}/metadata.yaml" targetName: "metadata.yaml" - - sourcePath: "${PWD}/templates/cluster-template-powervs.yaml" - targetName: "cluster-template-powervs.yaml" - sourcePath: "${PWD}/test/e2e/data/templates/cluster-template-md-remediation.yaml" targetName: "cluster-template-md-remediation.yaml" diff --git a/test/e2e/data/templates/cluster-template-md-remediation.yaml b/test/e2e/data/templates/cluster-template-md-remediation.yaml deleted file mode 100644 index 6fa09a951..000000000 --- a/test/e2e/data/templates/cluster-template-md-remediation.yaml +++ /dev/null @@ -1,261 +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"} - infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: IBMPowerVSCluster - name: "${CLUSTER_NAME}" - controlPlaneRef: - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - kind: KubeadmControlPlane - name: "${CLUSTER_NAME}-control-plane" ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: IBMPowerVSCluster -metadata: - labels: - cluster.x-k8s.io/cluster-name: "${CLUSTER_NAME}" - name: "${CLUSTER_NAME}" -spec: - serviceInstanceID: "${IBMPOWERVS_SERVICE_INSTANCE_ID}" - network: - name: "${IBMPOWERVS_NETWORK_NAME}" - controlPlaneEndpoint: - host: "${IBMPOWERVS_VIP_EXTERNAL}" - port: 6443 ---- -kind: KubeadmControlPlane -apiVersion: controlplane.cluster.x-k8s.io/v1beta1 -metadata: - name: "${CLUSTER_NAME}-control-plane" -spec: - version: "${KUBERNETES_VERSION}" - replicas: ${CONTROL_PLANE_MACHINE_COUNT} - machineTemplate: - infrastructureRef: - kind: IBMPowerVSMachineTemplate - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - name: "${CLUSTER_NAME}-control-plane" - kubeadmConfigSpec: - clusterConfiguration: - apiServer: - certSANs: - - "${IBMPOWERVS_VIP}" - - "${IBMPOWERVS_VIP_EXTERNAL}" - controlPlaneEndpoint: ${IBMPOWERVS_VIP}:6443 - controllerManager: - extraArgs: - enable-hostpath-provisioner: "true" - initConfiguration: - nodeRegistration: - criSocket: /var/run/containerd/containerd.sock - kubeletExtraArgs: - cloud-provider: external - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% - name: '{{ v1.local_hostname }}' - joinConfiguration: - discovery: - bootstrapToken: - apiServerEndpoint: ${IBMPOWERVS_VIP}:6443 - token: "" - caCertHashes: [ ] - unsafeSkipCAVerification: false - nodeRegistration: - criSocket: /var/run/containerd/containerd.sock - kubeletExtraArgs: - cloud-provider: external - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% - name: '{{ v1.local_hostname }}' - useExperimentalRetryJoin: true - 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 - files: - - path: /etc/kubernetes/manifests/kube-vip.yaml - 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: "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.4.4 - imagePullPolicy: Always - name: kube-vip - resources: {} - securityContext: - capabilities: - add: - - NET_ADMIN - - NET_RAW - volumeMounts: - - mountPath: /etc/kubernetes/admin.conf - name: kubeconfig - hostAliases: - - hostnames: - - kubernetes - ip: 127.0.0.1 - hostNetwork: true - volumes: - - hostPath: - path: /etc/kubernetes/admin.conf - name: kubeconfig - status: {} - owner: "root:root" - permissions: "0744" ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: IBMPowerVSMachineTemplate -metadata: - name: "${CLUSTER_NAME}-control-plane" -spec: - template: - spec: - serviceInstanceID: "${IBMPOWERVS_SERVICE_INSTANCE_ID}" - sshKey: "${IBMPOWERVS_SSHKEY_NAME}" - image: - name: "${IBMPOWERVS_IMAGE_NAME}" - network: - name: "${IBMPOWERVS_NETWORK_NAME}" - memory: ${IBMPOWERVS_CONTROL_PLANE_MEMORY:="4"} - processors: ${IBMPOWERVS_CONTROL_PLANE_PROCESSORS:="0.25"} - sysType: ${IBMPOWERVS_CONTROL_PLANE_SYSTYPE:="s922"} - procType: ${IBMPOWERVS_CONTROL_PLANE_PROCTYPE:="shared"} ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineDeployment -metadata: - name: "${CLUSTER_NAME}-md-0" -spec: - clusterName: "${CLUSTER_NAME}" - replicas: ${WORKER_MACHINE_COUNT} - selector: {} - template: - metadata: - labels: - e2e.remediation.label: "" - spec: - clusterName: "${CLUSTER_NAME}" - version: "${KUBERNETES_VERSION}" - bootstrap: - configRef: - name: "${CLUSTER_NAME}-md-0" - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - infrastructureRef: - name: "${CLUSTER_NAME}-md-0" - apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 - kind: IBMPowerVSMachineTemplate ---- -apiVersion: cluster.x-k8s.io/v1beta1 -kind: MachineHealthCheck -metadata: - name: "${CLUSTER_NAME}-mhc-0" -spec: - clusterName: "${CLUSTER_NAME}" - maxUnhealthy: 100% - nodeStartupTimeout: 20m - selector: - matchLabels: - e2e.remediation.label: "" - unhealthyConditions: - - type: Ready - status: "False" - timeout: 30s ---- -apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 -kind: IBMPowerVSMachineTemplate -metadata: - name: "${CLUSTER_NAME}-md-0" -spec: - template: - spec: - serviceInstanceID: "${IBMPOWERVS_SERVICE_INSTANCE_ID}" - sshKey: "${IBMPOWERVS_SSHKEY_NAME}" - image: - name: "${IBMPOWERVS_IMAGE_NAME}" - network: - name: "${IBMPOWERVS_NETWORK_NAME}" - memory: ${IBMPOWERVS_COMPUTE_MEMORY:="4"} - processors: ${IBMPOWERVS_COMPUTE_PROCESSORS:="0.25"} - sysType: ${IBMPOWERVS_COMPUTE_SYSTYPE:="s922"} - procType: ${IBMPOWERVS_COMPUTE_PROCTYPE:="shared"} ---- -apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 -kind: KubeadmConfigTemplate -metadata: - labels: - cluster.x-k8s.io/cluster-name: ${CLUSTER_NAME} - cluster.x-k8s.io/control-plane: "" - name: "${CLUSTER_NAME}-md-0" -spec: - template: - spec: - joinConfiguration: - discovery: - bootstrapToken: - apiServerEndpoint: ${IBMPOWERVS_VIP}:6443 - token: "" - caCertHashes: [] - unsafeSkipCAVerification: false - nodeRegistration: - criSocket: /var/run/containerd/containerd.sock - kubeletExtraArgs: - cloud-provider: external - provider-id: ibmpowervs://${CLUSTER_NAME}/'{{ v1.local_hostname }}' - eviction-hard: nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0% - 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/test/e2e/data/templates/cluster-template-md-remediation/kustomization.yaml b/test/e2e/data/templates/cluster-template-md-remediation/kustomization.yaml new file mode 100644 index 000000000..b15554984 --- /dev/null +++ b/test/e2e/data/templates/cluster-template-md-remediation/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../../../templates/cluster-template-powervs.yaml + - mhc-powervs.yaml diff --git a/test/e2e/data/templates/cluster-template-md-remediation/mhc-powervs.yaml b/test/e2e/data/templates/cluster-template-md-remediation/mhc-powervs.yaml new file mode 100644 index 000000000..0cc297d7f --- /dev/null +++ b/test/e2e/data/templates/cluster-template-md-remediation/mhc-powervs.yaml @@ -0,0 +1,15 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineHealthCheck +metadata: + name: "${CLUSTER_NAME}-mhc-0" +spec: + clusterName: "${CLUSTER_NAME}" + maxUnhealthy: 100% + nodeStartupTimeout: 20m + selector: + matchLabels: + e2e.remediation.label: "" + unhealthyConditions: + - type: Ready + status: "False" + timeout: 30s