From 90c6f17077bfe29b89b1b9db4aea57654d46c6ea Mon Sep 17 00:00:00 2001 From: Tao Li Date: Wed, 27 Nov 2024 11:03:13 +0800 Subject: [PATCH] use global value for operator repository Signed-off-by: Tao Li --- .github/workflows/continuous-delivery.yml | 7 ++- README.md | 62 +++++++------------ .../README.md | 9 ++- .../templates/_helpers.tpl | 11 ++++ .../templates/deployment.yaml | 4 +- .../values.yaml | 9 ++- .../templates/_helpers.tpl | 11 ++++ .../templates/deployment.yaml | 4 +- .../values.yaml | 28 +++++---- 9 files changed, 80 insertions(+), 65 deletions(-) diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index b30b312..460809e 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -67,7 +67,7 @@ jobs: PHASE="Cluster in healthy state" kubectl wait --timeout=5m --for=jsonpath='{.status.phase}'="$PHASE" clusters/cluster-example - deploy-ep4k-lts: + deploy-ep4k-subcharts: runs-on: ubuntu-22.04 needs: - change-triage @@ -190,7 +190,7 @@ jobs: kubectl -n test-ignore apply -f hack/samples/ep4k-cluster.yaml kubectl -n test-ignore get pods 2>&1 >/dev/null | grep 'No resources found' - deploy-ep4k-lts-single-namespace: + deploy-ep4k-subcharts-single-namespace: runs-on: ubuntu-22.04 needs: - change-triage @@ -209,11 +209,12 @@ jobs: - name: Create kind cluster uses: helm/kind-action@v1.10.0 - - name: Deploy in single-namespace mode using helm chart + - name: Deploy in single-namespace mode using helm chart use different namespace run: | helm upgrade --install edb-pg4k-lts --namespace single-install \ --set config.clusterWide=false \ --create-namespace charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts \ + --set image.repository=docker.enterprisedb.com/k8s_standard_pgd \ --set image.imageCredentials.create=true \ --set image.imageCredentials.username=${{ secrets.CS_USER }} \ --set image.imageCredentials.password=${{ secrets.CS_PASSWORD }} \ diff --git a/README.md b/README.md index 85ca444..dddb45c 100644 --- a/README.md +++ b/README.md @@ -90,17 +90,17 @@ It is up to the user to ensure there is no collision between operators. ## Deployment of the EDB Postgres Distributed for Kubernetes operator (PG4K-PGD) -Like PG4K install, both the operator and the operand images required by PG4K-PGD -may be pulled from the `k8s_enterprise` or `k8s_standard` repositories at -`docker.enterprisedb.com`, please obtaining an EDB subscription token before setup. +Like PG4K helm chart install, both the operator and the operand images required +by `edb-postgres-distributed-for-kubernetes` may be pulled from the +`k8s_enterprise_pgd` or `k8s_standard_pgd` repositories at `docker.enterprisedb.com`, +please obtaining an EDB subscription token before setup. -The `edb-postgres-distributed-for-kubernetes` chart will by default install PG4K -operator defined by sub-chart in the same namespace, the PG4K operator installed -in the sub-chart is PG4K LTS release operator, which is upgraded along with the -parent chart version release. +The PG4K-PGD chart installs both the PG4K-PGD and PG4K operators in the +same namespace. The PG4K operator installed is a stable version that is +part of the latest long-term support release of PG4K. -The `edb-postgres-distributed-for-kubernetes` chart also install the cert-manager -operators as dependency. You can avoid this if necessary. See the sub-section +The PG4K-PGD chart also install the cert-manager operators as dependency. You +can avoid this if necessary. See the sub-section [on deploying individually](#deploying-the-PG4K-PGD-operators-individually). **Note:** this helm chart uses a default registry to retrieve the operator @@ -145,7 +145,7 @@ helm chart are working: ### Deploying the PG4K-PGD operators and cert-manager individually The chart `edb-postgres-distributed-for-kubernetes` is set by default to -also install PG4K and cert-manager operators, which it depends on. +also install cert-manager operators, which it depends on. When following this route, all operators will be installed in the same namespace. This is in contrast with other installation paths, where the operators reside in dedicated namespaces. @@ -154,7 +154,7 @@ Installing all dependencies in the same namespace is a design limitation of Helm, but we can get around it by installing dependencies with separate invocations of `helm`. -If you would like to install the cert-manager in separate namespaces, please +If you would like to install the cert-manager in a separate namespaces, please follow the below steps. #### 1. Setup cert-manager @@ -184,23 +184,10 @@ In case you choose this option, remember to also specify `--set cert-manager.enabled=false` during the installation of the PG4K-PGD helm chart in the next section. -#### 2. Setup PG4K - -By default, a PG4K operator with LTS release is installed alongside with PG4K-PGD -deploy. You can follow [PG4K helm chart](#deployment-of-the-edb-postgres-for-kubernetes-operator-pg4k) -to deploy the PG4K operator in its own namespace. But it is highly recommended to use -the PG4K operator installed as dependency of PG4K-PGD chart, which contains the well tested PG4K -operator version. - -In case you choose to use existing PG4K operator, remember to also specify -`--set edb-postgres-for-kubernetes-lts.enabled=false` during the installation of the PG4K-PGD -helm chart in the next section. - -#### 3. Setup PG4K-PGD +#### 2. Setup PG4K-PGD Once the above deployments are ready, you can deploy the PG4K-PGD helm chart. taking care -to set `edb-postgres-for-kubernetes-lts.enabled` to false if you PG4K already deployed, -and set `cert-manager.enabled` to false if cert-manager is installed separately. +to set `cert-manager.enabled` to false if cert-manager is installed separately. **Note:** in the following example, the flags setting the credentials were elided to put the focus on the `enabled=false` condition. The flags may still be @@ -213,11 +200,10 @@ helm upgrade --dependency-update \ --create-namespace \ edb/edb-postgres-distributed-for-kubernetes \ --set cert-manager.enabled=false - --set edb-postgres-for-kubernetes-lts.enabled=false ``` -You can see the three separate namespaces, the same that would be created if -installing manually without Helm charts. +You can see two seperate namespaces where cert-manager is installed in `cert-manager` +namespaces. ``` sh $ kubectl get ns @@ -225,7 +211,6 @@ NAME STATUS AGE … cert-manager Active 24m pgd-operator-system Active 55s -postgresql-operator-system Active 5m33s ``` ### Controlling the image repositories @@ -238,14 +223,12 @@ subscription plan. This needs to be done in several places in the command-line invocation. The following example uses the `k8s_standard_pgd` registry in -`docker.enterprisedb.com`. -Note the multiple `--set` options, for the `image.repository`, -`PGD_IMAGE_NAME` and `PGD_PROXY_IMAGE_NAME` in addition to the -`edb-postgres-for-kubernetes-lts.image.repository` where the PGD operator -is pulled from. There are 4 in total -- `image.repository` where the PG4K-PGD operator image is pulled from. -- `edb-postgres-for-kubernetes-lts.image.repository` where the PG4K operator image is pulled from. -- `PGD_IMAGE_NAME` and `PGD_PROXY_IMAGE_NAME` where the PGD and PGD Proxy image are pulled from. +`docker.enterprisedb.com`. Following is the description of set options. +- `global.image.repository`: The repository where the PG4K-PGD and PG4K operator image downloaded from. +This is a global setting, which is shared for both PG4K-PGD and PG4K operators. +- `PGD_IMAGE_NAME`: The location where the PGD image are pulled from. +- `PGD_PROXY_IMAGE_NAME`: The location where PGD Proxy image are pulled from, usually +the same with `PGD_IMAGE_NAME`. Assuming that you have your necessary credentials, please fill in the USERNAME and PASSWORD below. @@ -258,8 +241,7 @@ helm upgrade --dependency-update \ edb/edb-postgres-distributed-for-kubernetes \ --set image.imageCredentials.username=${USERNAME} \ --set image.imageCredentials.password=${PASSWORD} \ - --set image.repository=docker.enterprisedb.com/k8s_standard_pgd/pg4k-pgd \ - --set edb-postgres-for-kubernetes-lts.image.repository=docker.enterprisedb.com/k8s_standard_pgd/edb-postgres-for-kubernetes \ + --set global.image.repository=docker.enterprisedb.com/k8s_standard_pgd \ --set config.data.PGD_IMAGE_NAME=docker.enterprisedb.com/k8s_standard_pgd/postgresql-pgd:15.6-5.5.1-1 \ --set config.data.PGD_PROXY_IMAGE_NAME=docker.enterprisedb.com/k8s_standard_pgd/edb-pgd-proxy:5.5.0 ``` diff --git a/charts/edb-postgres-distributed-for-kubernetes/README.md b/charts/edb-postgres-distributed-for-kubernetes/README.md index e87b743..ea43ead 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/README.md +++ b/charts/edb-postgres-distributed-for-kubernetes/README.md @@ -44,18 +44,21 @@ EDB Postgres Distributed for Kubernetes Helm Chart | containerSecurityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"runAsGroup":10001,"runAsUser":10001}` | Container Security Context | | crds.create | bool | `true` | || | edb-postgres-for-kubernetes-lts.enable | bool | `true` | | -| edb-postgres-for-kubernetes-lts.image.repository | string | `"docker.enterprisedb.com/k8s_enterprise_pgd/edb-postgres-for-kubernetes"` | | +| edb-postgres-for-kubernetes-lts.image.repository | string | `""` | Overrides the global image repository for pg4k operator. | +| edb-postgres-for-kubernetes-lts.image.imageName | string | `"edb-postgres-for-kubernetes"` | pg4k operator image name in repository| | edb-postgres-for-kubernetes-lts.image.imagePullSecrets[0].name | string| `"edb-pull-secret"` | | | edb-postgres-for-kubernetes-lts.config.data.PULL_SECRET_NAME| string| `"edb-pull-secret"` | | +|global.repository| string|`docker.enterprisedb.com/k8s_enterprise_pgd`| specifies the repository name where all the operators are pulled from, image name is not included| | imagePullSecrets[0].name | string | `"edb-pull-secret"` | | | fullnameOverride | string | `""` | | | image.imageCredentials.create | bool | `true` | Specifies if an imagePullSecret should be created | | image.imageCredentials.name | string | `"edb-pull-secret"` | | | image.imageCredentials.password | string | `""` | | | image.imageCredentials.registry | string | `"docker.enterprisedb.com"` | | -| image.imageCredentials.username | string | `""` | | +| image.imageCredentials.username | string | `""` | | +| image.repository | string | `""` | Overrides the global image repository for pg4k-pgd operator.| +| image.imageName | string | `"pg4k-pgd"` | pg4k-pgd operator image name in repository| | image.pullPolicy | string | `"IfNotPresent"` | | -| image.repository | string | `"docker.enterprisedb.com/k8s_enterprise_pgd/pg4k-pgd"` | | | image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | | managerConfig.data.health.healthProbeBindAddress | string | `":9443"` | | | managerConfig.data.leaderElection.enabled | bool | `true` | | diff --git a/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/_helpers.tpl b/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/_helpers.tpl index 5ec2d8c..f860909 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/_helpers.tpl +++ b/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/_helpers.tpl @@ -72,6 +72,17 @@ Create the imagePullSecret {{- end }} {{- end }} +{{/* +Create the pg4k operator image name +*/}} +{{- define "edb-postgres-for-kubernetes-lts.operatorImageName" }} +{{- if .Values.image.repository }} +{{- printf "%s/%s:%s" .Values.image.repository ( .Values.imageName | default "edb-postgres-for-kubernetes" ) ( .Values.image.tag | default .Chart.AppVersion ) }} +{{- else }} +{{- printf "%s/%s:%s" .Values.global.repository ( .Values.global.imageName | default "edb-postgres-for-kubernetes" ) ( .Values.image.tag | default .Chart.AppVersion ) }} +{{- end }} +{{- end }} + {{/* Define the common set of rules that can be applied either with namespace scope or clusterwide diff --git a/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/deployment.yaml b/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/deployment.yaml index 4c8be70..f5ab323 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/deployment.yaml +++ b/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/templates/deployment.yaml @@ -70,7 +70,7 @@ spec: - /manager env: - name: OPERATOR_IMAGE_NAME - value: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + value: "{{- include "edb-postgres-for-kubernetes-lts.operatorImageName" . }}" - name: OPERATOR_NAMESPACE valueFrom: fieldRef: @@ -84,7 +84,7 @@ spec: - name: WATCH_NAMESPACE value: "{{ .Release.Namespace }}" {{- end }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: "{{- include "edb-postgres-for-kubernetes-lts.operatorImageName" . }}" imagePullPolicy: {{ .Values.image.pullPolicy }} livenessProbe: httpGet: diff --git a/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/values.yaml b/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/values.yaml index d7c9472..d835204 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/values.yaml +++ b/charts/edb-postgres-distributed-for-kubernetes/charts/edb-postgres-for-kubernetes-lts/values.yaml @@ -19,10 +19,14 @@ replicaCount: 1 image: - repository: docker.enterprisedb.com/k8s_enterprise/edb-postgres-for-kubernetes - pullPolicy: IfNotPresent + # -- Specifies the repository where the operator image to be downloaded from + # docker.enterprisedb.com/k8s_standard_pgd + repository: docker.enterprisedb.com/k8s_enterprise_pgd + # The name of the operator image to be pulled from repository + imageName: edb-postgres-for-kubernetes # -- Overrides the image tag whose default is the chart appVersion. tag: "" + pullPolicy: IfNotPresent # Credentials configuration imageCredentials: # -- Specifies if an imagePullSecret should be created @@ -41,6 +45,7 @@ fullnameOverride: "" hostNetwork: false dnsPolicy: "" +installCRDs: true crds: # -- Specifies whether the CRDs should be created when installing the chart. create: true diff --git a/charts/edb-postgres-distributed-for-kubernetes/templates/_helpers.tpl b/charts/edb-postgres-distributed-for-kubernetes/templates/_helpers.tpl index 4fb1e7a..c17679a 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/templates/_helpers.tpl +++ b/charts/edb-postgres-distributed-for-kubernetes/templates/_helpers.tpl @@ -30,6 +30,17 @@ Create chart name and version as used by the chart label. {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} +{{/* +Create the pg4k-pgd operator image name +*/}} +{{- define "edb-postgres-distributed-for-kubernetes.operatorImageName" }} +{{- if .Values.image.repository }} +{{- printf "%s/%s:%s" .Values.image.repository ( .Values.image.imageName | default "pg4k-pgd" ) ( .Values.image.imageTag | default .Chart.AppVersion ) }} +{{- else }} +{{- printf "%s/%s:%s" .Values.global.repository ( .Values.image.imageName | default "pg4k-pgd" ) ( .Values.image.imageTag | default .Chart.AppVersion ) }} +{{- end }} +{{- end }} + {{/* Common labels */}} diff --git a/charts/edb-postgres-distributed-for-kubernetes/templates/deployment.yaml b/charts/edb-postgres-distributed-for-kubernetes/templates/deployment.yaml index 46c5688..d6ef87a 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/templates/deployment.yaml +++ b/charts/edb-postgres-distributed-for-kubernetes/templates/deployment.yaml @@ -65,12 +65,12 @@ spec: - /manager env: - name: OPERATOR_IMAGE_NAME - value: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + value: "{{- include "edb-postgres-distributed-for-kubernetes.operatorImageName" . }}" - name: OPERATOR_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: "{{- include "edb-postgres-distributed-for-kubernetes.operatorImageName" . }}" imagePullPolicy: {{ .Values.image.pullPolicy }} livenessProbe: httpGet: diff --git a/charts/edb-postgres-distributed-for-kubernetes/values.yaml b/charts/edb-postgres-distributed-for-kubernetes/values.yaml index 24727d7..3c99f2d 100644 --- a/charts/edb-postgres-distributed-for-kubernetes/values.yaml +++ b/charts/edb-postgres-distributed-for-kubernetes/values.yaml @@ -18,13 +18,20 @@ replicaCount: 1 +# -- Global values +global: + # -- Specifies the repository where the operator image to be downloaded from + # repository: docker.enterprisedb.com/k8s_standard_pgd + repository: docker.enterprisedb.com/k8s_enterprise_pgd + image: - # Additional Registries - # repository: docker.enterprisedb.com/k8s_standard_pgd/pg4k-pgd - repository: docker.enterprisedb.com/k8s_enterprise_pgd/pg4k-pgd - pullPolicy: IfNotPresent + repository: "" + # -- Specifies the name of the operator image to be pulled from repository + imageName: pg4k-pgd + # -- Specifies the tag of the operator image to be pulled from repository # -- Overrides the image tag whose default is the chart appVersion. - tag: "" + imageTag: "" + imagePullPolicy: IfNotPresent # Credentials configuration imageCredentials: # -- Specifies if an imagePullSecret should be created @@ -36,6 +43,7 @@ image: imagePullSecrets: - name: edb-pull-secret + nameOverride: "" fullnameOverride: "" @@ -158,16 +166,10 @@ cert-manager: enabled: true installCRDs: true -# edb-postgres-for-kubernetes-lts +# edb-postgres-for-kubernetes-lts subcharts edb-postgres-for-kubernetes-lts: enabled: true image: - repository: docker.enterprisedb.com/k8s_enterprise_pgd/edb-postgres-for-kubernetes - imagePullSecrets: - - name: edb-pull-secret - config: - data: - PULL_SECRET_NAME: edb-pull-secret + repository: "" crds: - # -- Specifies whether the CRDs should be created when installing the chart. create: true