From c7a586d0f892cb3e8ed8c08b15f3a30506d9cef5 Mon Sep 17 00:00:00 2001
From: Polina Bungina <27892524+hughcapet@users.noreply.github.com>
Date: Mon, 10 Mar 2025 10:16:01 +0100
Subject: [PATCH] Configure (upcoming) Patroni bootstrap labels feature (#2872)

Set the value from the critical-operation-pdb's selector if PDBs are enabled
---
 pkg/cluster/k8sres.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go
index c5a58ed5..6b82efd1 100644
--- a/pkg/cluster/k8sres.go
+++ b/pkg/cluster/k8sres.go
@@ -1010,6 +1010,9 @@ func (c *Cluster) generateSpiloPodEnvVars(
 
 	if c.patroniUsesKubernetes() {
 		envVars = append(envVars, v1.EnvVar{Name: "DCS_ENABLE_KUBERNETES_API", Value: "true"})
+		if c.OpConfig.EnablePodDisruptionBudget != nil && !(*c.OpConfig.EnablePodDisruptionBudget) {
+			envVars = append(envVars, v1.EnvVar{Name: "KUBERNETES_BOOTSTRAP_LABELS", Value: "{\"critical-operation\":\"true\"}"})
+		}
 	} else {
 		envVars = append(envVars, v1.EnvVar{Name: "ETCD_HOST", Value: c.OpConfig.EtcdHost})
 	}
-- 
GitLab