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 77c4250 commit d2c0b98
Show file tree
Hide file tree
Showing 7 changed files with 79 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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ Create the imagePullSecret
{{- end }}
{{- end }}

{{/*
Create the pg4k operator image name
*/}}
{{- define "edb-postgres-for-kubernetes-lts.operatorImageName" }}
{{- if not .Values.global }}
{{- if .Values.image.repository }}
{{- printf "%s/%s:%s" .Values.image.repository .Values.image.imageName | default "edb-postgres-for-kubernetes" .Values.image.tag | default .Chart.AppVersion }}
{{- end }}
{{- else }}
{{- if .Values.global.repository }}
{{- printf "%s/%s:%s" .Values.global.repository .Values.global.imageName | default "edb-postgres-for-kubernetes" .Values.image.tag | default .Chart.AppVersion }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create image pullPolicy
*/}}
{{- define "edb-postgres-for-kubernetes-lts.operatorImagePullPolicy" }}
{{- if not .Values.global }}
{{ printf .Values.image.pullPolicy }}
{{- else }}
{{ printf .Values.global.imagePullPolicy }}
{{- 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,8 +84,8 @@ spec:
- name: WATCH_NAMESPACE
value: "{{ .Release.Namespace }}"
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{- include "edb-postgres-for-kubernetes-lts.operatorImageName" . }}"
imagePullPolicy: "{{- include "edb-postgres-for-kubernetes-lts.operatorImagePullPolicy" . }}"
livenessProbe:
httpGet:
path: /readyz
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,15 @@ 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.global.repository }}
{{- printf "%s/%s:%s" .Values.global.repository .Values.global.imageName | default "pg4k-pgd" .Values.global.imageTag | default .Chart.AppVersion }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ 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 }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{- include "edb-postgres-distributed-for-kubernetes.operatorImageName" . }}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
livenessProbe:
httpGet:
path: /readyz
Expand Down
31 changes: 16 additions & 15 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
# -- 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.
imageTag: ""
imagePullPolicy: IfNotPresent


image:
# Additional Registries
# repository: docker.enterprisedb.com/k8s_standard_pgd/pg4k-pgd
repository: docker.enterprisedb.com/k8s_enterprise_pgd/pg4k-pgd
pullPolicy: IfNotPresent
# -- Overrides the image tag whose default is the chart appVersion.
tag: ""
# Credentials configuration
imageCredentials:

Check failure on line 36 in charts/edb-postgres-distributed-for-kubernetes/values.yaml

View workflow job for this annotation

GitHub Actions / linter

36:3 [indentation] wrong indentation: expected 4 but found 2
# -- Specifies if an imagePullSecret should be created
Expand All @@ -36,6 +43,7 @@ image:

imagePullSecrets:
- name: edb-pull-secret

Check failure on line 45 in charts/edb-postgres-distributed-for-kubernetes/values.yaml

View workflow job for this annotation

GitHub Actions / linter

45:3 [indentation] wrong indentation: expected 4 but found 2

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
# Values defined here will overwrite the global values
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
crds:
# -- Specifies whether the CRDs should be created when installing the chart.
create: true

0 comments on commit d2c0b98

Please sign in to comment.