Skip to content

Commit 579f788

Browse files
authored
pass cluster labels as JSON to Spilo (zalando#877)
1 parent cc1ffdc commit 579f788

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/cluster/k8sres.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,6 @@ func (c *Cluster) generateSpiloPodEnvVars(uid types.UID, spiloConfiguration stri
549549
Name: "KUBERNETES_ROLE_LABEL",
550550
Value: c.OpConfig.PodRoleLabel,
551551
},
552-
{
553-
Name: "KUBERNETES_LABELS",
554-
Value: labels.Set(c.OpConfig.ClusterLabels).String(),
555-
},
556552
{
557553
Name: "PGPASSWORD_SUPERUSER",
558554
ValueFrom: &v1.EnvVarSource{
@@ -588,6 +584,12 @@ func (c *Cluster) generateSpiloPodEnvVars(uid types.UID, spiloConfiguration stri
588584
Value: c.OpConfig.PamRoleName,
589585
},
590586
}
587+
// Spilo expects cluster labels as JSON
588+
if clusterLabels, err := json.Marshal(labels.Set(c.OpConfig.ClusterLabels)); err != nil {
589+
envVars = append(envVars, v1.EnvVar{Name: "KUBERNETES_LABELS", Value: labels.Set(c.OpConfig.ClusterLabels).String()})
590+
} else {
591+
envVars = append(envVars, v1.EnvVar{Name: "KUBERNETES_LABELS", Value: string(clusterLabels)})
592+
}
591593
if spiloConfiguration != "" {
592594
envVars = append(envVars, v1.EnvVar{Name: "SPILO_CONFIGURATION", Value: spiloConfiguration})
593595
}

0 commit comments

Comments
 (0)