define new variables

This commit is contained in:
inovindasari 2024-11-25 14:49:24 +01:00
parent 766597980f
commit 8b79e33b1c
11 changed files with 45 additions and 3 deletions

View File

@ -327,6 +327,12 @@ spec:
pod_role_label: pod_role_label:
type: string type: string
default: "spilo-role" default: "spilo-role"
pod_leader_label_value:
type: string
default: "master"
pod_standby_leader_label_value:
type: string
default: "master"
pod_service_account_definition: pod_service_account_definition:
type: string type: string
default: "" default: ""

View File

@ -194,6 +194,8 @@ configKubernetes:
pod_management_policy: "ordered_ready" pod_management_policy: "ordered_ready"
# label assigned to the Postgres pods (and services/endpoints) # label assigned to the Postgres pods (and services/endpoints)
pod_role_label: spilo-role pod_role_label: spilo-role
pod_leader_label_value: master
pod_standby_leader_label_value: master
# service account definition as JSON/YAML string to be used by postgres cluster pods # service account definition as JSON/YAML string to be used by postgres cluster pods
# pod_service_account_definition: "" # pod_service_account_definition: ""

View File

@ -437,6 +437,14 @@ configuration they are grouped under the `kubernetes` key.
name of the label assigned to the Postgres pods (and services/endpoints) by name of the label assigned to the Postgres pods (and services/endpoints) by
the operator. The default is `spilo-role`. the operator. The default is `spilo-role`.
* **pod_leader_label_value**
value of the pod label if Postgres role is primary when running on Kubernetes.
The default is 'master'.
* **pod_standby_leader_label_value**
value of the pod label if Postgres role is standby_leader when running on Kubernetes.
The default is 'master'.
* **cluster_labels** * **cluster_labels**
list of `name:value` pairs for additional labels assigned to the cluster list of `name:value` pairs for additional labels assigned to the cluster
objects. The default is `application:spilo`. objects. The default is `application:spilo`.

View File

@ -12,9 +12,9 @@ from kubernetes import client
from tests.k8s_api import K8s from tests.k8s_api import K8s
from kubernetes.client.rest import ApiException from kubernetes.client.rest import ApiException
SPILO_CURRENT = "container-registry-test.zalando.net/acid/spilo-cdp-pr1050-16:4.0-p4" SPILO_CURRENT = "registry.opensource.zalan.do/acid/spilo-16-e2e:0.1"
SPILO_LAZY = "registry.opensource.zalan.do/acid/spilo-16-e2e:0.2" SPILO_LAZY = "registry.opensource.zalan.do/acid/spilo-16-e2e:0.2"
SPILO_FULL_IMAGE = "container-registry-test.zalando.net/acid/spilo-cdp-pr1050-16:4.0-p4" SPILO_FULL_IMAGE = "ghcr.io/zalando/spilo-16:3.2-p3"
def to_selector(labels): def to_selector(labels):

View File

@ -135,7 +135,7 @@ data:
# pod_priority_class_name: "postgres-pod-priority" # pod_priority_class_name: "postgres-pod-priority"
pod_role_label: spilo-role pod_role_label: spilo-role
pod_leader_label_value: master pod_leader_label_value: master
pod_standby_leader_label_value: standby_leader pod_standby_leader_label_value: master
pod_service_account_definition: "" pod_service_account_definition: ""
pod_service_account_name: "postgres-pod" pod_service_account_name: "postgres-pod"
pod_service_account_role_binding_definition: "" pod_service_account_role_binding_definition: ""

View File

@ -325,6 +325,12 @@ spec:
pod_role_label: pod_role_label:
type: string type: string
default: "spilo-role" default: "spilo-role"
pod_leader_label_value:
type: string
default: "master"
pod_standby_leader_label_value:
type: string
default: "master"
pod_service_account_definition: pod_service_account_definition:
type: string type: string
default: "" default: ""

View File

