From 9876381f2ec22ac7c7dca76b51056085fd2fbb1f Mon Sep 17 00:00:00 2001 From: Danil Grigorev Date: Fri, 11 Aug 2023 23:21:59 +0200 Subject: [PATCH] Add generate workflow for full-chart-install test --- Makefile | 6 ++- test/e2e/helm_test.go | 18 +++---- test/e2e/resources/full-chart-install.yaml | 60 +++++++++++----------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index ac8e6dcc8..f471cfc16 100644 --- a/Makefile +++ b/Makefile @@ -124,6 +124,7 @@ PROD_REGISTRY ?= registry.k8s.io/capi-operator # Image name IMAGE_NAME ?= cluster-api-operator +PACKAGE_NAME = cluster-api-operator CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) CONTROLLER_IMG_TAG ?= $(CONTROLLER_IMG)-$(ARCH):$(TAG) @@ -291,9 +292,10 @@ verify-gen: generate ## -------------------------------------- .PHONY: generate -generate: $(CONTROLLER_GEN) ## Generate code +generate: $(CONTROLLER_GEN) $(HELM) release-chart ## Generate code $(MAKE) generate-manifests $(MAKE) generate-go + $(HELM) template capi-operator $(CHART_PACKAGE_DIR)/$(PACKAGE_NAME)-$(HELM_CHART_TAG).tgz > test/e2e/resources/full-chart-install.yaml .PHONY: generate-go generate-go: $(CONTROLLER_GEN) ## Runs Go related generate targets for the operator @@ -434,7 +436,7 @@ chart-manifest-modification: # Set the manifest images to the staging/production .PHONY: release-manifests release-manifests: $(KUSTOMIZE) $(RELEASE_DIR) ## Builds the manifests to publish with a release $(KUSTOMIZE) build ./config/default > $(RELEASE_DIR)/operator-components.yaml - + .PHONY: release-chart release-chart: $(HELM) $(KUSTOMIZE) $(RELEASE_DIR) $(CHART_DIR) $(CHART_PACKAGE_DIR) ## Builds the chart to publish with a release cp -rf $(ROOT)/hack/charts/cluster-api-operator/. $(CHART_DIR) diff --git a/test/e2e/helm_test.go b/test/e2e/helm_test.go index 8c59dcf62..49c409676 100644 --- a/test/e2e/helm_test.go +++ b/test/e2e/helm_test.go @@ -20,23 +20,23 @@ limitations under the License. package e2e import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" "os" "path/filepath" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" . "sigs.k8s.io/cluster-api-operator/test/framework" ) var _ = Describe("Create a proper set of manifests when using helm charts", func() { It("should deploy default manifest set for quick-start process", func() { fullInstallChart := &HelmChart{ - BinaryPath: helmChart.BinaryPath, - Path: helmChart.Path, - Name: helmChart.Name, - Kubeconfig: helmChart.Kubeconfig, - DryRun: helmChart.DryRun, - Output: Manifests, - AdditionalFlags: []string{"-n=capi-operator-system", "--create-namespace"}, + BinaryPath: helmChart.BinaryPath, + Path: helmChart.Path, + Name: helmChart.Name, + Kubeconfig: helmChart.Kubeconfig, + DryRun: helmChart.DryRun, + Output: Manifests, } fullInstallChart.Output = Manifests manifests, err := fullInstallChart.InstallChart(nil) diff --git a/test/e2e/resources/full-chart-install.yaml b/test/e2e/resources/full-chart-install.yaml index c28343949..cda9e7000 100644 --- a/test/e2e/resources/full-chart-install.yaml +++ b/test/e2e/resources/full-chart-install.yaml @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: 'capi-operator-system/capi-operator-serving-cert' + cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.11.4 labels: clusterctl.cluster.x-k8s.io/core: capi-operator @@ -17,7 +17,7 @@ spec: caBundle: Cg== service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /convert conversionReviewVersions: - v1 @@ -1565,7 +1565,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: 'capi-operator-system/capi-operator-serving-cert' + cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.11.4 labels: clusterctl.cluster.x-k8s.io/core: capi-operator @@ -1578,7 +1578,7 @@ spec: caBundle: Cg== service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /convert conversionReviewVersions: - v1 @@ -3128,7 +3128,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: 'capi-operator-system/capi-operator-serving-cert' + cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.11.4 labels: clusterctl.cluster.x-k8s.io/core: capi-operator @@ -3141,7 +3141,7 @@ spec: caBundle: Cg== service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /convert conversionReviewVersions: - v1 @@ -4689,7 +4689,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: 'capi-operator-system/capi-operator-serving-cert' + cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.11.4 labels: clusterctl.cluster.x-k8s.io/core: capi-operator @@ -4702,7 +4702,7 @@ spec: caBundle: Cg== service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /convert conversionReviewVersions: - v1 @@ -6311,7 +6311,7 @@ roleRef: subjects: - kind: ServiceAccount name: default - namespace: 'capi-operator-system' + namespace: 'default' --- # Source: cluster-api-operator/templates/operator-components.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -6327,7 +6327,7 @@ roleRef: subjects: - kind: ServiceAccount name: default - namespace: 'capi-operator-system' + namespace: 'default' --- # Source: cluster-api-operator/templates/operator-components.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -6336,7 +6336,7 @@ metadata: labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-leader-election-role - namespace: 'capi-operator-system' + namespace: 'default' rules: - apiGroups: - "" @@ -6384,7 +6384,7 @@ metadata: labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-leader-election-rolebinding - namespace: 'capi-operator-system' + namespace: 'default' roleRef: apiGroup: rbac.authorization.k8s.io kind: Role @@ -6392,7 +6392,7 @@ roleRef: subjects: - kind: ServiceAccount name: default - namespace: 'capi-operator-system' + namespace: 'default' --- # Source: cluster-api-operator/templates/operator-components.yaml apiVersion: v1 @@ -6402,7 +6402,7 @@ metadata: clusterctl.cluster.x-k8s.io/core: capi-operator control-plane: controller-manager name: capi-operator-controller-manager-metrics-service - namespace: 'capi-operator-system' + namespace: 'default' spec: ports: - name: https @@ -6419,7 +6419,7 @@ metadata: labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' spec: ports: - port: 443 @@ -6433,7 +6433,7 @@ apiVersion: apps/v1 kind: Deployment metadata: name: capi-operator-cluster-api-operator - namespace: 'capi-operator-system' + namespace: 'default' labels: app: cluster-api-operator app.kubernetes.io/name: cluster-api-operator @@ -6555,11 +6555,11 @@ metadata: labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-serving-cert - namespace: 'capi-operator-system' + namespace: 'default' spec: dnsNames: - - capi-operator-webhook-service.capi-operator-system.svc - - capi-operator-webhook-service.capi-operator-system.svc.cluster.local + - capi-operator-webhook-service.default.svc + - capi-operator-webhook-service.default.svc.cluster.local issuerRef: kind: Issuer name: capi-operator-selfsigned-issuer @@ -6572,7 +6572,7 @@ metadata: labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-selfsigned-issuer - namespace: 'capi-operator-system' + namespace: 'default' spec: selfSigned: {} --- @@ -6581,7 +6581,7 @@ apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: annotations: - cert-manager.io/inject-ca-from: 'capi-operator-system/capi-operator-serving-cert' + cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-mutating-webhook-configuration @@ -6592,7 +6592,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /mutate-operator-cluster-x-k8s-io-v1alpha1-bootstrapprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6614,7 +6614,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /mutate-operator-cluster-x-k8s-io-v1alpha1-controlplaneprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6636,7 +6636,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /mutate-operator-cluster-x-k8s-io-v1alpha1-coreprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6658,7 +6658,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /mutate-operator-cluster-x-k8s-io-v1alpha1-infrastructureprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6680,7 +6680,7 @@ apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: annotations: - cert-manager.io/inject-ca-from: 'capi-operator-system/capi-operator-serving-cert' + cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: capi-operator-validating-webhook-configuration @@ -6691,7 +6691,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /validate-operator-cluster-x-k8s-io-v1alpha1-bootstrapprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6713,7 +6713,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /validate-operator-cluster-x-k8s-io-v1alpha1-controlplaneprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6735,7 +6735,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /validate-operator-cluster-x-k8s-io-v1alpha1-coreprovider failurePolicy: Fail matchPolicy: Equivalent @@ -6757,7 +6757,7 @@ webhooks: clientConfig: service: name: capi-operator-webhook-service - namespace: 'capi-operator-system' + namespace: 'default' path: /validate-operator-cluster-x-k8s-io-v1alpha1-infrastructureprovider failurePolicy: Fail matchPolicy: Equivalent