Skip to content

Commit f0003c4

Browse files
author
Yannic Nevado Hidalgo
committed
enable pod affinity for postgres instances, increase volume size
1 parent 783064c commit f0003c4

File tree

5 files changed

+46
-13
lines changed

5 files changed

+46
-13
lines changed

manifests/configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ data:
2323
# enable_admin_role_for_users: "true"
2424
# enable_database_access: "true"
2525
enable_master_load_balancer: "true"
26-
# enable_pod_antiaffinity: "false"
26+
enable_pod_antiaffinity: "true"
2727
# enable_pod_disruption_budget: "true"
2828
enable_replica_load_balancer: "true"
2929
# enable_shm_volume: "true"

manifests/postgres-instance.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
teamId: "Postgres"
1717
# size and accessmode(=defined in storageclass) for persistent volume claim
1818
volume:
19-
size: 1Gi
19+
size: 15Gi
2020
storageClass: standard
2121
# number of pods
2222
# 1 is master, others replicas
@@ -30,7 +30,6 @@ spec:
3030
# define some database with its owner
3131
databases:
3232
foo: zalando # dbname: owner
33-
test: zalando
3433
# needed for shared_memory, in docker default=64mb
3534
enableShmVolume: true
3635
allowedSourceRanges: # load balancers' source ranges for both master and replica services
@@ -42,18 +41,18 @@ spec:
4241
parameters:
4342
listen_addresses: '*'
4443
shared_buffers: "128MB"
45-
max_connections: "10"
44+
max_connections: "100"
4645
log_statement: "all"
4746
log_destination: "stderr"
4847
log_directory: "/var/log/postgresql"
4948
# define the minimum and limit of resources of an postgres database container
5049
resources:
5150
requests:
52-
cpu: 15m
53-
memory: 150Mi
51+
cpu: 100m
52+
memory: 275Mi
5453
limits:
5554
cpu: 300m
56-
memory: 275Mi
55+
memory: 300Mi
5756
# parameters for initializing database
5857
patroni:
5958
initdb:

manifests/postgres-operator.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ spec:
2727
resources:
2828
requests:
2929
cpu: 500m
30-
memory: 250Mi
30+
memory: 125Mi
3131
limits:
32-
cpu: 2000m
33-
memory: 500Mi
32+
cpu: 1000m
33+
memory: 250Mi
3434
# define at which user the postgres-operator container will run
3535
securityContext:
3636
runAsUser: 1000

pg_bench

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$ psql -d postgres -U postgres -c "DROP DATABASE IF EXISTS test"
2+
3+
# Testdatenbank mti dem Namen test_container erstellen
4+
$ psql -d postgres -U postgres -c "CREATE DATABASE test"
5+
6+
# -i = initialize
7+
# -s = scale default database value(16MB) * 50 = 800MB
8+
# time = measure the time for executing the command
9+
$ time pgbench -i -s 50 test -U postgres (~30min 51sec.)
10+
11+
table # of rows
12+
---------------------------------
13+
pgbench_branches 50
14+
pgbench_tellers 500
15+
pgbench_accounts 5.000.000
16+
pgbench_history 0
17+
18+
# c = clients -> number of clients to connect with
19+
# j = threads -> number of worker processes for pgbench
20+
# t = transactions -> number of transactions per client session => 10*100.000 = 1.000.000 transactions
21+
# -t 100000 -> nach 42min abgebrochen -> ram const stabil unter req; cpu const. über req
22+
# -t 10000 -> number of transactions per client session => 10*10.000 = 100.000 transactions
23+
$ time pgbench -c 10 -j 2 -t 10000 test -U postgres
24+
25+
26+
# kill database with to much ressourcen
27+
$ pgbench -c 90 -j 10 -t 100000 test -U postgres
28+
29+
# get size of database
30+
SELECT pg_size_pretty( pg_database_size('test') );

reset_postgres_operator_setup.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ kubectl delete clusterroles zalando-postgres-operator -n zalando-postgres
66

77
kubectl delete clusterrolebindings zalando-postgres-operator -n zalando-postgres
88

9-
kubectl delete serviceaccounts zalando-postgres-operator -n zalando-postgres
9+
kubectl delete serviceaccounts zalando-postgres-operator -n zalando-postgres
1010

1111
kubectl delete secrets foo-user.postgres-instance.credentials postgres.postgres-instance.credentials standby.postgres-instance.credentials zalando.postgres-instance.credentials -n zalando-postgres
1212

1313
kubectl delete configmaps postgres-operator -n zalando-postgres
1414

1515
kubectl delete postgresql postgres-instance -n zalando-postgres
1616

17-
kubectl delete service postgres-instance postgres-instance-repl -n zalando-postgres
17+
sleep 3
1818

19-
kubectl delete poddisruptionbudgets postgres-acid-minimal-cluster-pdb -n zalando-postgres
19+
kubectl delete service postgres-instance postgres-instance-config postgres-instance-repl -n zalando-postgres
20+
21+
# sleep 3
22+
23+
# kubectl delete poddisruptionbudgets postgres-acid-minimal-cluster-pdb -n zalando-postgres
2024

2125
# kubectl delete pvc pgdata-acid-minimal-cluster-0 pgdata-acid-minimal-cluster-1 pgdata-acid-minimal-cluster-2 -n zalando-postgres

0 commit comments

Comments
 (0)