Skip to content

Commit 52de8fd

Browse files
author
jmccormick2001
committed
update collect label logic to apply collect label to the pod which is used for the sample prometheus scrape config, also added collect ports to the deployment service by default
1 parent 64d28e8 commit 52de8fd

File tree

6 files changed

+30
-14
lines changed

6 files changed

+30
-14
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,14 @@ func CreateCluster(request *msgs.CreateClusterRequest) msgs.CreateClusterRespons
512512
}
513513

514514
//set the metrics flag with the global setting first
515-
userLabelsMap["crunchy-collect"] = strconv.FormatBool(apiserver.MetricsFlag)
515+
userLabelsMap["crunchy_collect"] = strconv.FormatBool(apiserver.MetricsFlag)
516516
if err != nil {
517517
log.Error(err)
518518
}
519519

520520
//if metrics is chosen on the pgo command, stick it into the user labels
521521
if request.MetricsFlag {
522-
userLabelsMap["crunchy-collect"] = "true"
522+
userLabelsMap["crunchy_collect"] = "true"
523523
}
524524

525525
if request.PgpoolFlag {

conf/apiserver/pgo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Cluster:
22
CCPImagePrefix: crunchydata
3-
CCPImageTag: centos7-10.3-1.8.1
3+
CCPImageTag: centos7-10.3-1.8.2
44
Port: 5432
55
User: testuser
66
Database: userdb

conf/postgres-operator/cluster/1/cluster-deployment-1.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"labels": {
1515
"name": "{{.Name}}",
1616
"primary": "true",
17-
"pg-cluster": "{{.ClusterName}}"
17+
"pg-cluster": "{{.ClusterName}}",
18+
{{.OperatorLabels }}
1819
}
1920
},
2021
"spec": {

conf/postgres-operator/cluster/1/cluster-service-1.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,27 @@
99
}
1010
},
1111
"spec": {
12-
"ports": [{
12+
"ports": [
13+
{
14+
"name": "postgres",
1315
"protocol": "TCP",
1416
"port": {{.Port}},
1517
"targetPort": {{.Port}},
1618
"nodePort": 0
17-
}],
19+
}, {
20+
"name": "node-exporter",
21+
"protocol": "TCP",
22+
"port": 9100,
23+
"targetPort": 9100,
24+
"nodePort": 0
25+
}, {
26+
"name": "postgres-exporter",
27+
"protocol": "TCP",
28+
"port": 9187,
29+
"targetPort": 9187,
30+
"nodePort": 0
31+
}
32+
],
1833
"selector": {
1934
"name": "{{.Name}}"
2035
},

conf/postgres-operator/cluster/1/collect.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
}],
1111
"env": [{
1212
"name": "DATA_SOURCE_NAME",
13-
"value": "postgresql://primaryuser:password@127.0.0.1:5432/postgres?sslmode=disable"
13+
"value": "postgresql://primaryuser:{{.PrimaryPassword}}@127.0.0.1:5432/postgres?sslmode=disable"
1414
}]
1515
},

operator/cluster/cluster_strategy_1.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ type containerResourcesTemplateFields struct {
5151
}
5252

5353
type collectTemplateFields struct {
54-
Name string
55-
CCPImageTag string
56-
CCPImagePrefix string
54+
Name string
55+
PrimaryPassword string
56+
CCPImageTag string
57+
CCPImagePrefix string
5758
}
5859

5960
// Strategy1 ...
@@ -103,8 +104,6 @@ func (r Strategy1) AddCluster(clientset *kubernetes.Clientset, client *rest.REST
103104

104105
primaryLabels := getPrimaryLabels(cl.Spec.Name, cl.Spec.ClusterName, false, cl.Spec.UserLabels)
105106

106-
log.Debug("CCPImagePrefix before create cluster " + operator.CCPImagePrefix)
107-
108107
//create the primary deployment
109108
deploymentFields := DeploymentTemplateFields{
110109
Name: cl.Spec.Name,
@@ -468,10 +467,11 @@ func GetAffinity(nodeLabelKey, nodeLabelValue string, operator string) string {
468467

469468
func GetCollectAddon(spec *crv1.PgclusterSpec) string {
470469

471-
if spec.UserLabels["crunchy-collect"] == "true" {
472-
log.Debug("crunchy-collect was found as a label on cluster create")
470+
if spec.UserLabels["crunchy_collect"] == "true" {
471+
log.Debug("crunchy_collect was found as a label on cluster create")
473472
collectTemplateFields := collectTemplateFields{}
474473
collectTemplateFields.Name = spec.Name
474+
collectTemplateFields.PrimaryPassword = spec.PrimaryPassword
475475
collectTemplateFields.CCPImageTag = spec.CCPImageTag
476476
collectTemplateFields.CCPImagePrefix = operator.CCPImagePrefix
477477

0 commit comments

Comments
 (0)