diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 073ab1f7369fdcbef0c9d80f3629022e0d55c534..d996a473cd0df8bb0e41f2e3029ba8bd8b50d525 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -38,5 +38,6 @@ data: cluster_history_entries: "1000" pod_terminate_grace_period: 5m pdb_name_format: "postgres-{cluster}-pdb" - eol_node_label: "eol:true" + node_eol_label: "lifecycle-status:pending-decommission" + node_readiness_label: "lifecycle-status:ready" team_api_role_configuration: "log_statement:all" diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 0f0e5cd06278b3da14f078aec493bd74df45ee65..2170bea16e3740fda0284de1806ace96685c14f0 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -238,10 +238,10 @@ PatroniInitDBParams: func (c *Cluster) nodeAffinity() *v1.Affinity { matchExpressions := make([]v1.NodeSelectorRequirement, 0) - for k, v := range c.OpConfig.EOLNodeLabel { + for k, v := range c.OpConfig.NodeReadinessLabel { matchExpressions = append(matchExpressions, v1.NodeSelectorRequirement{ Key: k, - Operator: v1.NodeSelectorOpNotIn, + Operator: v1.NodeSelectorOpIn, Values: []string{v}, }) } diff --git a/pkg/cluster/pod.go b/pkg/cluster/pod.go index 5f458db9cf8b78749e14630e24142bac32dd98db..44af662cb32f8da7e1e47e33966c0112c695a9b1 100644 --- a/pkg/cluster/pod.go +++ b/pkg/cluster/pod.go @@ -319,6 +319,6 @@ func (c *Cluster) podIsEndOfLife(pod *v1.Pod) (bool, error) { if err != nil { return false, err } - return node.Spec.Unschedulable || util.MapContains(node.Labels, c.OpConfig.EOLNodeLabel), nil + return node.Spec.Unschedulable || util.MapContains(node.Labels, c.OpConfig.NodeEOLLabel), nil } diff --git a/pkg/controller/node.go b/pkg/controller/node.go index abe74da05c8aef1c4f4a35c2c7acef699733a9e5..524b3ce3083ca8b4c874a3933f091d0a4f3d5a24 100644 --- a/pkg/controller/node.go +++ b/pkg/controller/node.go @@ -55,13 +55,13 @@ func (c *Controller) nodeUpdate(prev, cur interface{}) { return } - if nodePrev.Spec.Unschedulable && util.MapContains(nodePrev.Labels, c.opConfig.EOLNodeLabel) || - !nodeCur.Spec.Unschedulable || !util.MapContains(nodeCur.Labels, c.opConfig.EOLNodeLabel) { + if nodePrev.Spec.Unschedulable && util.MapContains(nodePrev.Labels, c.opConfig.NodeEOLLabel) || + !nodeCur.Spec.Unschedulable || !util.MapContains(nodeCur.Labels, c.opConfig.NodeEOLLabel) { return } c.logger.Infof("node %q became unschedulable and has EOL labels: %q", util.NameFromMeta(nodeCur.ObjectMeta), - c.opConfig.EOLNodeLabel) + c.opConfig.NodeEOLLabel) opts := metav1.ListOptions{ LabelSelector: labels.Set(c.opConfig.ClusterLabels).String(), diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index db98d5c2b6b65ab2944cacf2d41fb619a843aba1..c92b9d35b45c108b2613f24401bc38716dac3999 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -30,7 +30,8 @@ type Resources struct { DefaultMemoryRequest string `name:"default_memory_request" default:"100Mi"` DefaultCPULimit string `name:"default_cpu_limit" default:"3"` DefaultMemoryLimit string `name:"default_memory_limit" default:"1Gi"` - EOLNodeLabel map[string]string `name:"eol_node_label" default:"eol:true"` + NodeEOLLabel map[string]string `name:"node_eol_label" default:"lifecycle-status:pending-decommission"` + NodeReadinessLabel map[string]string `name:"node_readiness_label" default:"lifecycle-status:ready"` } // Auth describes authentication specific configuration parameters