-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-prod-postgres-cluster-manifest
executable file
·101 lines (87 loc) · 5.85 KB
/
build-prod-postgres-cluster-manifest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -e
shopt -s extglob
# Update/Modify/Deploy postgres-operator clusters
# Update/Modify/Deploy postgres-operator clusters
# DBA's: edit postgres.vars file the run this script with no args then follow your git process to commit to development branch.
# DBA's: edit postgres.vars file the run this script with no args then follow your git process to commit to development branch.
POSTGRES_CLUSTER_VARS_FILE="./pg-prod.vars"
source "./${POSTGRES_CLUSTER_VARS_FILE}"
printf "\nPOSTGRES_CLUSTER_VARS_FILE: ${POSTGRES_CLUSTER_VARS_FILE}\n
POSTGRES_API_VERSION: ${POSTGRES_API_VERSION}\n
POSTGRES_CLUSTER_ENV: ${POSTGRES_CLUSTER_ENV}\n
POSTGRES_CLUSTER_NAME: ${POSTGRES_CLUSTER_NAME}\n
POSTGRES_CLUSTER_NAMESPACE: ${POSTGRES_CLUSTER_NAMESPACE}\n
POSTGRES_TEAMID: ${POSTGRES_TEAMID}\n
POSTGRES_VOLUME_SIZE: ${POSTGRES_VOLUME_SIZE}\n
POSTGRES_NUMBER_OF_INSTANCES: ${POSTGRES_NUMBER_OF_INSTANCES}\n
POSTGRES_APPLICATION_USERS_ROOT_ONE: ${POSTGRES_APPLICATION_USERS_ROOT_ONE}\n
POSTGRES_APPLICATION_USERS_ROOT_TWO: ${POSTGRES_APPLICATION_USERS_ROOT_TWO}\n
POSTGRES_ENABLE_MASTER_LOADBALANCER: ${POSTGRES_ENABLE_MASTER_LOADBALANCER}\n
POSTGRES_ENABLE_REPLCA_LOADBALANCER: ${POSTGRES_ENABLE_REPLCA_LOADBALANCER}\n
POSTGRES_ALLOWED_SOURCE_RANGE1: ${POSTGRES_ALLOWED_SOURCE_RANGE1}\n
POSTGRES_ALLOWED_SOURCE_RANGE2: ${POSTGRES_ALLOWED_SOURCE_RANGE2}\n
POSTGRES_ALLOWED_SOURCE_RANGE3: ${POSTGRES_ALLOWED_SOURCE_RANGE3}\n
POSTGRES_DATABASES1_NAME: ${POSTGRES_DATABASES1_NAME}\n
POSTGRES_DATABASES1_USER: ${POSTGRES_DATABASES1_USER}\n
POSTGRES_DATABASES2_NAME: ${POSTGRES_DATABASES2_NAME}\n
POSTGRES_DATABASES2_USER: ${POSTGRES_DATABASES2_USER}\n
POSTGRES_DATABASES3_NAME: ${POSTGRES_DATABASES3_NAME}\n
POSTGRES_DATABASES3_USER: ${POSTGRES_DATABASES3_USER}\n
POSTGRES_ENABLE_SHM_VOLUME: ${POSTGRES_ENABLE_SHM_VOLUME}\n
POSTGRES_VERSION: ${POSTGRES_VERSION}\n
POSTGRES_SHARED_BUFFERS: ${POSTGRES_SHARED_BUFFERS}\n
POSTGRES_MAX_CONNECTIONS: ${POSTGRES_MAX_CONNECTIONS}\n
POSTGRES_LOG_STATEMENT: ${POSTGRES_LOG_STATEMENT}\n
POSTGRES_RESOURCES_REQUESTS_CPU: ${POSTGRES_RESOURCES_REQUESTS_CPU}\n
POSTGRES_RESOURCES_REQUESTS_MEMORY: ${POSTGRES_RESOURCES_REQUESTS_MEMORY}\n
POSTGRES_RESOURCES_LIMITS_CPU: ${POSTGRES_RESOURCES_LIMITS_CPU}\n
POSTGRES_RESOURCES_LIMITS_MEMORY: ${POSTGRES_RESOURCES_LIMITS_MEMORY}\n
POSTGRES_PATRONI_PG_HBA_HOSTSSL: ${POSTGRES_PATRONI_PG_HBA_HOSTSSL}\n
POSTGRES_PATRONI_PG_HBA_HOST: ${POSTGRES_PATRONI_PG_HBA_HOST}\n
POSTGRES_PATRONI_TTL: ${POSTGRES_PATRONI_TTL}\n
POSTGRES_PATRONI_LOOP_WAIT: ${POSTGRES_PATRONI_LOOP_WAIT}\n
POSTGRES_PATRONI_RETRY_TIMEOUT: ${POSTGRES_PATRONI_RETRY_TIMEOUT}\n
POSTGRES_PATRONI_MAXIMUM_LAG_ON_FAILOVER: ${POSTGRES_PATRONI_MAXIMUM_LAG_ON_FAILOVER}\n
POSTGRES_MAINT_WINDOW: ${POSTGRES_MAINT_WINDOWS}\n"
# clear existing old manifests before we build new ones
rm -fr ./manifests/${POSTGRES_CLUSTER_ENV} && mkdir -p ./manifests/${POSTGRES_CLUSTER_ENV}
# token replace all our requisite vars from the requisite POSTGRES_CLUSTER_VARS_FILE
# this should already exist from the infrastructure code repo but JIC its missing we create namespace
sed -e "s#__POSTGRES_CLUSTER_NAMESPACE__#${POSTGRES_CLUSTER_NAMESPACE}#g" ./templates/00-namespace.yaml.tpl > "./manifests/${POSTGRES_CLUSTER_ENV}/${POSTGRES_CLUSTER_NAME}-namespace.yaml"
# cluster
sed -e "s#__POSTGRES_CLUSTER_NAME__#${POSTGRES_CLUSTER_NAME}#g" \
-e "s#__POSTGRES_CLUSTER_NAMESPACE__#${POSTGRES_CLUSTER_NAMESPACE}#g" \
-e "s#__POSTGRES_API_VERSION__#${POSTGRES_API_VERSION}#g" \
-e "s#__POSTGRES_TEAMID__#${POSTGRES_TEAMID}#g" \
-e "s#__POSTGRES_VOLUME_SIZE__#${POSTGRES_VOLUME_SIZE}#g" \
-e "s#__POSTGRES_NUMBER_OF_INSTANCES__#${POSTGRES_NUMBER_OF_INSTANCES}#g" \
-e "s#__POSTGRES_APPLICATION_USERS_ROOT_ONE__#${POSTGRES_APPLICATION_USERS_ROOT_ONE}#g" \
-e "s#__POSTGRES_APPLICATION_USERS_ROOT_TWO__#${POSTGRES_APPLICATION_USERS_ROOT_TWO}#g" \
-e "s#__POSTGRES_ENABLE_MASTER_LOADBALANCER__#${POSTGRES_ENABLE_MASTER_LOADBALANCER}#g" \
-e "s#__POSTGRES_ENABLE_REPLICA_LOADBALANCER__#${POSTGRES_ENABLE_REPLICA_LOADBALANCER}#g" \
-e "s#__POSTGRES_ALLOWED_SOURCE_RANGE1__#${POSTGRES_ALLOWED_SOURCE_RANGE1}#g" \
-e "s#__POSTGRES_ALLOWED_SOURCE_RANGE2__#${POSTGRES_ALLOWED_SOURCE_RANGE2}#g" \
-e "s#__POSTGRES_ALLOWED_SOURCE_RANGE3__#${POSTGRES_ALLOWED_SOURCE_RANGE3}#g" \
-e "s#__POSTGRES_DATABASES1_NAME__#${POSTGRES_DATABASES1_NAME}#g" \
-e "s#__POSTGRES_DATABASES1_USER__#${POSTGRES_DATABASES1_USER}#g" \
-e "s#__POSTGRES_DATABASES2_NAME__#${POSTGRES_DATABASES2_NAME}#g" \
-e "s#__POSTGRES_DATABASES2_USER__#${POSTGRES_DATABASES2_USER}#g" \
-e "s#__POSTGRES_DATABASES3_NAME__#${POSTGRES_DATABASES3_NAME}#g" \
-e "s#__POSTGRES_DATABASES3_USER__#${POSTGRES_DATABASES3_USER}#g" \
-e "s#__POSTGRES_ENABLE_SHM_VOLUME__#${POSTGRES_ENABLE_SHM_VOLUME}#g" \
-e "s#__POSTGRES_VERSION__#${POSTGRES_VERSION}#g" \
-e "s#__POSTGRES_SHARED_BUFFERS__#${POSTGRES_SHARED_BUFFERS}#g" \
-e "s#__POSTGRES_MAX_CONNECTIONS__#${POSTGRES_MAX_CONNECTIONS}#g" \
-e "s#__POSTGRES_LOG_STATEMENT__#${POSTGRES_LOG_STATEMENT}#g" \
-e "s#__POSTGRES_RESOURCES_REQUESTS_CPU__#${POSTGRES_RESOURCES_REQUESTS_CPU}#g" \
-e "s#__POSTGRES_RESOURCES_REQUESTS_MEMORY__#${POSTGRES_RESOURCES_REQUESTS_MEMORY}#g" \
-e "s#__POSTGRES_RESOURCES_LIMITS_CPU__#${POSTGRES_RESOURCES_LIMITS_CPU}#g" \
-e "s#__POSTGRES_RESOURCES_LIMITS_MEMORY__#${POSTGRES_RESOURCES_LIMITS_MEMORY}#g" \
-e "s#__POSTGRES_PATRONI_PG_HBA_HOSTSSL__#${POSTGRES_PATRONI_PG_HBA_HOSTSSL}#g" \
-e "s#__POSTGRES_PATRONI_PG_HBA_HOST__#${POSTGRES_PATRONI_PG_HBA_HOST}#g" \
-e "s#__POSTGRES_PATRONI_TTL__#${POSTGRES_PATRONI_TTL}#g" \
-e "s#__POSTGRES_PATRONI_LOOP_WAIT__#${POSTGRES_PATRONI_LOOP_WAIT}#g" \
-e "s#__POSTGRES_PATRONI_RETRY_TIMEOUT__#${POSTGRES_PATRONI_RETRY_TIMEOUT}#g" \
-e "s#__POSTGRES_PATRONI_MAXIMUM_LAG_ON_FAILOVER__#${POSTGRES_PATRONI_MAXIMUM_LAG_ON_FAILOVER}#g" \
-e "s#__POSTGRES_MAINT_WINDOWS__#${POSTGRES_MAINT_WINDOWS}#g" ./templates/01-cluster.yaml.tpl > "./manifests/${POSTGRES_CLUSTER_ENV}/${POSTGRES_CLUSTER_NAME}-cluster.yaml"