@ -99,6 +99,8 @@ configuration:
pod_management_policy: "ordered_ready" pod_management_policy: "ordered_ready"
# pod_priority_class_name: "postgres-pod-priority" # pod_priority_class_name: "postgres-pod-priority"
pod_role_label: spilo-role pod_role_label: spilo-role
pod_leader_label_value: master
pod_standby_leader_label_value: master
# pod_service_account_definition: "" # pod_service_account_definition: ""
pod_service_account_name: postgres-pod pod_service_account_name: postgres-pod
# pod_service_account_role_binding_definition: "" # pod_service_account_role_binding_definition: ""

View File

@ -1497,6 +1497,12 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
"pod_role_label": { "pod_role_label": {
Type: "string", Type: "string",
}, },
"pod_leader_label_value": {
Type: "string",
},
"pod_standby_leader_label_value": {
Type: "string",
},
"pod_service_account_definition": { "pod_service_account_definition": {
Type: "string", Type: "string",
}, },

View File

@ -81,6 +81,8 @@ type KubernetesMetaConfiguration struct {
InfrastructureRolesSecretName spec.NamespacedName `json:"infrastructure_roles_secret_name,omitempty"` InfrastructureRolesSecretName spec.NamespacedName `json:"infrastructure_roles_secret_name,omitempty"`
InfrastructureRolesDefs []*config.InfrastructureRole `json:"infrastructure_roles_secrets,omitempty"` InfrastructureRolesDefs []*config.InfrastructureRole `json:"infrastructure_roles_secrets,omitempty"`
PodRoleLabel string `json:"pod_role_label,omitempty"` PodRoleLabel string `json:"pod_role_label,omitempty"`
PodLeaderLabelValue string `json:"pod_leader_label_value,omitempty"`
PodStandbyLeaderLabelValue string `json:"pod_standby_leader_label_value,omitempty"`
ClusterLabels map[string]string `json:"cluster_labels,omitempty"` ClusterLabels map[string]string `json:"cluster_labels,omitempty"`
InheritedLabels []string `json:"inherited_labels,omitempty"` InheritedLabels []string `json:"inherited_labels,omitempty"`
InheritedAnnotations []string `json:"inherited_annotations,omitempty"` InheritedAnnotations []string `json:"inherited_annotations,omitempty"`

View File

@ -950,6 +950,14 @@ func (c *Cluster) generateSpiloPodEnvVars(
Name: "KUBERNETES_ROLE_LABEL", Name: "KUBERNETES_ROLE_LABEL",
Value: c.OpConfig.PodRoleLabel, Value: c.OpConfig.PodRoleLabel,
}, },
{
Name: "KUBERNETES_LEADER_LABEL_VALUE",
Value: c.OpConfig.PodLeaderLabelValue,
},
{
Name: "KUBERNETES_STANDBY_LEADER_LABEL_VALUE",
Value: c.OpConfig.PodStandbyLeaderLabelValue,
}
{ {
Name: "PGPASSWORD_SUPERUSER", Name: "PGPASSWORD_SUPERUSER",
ValueFrom: &v1.EnvVarSource{ ValueFrom: &v1.EnvVarSource{

View File

@ -48,6 +48,8 @@ type Resources struct {
DeleteAnnotationDateKey string `name:"delete_annotation_date_key"` DeleteAnnotationDateKey string `name:"delete_annotation_date_key"`
DeleteAnnotationNameKey string `name:"delete_annotation_name_key"` DeleteAnnotationNameKey string `name:"delete_annotation_name_key"`
PodRoleLabel string `name:"pod_role_label" default:"spilo-role"` PodRoleLabel string `name:"pod_role_label" default:"spilo-role"`
PodLeaderLabelValue string `name:"pod_leader_label_value" default:"master"`
PodStandbyLeaderLabelValue string `name:"pod_standby_leader_label_value" default:"master"`
PodToleration map[string]string `name:"toleration" default:""` PodToleration map[string]string `name:"toleration" default:""`
DefaultCPURequest string `name:"default_cpu_request"` DefaultCPURequest string `name:"default_cpu_request"`
DefaultMemoryRequest string `name:"default_memory_request"` DefaultMemoryRequest string `name:"default_memory_request"`