Skip to content

Commit 8c40541

Browse files
committed
The add-targeted-namespace.sh script now creates
the Service Account, Role and Role Binding required by the 'crunchy-postgres-ha' container. The PGHA_PRIMARY_HOST environment variable is now properly set on any replica deployments, which ensures the Primary pod is created and initialized prior to the replicas. This enables the proper orchestration and placement of Primary and Replica pods. The PG cluster deployments and associated services now include the Patroni port (8009).
1 parent db9480c commit 8c40541

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

conf/postgres-operator/cluster-deployment.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@
5252
}, {
5353
"name": "PGHA_USER",
5454
"value": "postgres"
55-
}, {
55+
},
56+
{{if .IsReplica}}
57+
{
58+
"name": "PGHA_PRIMARY_HOST",
59+
"value": "{{.ClusterName}}"
60+
},
61+
{{ end }}
62+
{
5663
"name": "PATRONI_POSTGRESQL_DATA_DIR",
5764
"value": "/pgdata/{{.Name}}"
5865
}, {
@@ -133,6 +140,9 @@
133140
"ports": [{
134141
"containerPort": 5432,
135142
"protocol": "TCP"
143+
}, {
144+
"containerPort": 8009,
145+
"protocol": "TCP"
136146
}],
137147
"resources": {},
138148
"imagePullPolicy": "IfNotPresent"

conf/postgres-operator/cluster-service.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
"port": {{.ExporterPort}},
3636
"targetPort": {{.ExporterPort}},
3737
"nodePort": 0
38+
}, {
39+
"name": "patroni",
40+
"protocol": "TCP",
41+
"port": 8009,
42+
"targetPort": 8009,
43+
"nodePort": 0
3844
}
3945
],
4046
"selector": {

deploy/add-targeted-namespace.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ cat $PGOROOT/conf/postgres-operator/pgo-target-role.json | sed 's/{{.TargetNames
5151
cat $PGOROOT/conf/postgres-operator/pgo-target-role-binding.json | sed 's/{{.TargetNamespace}}/'"$1"'/' | sed 's/{{.OperatorNamespace}}/'"$PGO_OPERATOR_NAMESPACE"'/' | $PGO_CMD -n $1 create -f -
5252
cat $PGOROOT/conf/postgres-operator/pgo-backrest-role.json | sed 's/{{.TargetNamespace}}/'"$1"'/' | $PGO_CMD -n $1 create -f -
5353
cat $PGOROOT/conf/postgres-operator/pgo-backrest-role-binding.json | sed 's/{{.TargetNamespace}}/'"$1"'/' | $PGO_CMD -n $1 create -f -
54+
cat $PGOROOT/conf/postgres-operator/pgo-pg-sa.json | sed 's/{{.TargetNamespace}}/'"$1"'/' | sed 's/{{.OperatorNamespace}}/'"$PGO_OPERATOR_NAMESPACE"'/' | $PGO_CMD -n $1 create -f -
55+
cat $PGOROOT/conf/postgres-operator/pgo-pg-role.json | sed 's/{{.TargetNamespace}}/'"$1"'/' | $PGO_CMD -n $1 create -f -
56+
cat $PGOROOT/conf/postgres-operator/pgo-pg-role-binding.json | sed 's/{{.TargetNamespace}}/'"$1"'/' | $PGO_CMD -n $1 create -f -

operator/cluster/clusterlogic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ func Scale(clientset *kubernetes.Clientset, client *rest.RESTClient, replica *cr
324324
replicaDeploymentFields := operator.DeploymentTemplateFields{
325325
Name: replica.Spec.Name,
326326
ClusterName: replica.Spec.ClusterName,
327+
IsReplica: true,
327328
Port: cluster.Spec.Port,
328329
CCPImagePrefix: operator.Pgo.Cluster.CCPImagePrefix,
329330
CCPImageTag: imageTag,

operator/clusterutilities.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ type DeploymentTemplateFields struct {
125125
PrimaryHost string
126126
// PgBouncer deployment only
127127
PgbouncerPass string
128+
IsReplica bool
128129
}
129130

130131
type PostgresHaTemplateFields struct {

0 commit comments

Comments
 (0)