Skip to content

Commit

Permalink
use global value for operator repository
Browse files Browse the repository at this point in the history
Signed-off-by: Tao Li <[email protected]>
  • Loading branch information
litaocdl committed Nov 27, 2024
1 parent 8a8b77f commit 231d393
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 58 deletions.
52 changes: 17 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ 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.

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 `edb-postgres-distributed-for-kubernetes` chart will install the operator for
both PG4K-PGD and PG4K in the same namespace. The PG4K operator used for PG4K-PGD
is well-tested and belongs to 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
Expand Down Expand Up @@ -145,7 +144,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.
Expand All @@ -154,7 +153,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
Expand Down Expand Up @@ -184,23 +183,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
Expand All @@ -213,19 +199,17 @@ 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
NAME STATUS AGE
cert-manager Active 24m
pgd-operator-system Active 55s
postgresql-operator-system Active 5m33s
```

### Controlling the image repositories
Expand All @@ -238,14 +222,13 @@ 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 multiple
set options.
- `image.repository` where the PG4K-PGD and PG4K operator image is pulled from, this is the repository without imageName, the default
operator image name is defined in the value file.
- `PGD_IMAGE_NAME` where the PGD image are pulled from.
- `PGD_PROXY_IMAGE_NAME` 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.
Expand All @@ -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 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
```
Expand Down
9 changes: 6 additions & 3 deletions charts/edb-postgres-distributed-for-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
replicaCount: 1

image:
repository: docker.enterprisedb.com/k8s_enterprise/edb-postgres-for-kubernetes
pullPolicy: IfNotPresent
repository: docker.enterprisedb.com/k8s_enterprise
# 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
Expand All @@ -41,6 +43,7 @@ fullnameOverride: ""
hostNetwork: false
dnsPolicy: ""

installCRDs: true
crds:
# -- Specifies whether the CRDs should be created when installing the chart.
create: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
29 changes: 15 additions & 14 deletions charts/edb-postgres-distributed-for-kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -36,6 +43,7 @@ image:

imagePullSecrets:
- name: edb-pull-secret

nameOverride: ""
fullnameOverride: ""

Expand Down Expand Up @@ -158,16 +166,9 @@ 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

0 comments on commit 231d393

Please sign in to comment.