mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-09-30 09:41:39 +02:00
Introduce masterServiceAnnotations & replicaServiceAnnotations (#2161)
* Introduce `masterServiceAnnotations` & `replicaServiceAnnotations` Introduce `masterServiceAnnotations` & `replicaServiceAnnotations` to the `Postgresql` CRD. `masterServiceAnnotations` overrides `serviceAnnotations` for master role if not empty. `replicaServiceAnnotations` overrides `serviceAnnotations` for replica role if not empty. Existing definition of `serviceAnnotations` continue to work for backward compatibitlity when neither `masterServiceAnnotations` nor `replicaServiceAnnotations` is defined. This closes https://github.com/zalando/postgres-operator/issues/1927 * Accumulate service annotations First, global config, then ServiceAnnotations overriding, then MasterServiceAnnotations and ReplicaServiceAnnotations. This addresses https://github.com/zalando/postgres-operator/pull/2161#discussion_r1063558711. * Update admin doc with master & replica service annotations overrides Addressed https://github.com/zalando/postgres-operator/pull/2161#discussion_r1064744086 Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
This commit is contained in:
@@ -355,6 +355,14 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||
},
|
||||
},
|
||||
},
|
||||
"masterServiceAnnotations": {
|
||||
Type: "object",
|
||||
AdditionalProperties: &apiextv1.JSONSchemaPropsOrBool{
|
||||
Schema: &apiextv1.JSONSchemaProps{
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
"nodeAffinity": {
|
||||
Type: "object",
|
||||
Properties: map[string]apiextv1.JSONSchemaProps{
|
||||
@@ -654,6 +662,14 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||
Type: "boolean",
|
||||
Description: "deprecated",
|
||||
},
|
||||
"replicaServiceAnnotations": {
|
||||
Type: "object",
|
||||
AdditionalProperties: &apiextv1.JSONSchemaPropsOrBool{
|
||||
Schema: &apiextv1.JSONSchemaProps{
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
"resources": {
|
||||
Type: "object",
|
||||
Properties: map[string]apiextv1.JSONSchemaProps{
|
||||
|
||||
@@ -79,10 +79,14 @@ type PostgresSpec struct {
|
||||
StandbyCluster *StandbyDescription `json:"standby,omitempty"`
|
||||
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
|
||||
ServiceAnnotations map[string]string `json:"serviceAnnotations,omitempty"`
|
||||
TLS *TLSDescription `json:"tls,omitempty"`
|
||||
AdditionalVolumes []AdditionalVolume `json:"additionalVolumes,omitempty"`
|
||||
Streams []Stream `json:"streams,omitempty"`
|
||||
Env []v1.EnvVar `json:"env,omitempty"`
|
||||
// MasterServiceAnnotations takes precedence over ServiceAnnotations for master role if not empty
|
||||
MasterServiceAnnotations map[string]string `json:"masterServiceAnnotations,omitempty"`
|
||||
// ReplicaServiceAnnotations takes precedence over ServiceAnnotations for replica role if not empty
|
||||
ReplicaServiceAnnotations map[string]string `json:"replicaServiceAnnotations,omitempty"`
|
||||
TLS *TLSDescription `json:"tls,omitempty"`
|
||||
AdditionalVolumes []AdditionalVolume `json:"additionalVolumes,omitempty"`
|
||||
Streams []Stream `json:"streams,omitempty"`
|
||||
Env []v1.EnvVar `json:"env,omitempty"`
|
||||
|
||||
// deprecated json tags
|
||||
InitContainersOld []v1.Container `json:"init_containers,omitempty"`
|
||||
|
||||
@@ -792,6 +792,20 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.MasterServiceAnnotations != nil {
|
||||
in, out := &in.MasterServiceAnnotations, &out.MasterServiceAnnotations
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.ReplicaServiceAnnotations != nil {
|
||||
in, out := &in.ReplicaServiceAnnotations, &out.ReplicaServiceAnnotations
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.TLS != nil {
|
||||
in, out := &in.TLS, &out.TLS
|
||||
*out = new(TLSDescription)
|
||||
|
||||
Reference in New Issue
Block a user