Skip to content

Commit ce961f4

Browse files
committed
Added full interactive scripts. Final materials for tutorial.
1 parent bb92583 commit ce961f4

13 files changed

+309
-145
lines changed

operator/pg-manifest.yaml~ renamed to operator/add-to-manifest.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: "acid.zalan.do/v1"
22
kind: postgresql
33
metadata:
4-
name: web-db6
4+
name: spilo-s1
55
spec:
6-
teamId: "web"
6+
teamId: "spilo"
77
volume:
88
size: 1Gi
99
numberOfInstances: 3
@@ -15,9 +15,15 @@ spec:
1515

1616
# role for application foo
1717
foo_user:
18-
18+
19+
# new role for application bar
20+
bar_user:
21+
1922
#databases: name->owner
2023
databases:
2124
foo: zalando
25+
bar: zalando
2226
postgresql:
2327
version: "10"
28+
parameters:
29+
timezone: "America/Los_Angeles"

operator/configmap.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: postgres-operator
5-
data:
5+
data:
66
# if set to the "*", listen to all namespaces
77
# watched_namespace: development
88
cluster_labels: application:spilo
@@ -11,7 +11,7 @@ data:
1111

1212
debug_logging: "true"
1313
workers: "4"
14-
docker_image: registry.opensource.zalan.do/acid/spilo-cdp-10:1.4-p8
14+
docker_image: "jberkus/spilo-demo:latest"
1515
pod_service_account_name: "zalando-postgres-operator"
1616
secret_name_template: '{username}.{cluster}.credentials'
1717
super_username: postgres

operator/connect_min_cluster

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/bash
22

3-
export HOST_PORT=$(minikube service acid-minimal-cluster --url | sed 's,.*/,,')
3+
export HOST_PORT=$(minikube service spilo-s1 --url | sed 's,.*/,,')
44
export PGHOST=$(echo $HOST_PORT | cut -d: -f 1)
55
export PGPORT=$(echo $HOST_PORT | cut -d: -f 2)
6-
export PGPASSWORD=$(kubectl --context minikube get secret postgres.acid-minimal-cluster.credentials -o 'jsonpath={.data.password}' | base64 -d)
6+
export PGPASSWORD=$(kubectl --context minikube get secret postgres.spilo-s1.credentials -o 'jsonpath={.data.password}' | base64 -d)
77

8-
psql -U postgres
8+
psql -U postgres

operator/fake-teams-api.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

operator/infrastructure-roles-configmap.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

operator/infrastructure-roles.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

operator/minimal-postgres-manifest.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: "acid.zalan.do/v1"
22
kind: postgresql
33
metadata:
4-
name: acid-minimal-cluster2
4+
name: spilo-s1
55
spec:
6-
teamId: "ACID"
6+
teamId: "spilo"
77
volume:
88
size: 1Gi
99
numberOfInstances: 3
@@ -15,7 +15,7 @@ spec:
1515

1616
# role for application foo
1717
foo_user:
18-
18+
1919
#databases: name->owner
2020
databases:
2121
foo: zalando

operator/pg-manifest.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

patroni/patroni_k8s.yaml

Lines changed: 58 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
## optional, a load-balancing service
2+
## for read-only connections and direct
3+
## connections to a specific backend
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: patronidemo-ss
8+
spec:
9+
ports:
10+
- port: 5432
11+
name: psql
12+
- port: 8008
13+
name: patronictl
14+
clusterIP: None
15+
selector:
16+
application: patroni
17+
cluster-name: patronidemo
18+
19+
---
20+
## endpoint, this is the master connection endpoint
21+
# also used as a lock for master election contests
22+
apiVersion: v1
23+
kind: Endpoints
24+
metadata:
25+
name: &cluster_name patronidemo
26+
labels:
27+
application: patroni
28+
cluster-name: *cluster_name
29+
subsets: []
30+
31+
---
32+
## service for the master endpoint
33+
apiVersion: v1
34+
kind: Service
35+
metadata:
36+
name: &cluster_name patronidemo
37+
labels:
38+
application: patroni
39+
cluster-name: *cluster_name
40+
spec:
41+
type: ClusterIP
42+
ports:
43+
- port: 5432
44+
targetPort: 5432
45+
46+
---
47+
## the statefulset, this is the actual database nodes
148
apiVersion: apps/v1beta1
249
kind: StatefulSet
350
metadata:
@@ -7,7 +54,8 @@ metadata:
754
cluster-name: *cluster_name
855
spec:
956
replicas: 3
10-
serviceName: *cluster_name
57+
# change to *clustername if not using the load-balancing service
58+
serviceName: patronidemo-ss
1159
template:
1260
metadata:
1361
labels:
@@ -80,30 +128,9 @@ spec:
80128
storage: 1Gi
81129

82130
---
83-
apiVersion: v1
84-
kind: Endpoints
85-
metadata:
86-
name: &cluster_name patronidemo
87-
labels:
88-
application: patroni
89-
cluster-name: *cluster_name
90-
subsets: []
91-
92-
---
93-
apiVersion: v1
94-
kind: Service
95-
metadata:
96-
name: &cluster_name patronidemo
97-
labels:
98-
application: patroni
99-
cluster-name: *cluster_name
100-
spec:
101-
type: ClusterIP
102-
ports:
103-
- port: 5432
104-
targetPort: 5432
105-
106-
---
131+
# passwords for the patroni database
132+
# if you had more users + passwords, you'd add them
133+
# here
107134
apiVersion: v1
108135
kind: Secret
109136
metadata:
@@ -117,6 +144,11 @@ data:
117144
replication-password: cmVwLXBhc3M=
118145

119146
---
147+
## the rest is a serviceaccount and RBAC
148+
# for permissions and access control for patroni
149+
# this is required for leader elections to work properly
150+
# and requires you to have admin rights on the
151+
# kubernetes cluster
120152
apiVersion: v1
121153
kind: ServiceAccount
122154
metadata:
@@ -148,6 +180,7 @@ rules:
148180
- patch
149181
- update
150182
# the following three privileges are necessary only when using endpoints
183+
# and need to be removed for Openshift
151184
- create
152185
- list
153186
- watch

patroni/pg-shell.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: pg-shell
5+
spec:
6+
containers:
7+
- name: pg-shell
8+
image: jberkus/simple-patroni
9+
command: ["/bin/bash", "-ec", "while :; do echo '.'; sleep 10 ; done"]
10+
env:
11+
- name: PGUSER
12+
value: postgres
13+
- name: PGPASSWORD
14+
valueFrom:
15+
secretKeyRef:
16+
name: patronidemo
17+
key: superuser-password
18+
restartPolicy: Never

0 commit comments

Comments
 (0)