Skip to content

Commit f0c02ad

Browse files
leonardocejsilvelasxd
authored
feat: support PG4K namespace-restricted installation (#140)
Signed-off-by: Leonardo Cecchi <[email protected]> Signed-off-by: Jaime Silvela <[email protected]> Signed-off-by: Jonathan Gonzalez V <[email protected]> Co-authored-by: Jaime Silvela <[email protected]> Co-authored-by: Jonathan Gonzalez V <[email protected]>
1 parent 6dfb29d commit f0c02ad

File tree

8 files changed

+475
-334
lines changed

8 files changed

+475
-334
lines changed

.github/workflows/continuous-delivery.yml

+39
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,42 @@ jobs:
102102
kubectl wait --timeout=5m --for=jsonpath='{.status.phase}'="$PHASE" pgdgroups/region-a
103103
kubectl wait --timeout=5m --for=jsonpath='{.status.phase}'="$PHASE" pgdgroups/region-b
104104
kubectl wait --timeout=5m --for=jsonpath='{.status.phase}'="$PHASE" pgdgroups/region-c
105+
106+
deploy-ep4k-single-namespace:
107+
runs-on: ubuntu-22.04
108+
needs:
109+
- change-triage
110+
if: needs.change-triage.outputs.ep4k-changed == 'true'
111+
steps:
112+
- name: Checkout
113+
uses: actions/[email protected]
114+
with:
115+
fetch-depth: 0
116+
117+
- name: Set up Helm
118+
uses: azure/[email protected]
119+
with:
120+
version: v3.11.3
121+
122+
- name: Create kind cluster
123+
uses: helm/[email protected]
124+
125+
- name: Deploy in single-namespace mode using helm chart
126+
run: |
127+
helm upgrade --install edb-pg4k --namespace single-install \
128+
--set config.clusterWide=false \
129+
--create-namespace charts/edb-postgres-for-kubernetes --wait
130+
- name: Install kubectl
131+
uses: azure/[email protected]
132+
133+
- name: Deploy a cluster in the watched namespace
134+
run: |
135+
kubectl -n single-install apply -f hack/samples/ep4k-cluster.yaml
136+
PHASE="Cluster in healthy state"
137+
kubectl -n single-install wait --timeout=5m --for=jsonpath='{.status.phase}'="$PHASE" clusters/cluster-example
138+
139+
- name: Ignore deploying a cluster in another namespace
140+
run: |
141+
kubectl create ns test-ignore
142+
kubectl -n test-ignore apply -f hack/samples/ep4k-cluster.yaml
143+
kubectl -n test-ignore get pods 2>&1 >/dev/null | grep 'No resources found'

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,30 @@ edb-pg4k-edb-postgres-for-kubernetes 1/1 1 1 11s
4242
Once it is ready, you can verify that you can deploy the sample cluster
4343
suggested by the helm chart.
4444

45+
### Single namespace installation
46+
47+
It is possible to limit the operator's capabilities to solely the namespace in
48+
which it has been installed. With this restriction, the cluster-level
49+
permissions required by the operator will be substantially reduced, and
50+
the security profile of the installation will be enhanced.
51+
52+
You can install the operator in single-namespace mode by setting the
53+
`config.clusterWide` flag to false, as in the following example:
54+
55+
```console
56+
helm upgrade --install edb-pg4k \
57+
--namespace postgresql-operator-system \
58+
--create-namespace \
59+
--set config.clusterWide=false \
60+
edb/edb-postgres-for-kubernetes
61+
```
62+
63+
**IMPORTANT**: the single-namespace installation mode can't coexist
64+
with the cluster-wide operator. Otherwise there would be collisions when
65+
managing the resources in the namespace watched by the single-namespace
66+
operator.
67+
It is up to the user to ensure there is no collision between operators.
68+
4569
### Deploying EDB Postgres for Kubernetes (PG4K) operator from EDB's private registry
4670

4771
By default, PG4K will be deployed using [images publicly hosted on Quay.io](https://quay.io/repository/enterprisedb/cloud-native-postgresql),
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11

22
EDB Postgres for Kubernetes Operator should be installed in namespace "{{ .Release.Namespace }}".
3-
You can now create a PostgreSQL cluster with 3 nodes in the current namespace as follows:
3+
You can now create a PostgreSQL cluster with 3 nodes as follows:
44

55
cat <<EOF | kubectl apply -f -
66
# Example of PostgreSQL cluster
77
apiVersion: postgresql.k8s.enterprisedb.io/v1
88
kind: Cluster
99
metadata:
1010
name: cluster-example
11+
{{if not .Values.config.clusterWide -}}
12+
namespace: {{ .Release.Namespace }}
13+
{{- end }}
1114
spec:
1215
instances: 3
1316
storage:
1417
size: 1Gi
1518
EOF
1619

17-
kubectl get cluster
20+
kubectl get -A cluster
1821

0 commit comments

Comments
 (0)