From b9086237296a3dc648b33ec49200e7db34859dad Mon Sep 17 00:00:00 2001 From: Abhinandan Purkait Date: Tue, 30 Jul 2024 11:34:04 +0000 Subject: [PATCH] chore: generate zfs-operator by disabling helm labels Signed-off-by: Abhinandan Purkait --- .github/workflows/build_and_push.yml | 33 +------------ .github/workflows/release.yml | 33 +------------ buildscripts/check-diff.sh | 2 +- buildscripts/generate-manifests.sh | 6 ++- deploy/helm/charts/templates/_helpers.tpl | 7 ++- .../helm/charts/templates/zfs-controller.yaml | 2 +- deploy/helm/charts/values.yaml | 4 ++ deploy/zfs-operator.yaml | 49 ------------------- 8 files changed, 19 insertions(+), 117 deletions(-) diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index 0c63f1dca..d89303e0f 100644 --- a/.github/workflows/build_and_push.yml +++ b/.github/workflows/build_and_push.yml @@ -35,40 +35,9 @@ jobs: run: | ct lint --config ct.yaml - validate_codegen: - runs-on: ubuntu-latest - env: - GOPATH: ${{ github.workspace }}/go - GOBIN: ${{ github.workspace }}/go/bin - defaults: - run: - working-directory: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - path: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv - - - name: Set up Go 1.19 - uses: actions/setup-go@v4 - with: - go-version: 1.19.9 - cache: false - - - name: Helm tool installer - uses: Azure/setup-helm@v4.2.0 - - - name: Verify kubegen - run: | - make verify-kubegen - - - name: Verify manifests - run: | - make verify-manifests - unit-tests: runs-on: ubuntu-latest - needs: ["lint", "validate_codegen"] + needs: ["lint"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd2030fb7..03c3baef9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,40 +28,9 @@ jobs: run: | ct lint --config ct.yaml - validate_codegen: - runs-on: ubuntu-latest - env: - GOPATH: ${{ github.workspace }}/go - GOBIN: ${{ github.workspace }}/go/bin - defaults: - run: - working-directory: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - path: ${{ env.GOPATH }}/src/github.com/openebs/zfs-localpv - - - name: Set up Go 1.19 - uses: actions/setup-go@v4 - with: - go-version: 1.19.9 - cache: false - - - name: Helm tool installer - uses: Azure/setup-helm@v4.2.0 - - - name: Verify kubegen - run: | - make verify-kubegen - - - name: Verify manifests - run: | - make verify-manifests - unit-tests: runs-on: ubuntu-latest - needs: ["lint", "validate_codegen"] + needs: ["lint"] steps: - name: Checkout uses: actions/checkout@v4 diff --git a/buildscripts/check-diff.sh b/buildscripts/check-diff.sh index 34c182bed..7119f8e2a 100755 --- a/buildscripts/check-diff.sh +++ b/buildscripts/check-diff.sh @@ -2,4 +2,4 @@ set -e -git --no-pager diff --exit-code pkg/generated pkg/apis/ deploy/yamls +git --no-pager diff --exit-code pkg/generated pkg/apis deploy/yamls diff --git a/buildscripts/generate-manifests.sh b/buildscripts/generate-manifests.sh index 3067952eb..0d3c2f28e 100755 --- a/buildscripts/generate-manifests.sh +++ b/buildscripts/generate-manifests.sh @@ -37,4 +37,8 @@ for FILE in "$DEPLOY_YAML_DIR"/zfs.openebs.io_*; do done # Generate the zfs-operator.yaml using the helm chart. -helm template "$RELEASE_NAME" "$HELM_CHART_DIR" -n "$RELEASE_NAMESPACE" --set analytics.installerType="zfs-operator" > "$DEPLOY_YAML_DIR"/../zfs-operator.yaml +helm template "$RELEASE_NAME" "$HELM_CHART_DIR" -n "$RELEASE_NAMESPACE" \ + --set analytics.installerType="zfs-operator" \ + --set crds.zfsLocalPv.keep=false \ + --set crds.csi.volumeSnapshots.keep=false \ + --set enableHelmMetaLabels=false > "$DEPLOY_YAML_DIR"/../zfs-operator.yaml diff --git a/deploy/helm/charts/templates/_helpers.tpl b/deploy/helm/charts/templates/_helpers.tpl index 95b4443c4..c24401a9c 100644 --- a/deploy/helm/charts/templates/_helpers.tpl +++ b/deploy/helm/charts/templates/_helpers.tpl @@ -58,8 +58,10 @@ Create the name of the service account to use Define meta labels for openebs zfs-localpv components */}} {{- define "zfslocalpv.common.metaLabels" -}} +{{- if or (not (hasKey .Values "enableHelmMetaLabels")) .Values.enableHelmMetaLabels -}} chart: {{ template "zfslocalpv.chart" . }} heritage: {{ .Release.Service }} +{{ end -}} openebs.io/version: {{ .Chart.AppVersion | quote }} role: {{ .Values.role | quote }} {{- end -}} @@ -69,7 +71,9 @@ Create match labels for openebs zfs-localpv controller */}} {{- define "zfslocalpv.zfsController.matchLabels" -}} app: {{ .Values.zfsController.componentName | quote }} +{{ if or (not (hasKey .Values "enableHelmMetaLabels")) .Values.enableHelmMetaLabels -}} release: {{ .Release.Name }} +{{ end -}} component: {{ .Values.zfsController.componentName | quote }} {{- end -}} @@ -94,9 +98,10 @@ Create labels for openebs zfs-localpv controller Create match labels for openebs zfs-localpv node daemon */}} {{- define "zfslocalpv.zfsNode.matchLabels" -}} -name: {{ .Values.zfsNode.componentName | quote }} +name: {{ .Values.zfsNode.componentName | quote }}{{ if or (not (hasKey .Values "enableHelmMetaLabels")) .Values.enableHelmMetaLabels }} release: {{ .Release.Name }} {{- end -}} +{{- end -}} {{/* Create component labels openebs zfs-localpv node daemon diff --git a/deploy/helm/charts/templates/zfs-controller.yaml b/deploy/helm/charts/templates/zfs-controller.yaml index 6b466ef4e..2654937ff 100644 --- a/deploy/helm/charts/templates/zfs-controller.yaml +++ b/deploy/helm/charts/templates/zfs-controller.yaml @@ -118,7 +118,7 @@ spec: fieldRef: fieldPath: metadata.namespace - name: OPENEBS_IO_INSTALLER_TYPE - value: "{{ .Values.analytics.installerType }}" + value: "{{ if (not (hasKey .Values.analytics "installerType")) }}zfs-localpv-helm{{ else }}{{ .Values.analytics.installerType }}{{ end }}" - name: OPENEBS_IO_ENABLE_ANALYTICS value: "{{ .Values.analytics.enabled }}" args : diff --git a/deploy/helm/charts/values.yaml b/deploy/helm/charts/values.yaml index 9a93f5a09..94bd75513 100644 --- a/deploy/helm/charts/values.yaml +++ b/deploy/helm/charts/values.yaml @@ -177,3 +177,7 @@ crds: volumeSnapshots: # Install Volume Snapshot CRDs enabled: true + +# Allows adding helm specific labels to the components. +# Only useful for generating independent templates from helm. +enableHelmMetaLabels: true diff --git a/deploy/zfs-operator.yaml b/deploy/zfs-operator.yaml index 60c22b2c3..c95a650b6 100644 --- a/deploy/zfs-operator.yaml +++ b/deploy/zfs-operator.yaml @@ -24,12 +24,9 @@ metadata: name: openebs-zfs-controller-sa namespace: kube-system labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller" --- @@ -40,12 +37,9 @@ metadata: name: openebs-zfs-node-sa namespace: kube-system labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" name: "openebs-zfs-node" - release: openebs openebs.io/component-name: "openebs-zfs-node" --- # Source: zfs-localpv/templates/configmap.yaml @@ -55,12 +49,9 @@ metadata: name: openebs-zfspv-bin namespace: kube-system # should be the same namespace where it is getting mounted labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" name: "openebs-zfs-node" - release: openebs openebs.io/component-name: "openebs-zfs-node" data: zfs: | @@ -80,7 +71,6 @@ metadata: annotations: api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814 controller-gen.kubebuilder.io/version: v0.11.3 - helm.sh/resource-policy: keep creationTimestamp: null name: volumesnapshotclasses.snapshot.storage.k8s.io @@ -231,7 +221,6 @@ metadata: annotations: api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814 controller-gen.kubebuilder.io/version: v0.11.3 - helm.sh/resource-policy: keep creationTimestamp: null name: volumesnapshotcontents.snapshot.storage.k8s.io @@ -720,7 +709,6 @@ metadata: annotations: api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814 controller-gen.kubebuilder.io/version: v0.11.3 - helm.sh/resource-policy: keep creationTimestamp: null name: volumesnapshots.snapshot.storage.k8s.io @@ -1110,7 +1098,6 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.4.0 - helm.sh/resource-policy: keep creationTimestamp: null name: zfsbackups.zfs.openebs.io @@ -1217,7 +1204,6 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.4.0 - helm.sh/resource-policy: keep creationTimestamp: null name: zfsnodes.zfs.openebs.io @@ -1304,7 +1290,6 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.4.0 - helm.sh/resource-policy: keep creationTimestamp: null name: zfsrestores.zfs.openebs.io @@ -1533,7 +1518,6 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.4.0 - helm.sh/resource-policy: keep creationTimestamp: null name: zfssnapshots.zfs.openebs.io @@ -1907,7 +1891,6 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.4.0 - helm.sh/resource-policy: keep creationTimestamp: null name: zfsvolumes.zfs.openebs.io @@ -2347,12 +2330,9 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: openebs-zfs-provisioner-role labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller" rules: @@ -2402,12 +2382,9 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: openebs-zfs-snapshotter-role labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller" rules: @@ -2451,12 +2428,9 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: openebs-zfs-driver-registrar-role labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" name: "openebs-zfs-node" - release: openebs openebs.io/component-name: "openebs-zfs-node" rules: - apiGroups: [""] @@ -2475,12 +2449,9 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: openebs-zfs-provisioner-binding labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller" subjects: @@ -2498,12 +2469,9 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: openebs-zfs-snapshotter-binding labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller" subjects: @@ -2521,12 +2489,9 @@ apiVersion: rbac.authorization.k8s.io/v1 metadata: name: openebs-zfs-driver-registrar-binding labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" name: "openebs-zfs-node" - release: openebs openebs.io/component-name: "openebs-zfs-node" subjects: - kind: ServiceAccount @@ -2544,18 +2509,14 @@ metadata: name: openebs-zfs-localpv-node namespace: kube-system labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" name: "openebs-zfs-node" - release: openebs openebs.io/component-name: "openebs-zfs-node" spec: selector: matchLabels: name: "openebs-zfs-node" - release: openebs updateStrategy: rollingUpdate: maxUnavailable: 100% @@ -2563,12 +2524,9 @@ spec: template: metadata: labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" name: "openebs-zfs-node" - release: openebs openebs.io/component-name: "openebs-zfs-node" spec: priorityClassName: openebs-zfs-csi-node-critical @@ -2683,30 +2641,23 @@ metadata: name: openebs-zfs-localpv-controller namespace: kube-system labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller" spec: selector: matchLabels: app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" replicas: 1 template: metadata: labels: - chart: zfs-localpv-2.7.0-develop - heritage: Helm openebs.io/version: "2.7.0-develop" role: "openebs-zfs" app: "openebs-zfs-controller" - release: openebs component: "openebs-zfs-controller" openebs.io/component-name: "openebs-zfs-controller"