diff --git a/apis/apps/v1alpha1/apimanager_types.go b/apis/apps/v1alpha1/apimanager_types.go index dd1a86340..e7e5d1096 100644 --- a/apis/apps/v1alpha1/apimanager_types.go +++ b/apis/apps/v1alpha1/apimanager_types.go @@ -269,6 +269,8 @@ type ApicastProductionSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type ApicastStagingSpec struct { @@ -333,6 +335,8 @@ type ApicastStagingSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type BackendSpec struct { @@ -354,6 +358,8 @@ type BackendSpec struct { RedisTopologySpreadConstraints []v1.TopologySpreadConstraint `json:"redisTopologySpreadConstraints,omitempty"` // +optional RedisLabels map[string]string `json:"redisLabels,omitempty"` + // +optional + RedisAnnotations map[string]string `json:"redisAnnotations,omitempty"` // +optional ListenerSpec *BackendListenerSpec `json:"listenerSpec,omitempty"` @@ -383,6 +389,8 @@ type BackendListenerSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type BackendWorkerSpec struct { @@ -400,6 +408,8 @@ type BackendWorkerSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type BackendCronSpec struct { @@ -417,6 +427,8 @@ type BackendCronSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type SystemSpec struct { @@ -438,6 +450,8 @@ type SystemSpec struct { MemcachedTopologySpreadConstraints []v1.TopologySpreadConstraint `json:"memcachedTopologySpreadConstraints,omitempty"` // +optional MemcachedLabels map[string]string `json:"memcachedLabels,omitempty"` + // +optional + MemcachedAnnotations map[string]string `json:"memcachedAnnotations,omitempty"` // +optional RedisImage *string `json:"redisImage,omitempty"` @@ -455,6 +469,8 @@ type SystemSpec struct { RedisTopologySpreadConstraints []v1.TopologySpreadConstraint `json:"redisTopologySpreadConstraints,omitempty"` // +optional RedisLabels map[string]string `json:"redisLabels,omitempty"` + // +optional + RedisAnnotations map[string]string `json:"redisAnnotations,omitempty"` // TODO should this field be optional? We have different approaches in Kubernetes. // For example, in v1.Volume it is optional and there's an implied behaviour @@ -503,6 +519,8 @@ type SystemAppSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type SystemSidekiqSpec struct { @@ -520,6 +538,8 @@ type SystemSidekiqSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type SystemSearchdSpec struct { @@ -539,6 +559,8 @@ type SystemSearchdSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type SystemSphinxSpec struct { @@ -633,6 +655,8 @@ type SystemMySQLSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type SystemPostgreSQLSpec struct { @@ -653,6 +677,8 @@ type SystemPostgreSQLSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type ZyncSpec struct { @@ -680,6 +706,8 @@ type ZyncSpec struct { DatabaseTopologySpreadConstraints []v1.TopologySpreadConstraint `json:"databaseTopologySpreadConstraints,omitempty"` // +optional DatabaseLabels map[string]string `json:"databaseLabels,omitempty"` + // +optional + DatabaseAnnotations map[string]string `json:"databaseAnnotations,omitempty"` } type ZyncAppSpec struct { @@ -697,6 +725,8 @@ type ZyncAppSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type ZyncQueSpec struct { @@ -714,6 +744,8 @@ type ZyncQueSpec struct { TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` // +optional Labels map[string]string `json:"labels,omitempty"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } type HighAvailabilitySpec struct { diff --git a/apis/apps/v1alpha1/zz_generated.deepcopy.go b/apis/apps/v1alpha1/zz_generated.deepcopy.go index 10147c719..69657e288 100644 --- a/apis/apps/v1alpha1/zz_generated.deepcopy.go +++ b/apis/apps/v1alpha1/zz_generated.deepcopy.go @@ -619,6 +619,13 @@ func (in *ApicastProductionSpec) DeepCopyInto(out *ApicastProductionSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApicastProductionSpec. @@ -789,6 +796,13 @@ func (in *ApicastStagingSpec) DeepCopyInto(out *ApicastStagingSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApicastStagingSpec. @@ -845,6 +859,13 @@ func (in *BackendCronSpec) DeepCopyInto(out *BackendCronSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendCronSpec. @@ -901,6 +922,13 @@ func (in *BackendListenerSpec) DeepCopyInto(out *BackendListenerSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendListenerSpec. @@ -987,6 +1015,13 @@ func (in *BackendSpec) DeepCopyInto(out *BackendSpec) { (*out)[key] = val } } + if in.RedisAnnotations != nil { + in, out := &in.RedisAnnotations, &out.RedisAnnotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.ListenerSpec != nil { in, out := &in.ListenerSpec, &out.ListenerSpec *out = new(BackendListenerSpec) @@ -1058,6 +1093,13 @@ func (in *BackendWorkerSpec) DeepCopyInto(out *BackendWorkerSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendWorkerSpec. @@ -1447,6 +1489,13 @@ func (in *SystemAppSpec) DeepCopyInto(out *SystemAppSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemAppSpec. @@ -1563,6 +1612,13 @@ func (in *SystemMySQLSpec) DeepCopyInto(out *SystemMySQLSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemMySQLSpec. @@ -1624,6 +1680,13 @@ func (in *SystemPostgreSQLSpec) DeepCopyInto(out *SystemPostgreSQLSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemPostgreSQLSpec. @@ -1726,6 +1789,13 @@ func (in *SystemSearchdSpec) DeepCopyInto(out *SystemSearchdSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemSearchdSpec. @@ -1782,6 +1852,13 @@ func (in *SystemSidekiqSpec) DeepCopyInto(out *SystemSidekiqSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SystemSidekiqSpec. @@ -1843,6 +1920,13 @@ func (in *SystemSpec) DeepCopyInto(out *SystemSpec) { (*out)[key] = val } } + if in.MemcachedAnnotations != nil { + in, out := &in.MemcachedAnnotations, &out.MemcachedAnnotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.RedisImage != nil { in, out := &in.RedisImage, &out.RedisImage *out = new(string) @@ -1889,6 +1973,13 @@ func (in *SystemSpec) DeepCopyInto(out *SystemSpec) { (*out)[key] = val } } + if in.RedisAnnotations != nil { + in, out := &in.RedisAnnotations, &out.RedisAnnotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } if in.FileStorageSpec != nil { in, out := &in.FileStorageSpec, &out.FileStorageSpec *out = new(SystemFileStorageSpec) @@ -2019,6 +2110,13 @@ func (in *ZyncAppSpec) DeepCopyInto(out *ZyncAppSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZyncAppSpec. @@ -2075,6 +2173,13 @@ func (in *ZyncQueSpec) DeepCopyInto(out *ZyncQueSpec) { (*out)[key] = val } } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZyncQueSpec. @@ -2146,6 +2251,13 @@ func (in *ZyncSpec) DeepCopyInto(out *ZyncSpec) { (*out)[key] = val } } + if in.DatabaseAnnotations != nil { + in, out := &in.DatabaseAnnotations, &out.DatabaseAnnotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZyncSpec. diff --git a/bundle/manifests/apps.3scale.net_apimanagers.yaml b/bundle/manifests/apps.3scale.net_apimanagers.yaml index a215dd058..3ee28917f 100644 --- a/bundle/manifests/apps.3scale.net_apimanagers.yaml +++ b/bundle/manifests/apps.3scale.net_apimanagers.yaml @@ -517,6 +517,10 @@ spec: allProxy: description: AllProxy specifies a HTTP(S) proxy to be used for connecting to services if a protocol-specific proxy is not specified. Authentication is not supported. Format is ://: type: string + annotations: + additionalProperties: + type: string + type: object customEnvironments: description: CustomEnvironments specifies an array of defined custom environments to be loaded items: @@ -1212,6 +1216,10 @@ spec: allProxy: description: AllProxy specifies a HTTP(S) proxy to be used for connecting to services if a protocol-specific proxy is not specified. Authentication is not supported. Format is ://: type: string + annotations: + additionalProperties: + type: string + type: object customEnvironments: description: CustomEnvironments specifies an array of defined custom environments to be loaded items: @@ -1901,6 +1909,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -2486,6 +2498,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -3067,6 +3083,10 @@ spec: type: array type: object type: object + redisAnnotations: + additionalProperties: + type: string + type: object redisImage: type: string redisLabels: @@ -3653,6 +3673,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -4292,6 +4316,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object developerContainerResources: description: ResourceRequirements describes the compute resource requirements. properties: @@ -4922,6 +4950,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object image: type: string labels: @@ -5525,6 +5557,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object image: type: string labels: @@ -6199,6 +6235,10 @@ spec: type: array type: object type: object + memcachedAnnotations: + additionalProperties: + type: string + type: object memcachedImage: type: string memcachedLabels: @@ -6778,6 +6818,10 @@ spec: type: array type: object type: object + redisAnnotations: + additionalProperties: + type: string + type: object redisImage: type: string redisLabels: @@ -7364,6 +7408,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object image: type: string labels: @@ -7967,6 +8015,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -9135,6 +9187,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -9716,6 +9772,10 @@ spec: type: array type: object type: object + databaseAnnotations: + additionalProperties: + type: string + type: object databaseLabels: additionalProperties: type: string @@ -10299,6 +10359,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string diff --git a/config/crd/bases/apps.3scale.net_apimanagers.yaml b/config/crd/bases/apps.3scale.net_apimanagers.yaml index f2d614190..a432ba577 100644 --- a/config/crd/bases/apps.3scale.net_apimanagers.yaml +++ b/config/crd/bases/apps.3scale.net_apimanagers.yaml @@ -953,6 +953,10 @@ spec: is not specified. Authentication is not supported. Format is ://: type: string + annotations: + additionalProperties: + type: string + type: object customEnvironments: description: CustomEnvironments specifies an array of defined custom environments to be loaded @@ -2233,6 +2237,10 @@ spec: is not specified. Authentication is not supported. Format is ://: type: string + annotations: + additionalProperties: + type: string + type: object customEnvironments: description: CustomEnvironments specifies an array of defined custom environments to be loaded @@ -3504,6 +3512,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -4633,6 +4645,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -5724,6 +5740,10 @@ spec: type: array type: object type: object + redisAnnotations: + additionalProperties: + type: string + type: object redisImage: type: string redisLabels: @@ -6846,6 +6866,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -8031,6 +8055,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object developerContainerResources: description: ResourceRequirements describes the compute resource requirements. @@ -9278,6 +9306,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object image: type: string labels: @@ -10503,6 +10535,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object image: type: string labels: @@ -11716,6 +11752,10 @@ spec: type: array type: object type: object + memcachedAnnotations: + additionalProperties: + type: string + type: object memcachedImage: type: string memcachedLabels: @@ -12797,6 +12837,10 @@ spec: type: array type: object type: object + redisAnnotations: + additionalProperties: + type: string + type: object redisImage: type: string redisLabels: @@ -13919,6 +13963,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object image: type: string labels: @@ -15071,6 +15119,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -17327,6 +17379,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string @@ -18418,6 +18474,10 @@ spec: type: array type: object type: object + databaseAnnotations: + additionalProperties: + type: string + type: object databaseLabels: additionalProperties: type: string @@ -19537,6 +19597,10 @@ spec: type: array type: object type: object + annotations: + additionalProperties: + type: string + type: object labels: additionalProperties: type: string diff --git a/doc/apimanager-reference.md b/doc/apimanager-reference.md index 82222c617..67473d958 100644 --- a/doc/apimanager-reference.md +++ b/doc/apimanager-reference.md @@ -143,6 +143,7 @@ One APIManager custom resource per project is allowed. | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### ApicastStagingSpec @@ -168,6 +169,7 @@ One APIManager custom resource per project is allowed. | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### CustomPolicySpec @@ -244,6 +246,7 @@ Some examples are available [here](/doc/adding-apicast-custom-environments.md) | RedisPriorityClassName | `redisPriorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | RedisTopologySpreadConstraints | `redisTopologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | RedisLabels | `redisLabels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| RedisAnnotations | `redisAnnotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### BackendRedisPersistentVolumeClaimSpec @@ -262,6 +265,7 @@ Some examples are available [here](/doc/adding-apicast-custom-environments.md) | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### BackendWorkerSpec @@ -274,6 +278,7 @@ Some examples are available [here](/doc/adding-apicast-custom-environments.md) | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### BackendCronSpec @@ -286,7 +291,7 @@ Some examples are available [here](/doc/adding-apicast-custom-environments.md) | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | - +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### SystemSpec @@ -314,6 +319,7 @@ Some examples are available [here](/doc/adding-apicast-custom-environments.md) | RedisPriorityClassName | `redisPriorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | RedisTopologySpreadConstraints | `redisTopologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | RedisLabels | `redisLabels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| RedisAnnotations | `redisAnnotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### SystemRedisPersistentVolumeClaimSpec @@ -391,6 +397,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### SystemMySQLPVCSpec @@ -412,6 +419,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### SystemPostgreSQLPVCSpec @@ -435,6 +443,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### SystemSidekiqSpec @@ -447,6 +456,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### SystemSphinxSpec @@ -470,6 +480,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### PVCGenericSpec @@ -491,9 +502,10 @@ Note: Deploying databases internally with this section is meant for evaluation p | DatabaseAffinity | `databaseAffinity` | [v1.Affinity](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#affinity-v1-core) | No | `nil` | Affinity is a group of affinity scheduling rules. Does not take effect when the database is managed externally | | DatabaseTolerations | `databaseTolerations` | \[\][v1.Tolerations](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#toleration-v1-core) | No | `nil` | Tolerations allow pods to schedule onto nodes with matching taints. Does not take effect when the database is managed externally | | DatabaseResources | `databaseResources` | [v1.ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#resourcerequirements-v1-core) | No | `nil` | DatabaseResources describes the compute resource requirements. Takes precedence over `spec.resourceRequirementsEnabled` with replace behavior. Does not take effect when the database is managed externally | -| PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | -| TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | +| DatabasePriorityClassName | `databasePriorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | +| DatabaseTopologySpreadConstraints | `databaseTopologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | DatabaseLabels | `databaseLabels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| DatabaseAnnotations | `databaseAnnotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### ZyncAppSpec @@ -506,6 +518,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### ZyncQueSpec @@ -518,6 +531,7 @@ Note: Deploying databases internally with this section is meant for evaluation p | PriorityClassName | `priorityClassName` | string | No | N/A | If specified, indicates the pod's priority. "system-node-critical" and "system-cluster-critical" are two special keywords which indicate the highest priorities with the former being the highest priority. Any other name must be defined by creating a PriorityClass object with that name. If not specified, the pod priority will be default or zero if there is no default. (see [docs](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/)) | | TopologySpreadConstraints | `topologySpreadConstraints` | \[\][v1.TopologySpreadConstraint](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.25/#topologyspreadconstraint-v1-core) | No | `nil` | Specifies how to spread matching pods among the given topology | | Labels | `labels` | map[string]string | No | `nil ` | Specifies labels that should be added to component | +| Annotations | `annotations` | map[string]string | No | `nil ` | Specifies Annotations that should be added to component | ### HighAvailabilitySpec diff --git a/doc/operator-user-guide.md b/doc/operator-user-guide.md index 34a827d9b..9a2cb8ad7 100644 --- a/doc/operator-user-guide.md +++ b/doc/operator-user-guide.md @@ -21,6 +21,7 @@ * [Setting custom PriorityClassName](#setting-custom-priorityclassname) * [Setting custom TopologySpreadConstraints](#setting-custom-topologyspreadconstraints) * [Setting custom labels](#setting-custom-labels) + * [Setting custom Annotations](#setting-custom-annotations) * [Reconciliation](#reconciliation) * [Resources](#resources) * [Backend replicas](#backend-replicas) @@ -792,6 +793,28 @@ Example for apicast-staging and backend-listener: ``` +#### Setting custom Annotations + +3scale components pods can have Annotations - key/value pairs. See [here](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/) +for more information. Annotations can be customized via APIManager CR for any 3scale component. +Example for apicast-staging and backend-listener: +```yaml +apiVersion: apps.3scale.net/v1alpha1 +kind: APIManager +metadata: + name: example-apimanager +spec: + wildcardDomain: example.com + apicast: + stagingSpec: + annotations: + anno-sample1: anno1 + backend: + listenerSpec: + annotations: + anno-sample2: anno2 +``` + ### Reconciliation After 3scale API Management solution has been installed, 3scale Operator enables updating a given set diff --git a/pkg/3scale/amp/component/apicast.go b/pkg/3scale/amp/component/apicast.go index 3b0290040..70f104a0b 100644 --- a/pkg/3scale/amp/component/apicast.go +++ b/pkg/3scale/amp/component/apicast.go @@ -135,7 +135,7 @@ func (apicast *Apicast) StagingDeploymentConfig() *appsv1.DeploymentConfig { Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: apicast.Options.StagingPodTemplateLabels, - Annotations: apicast.podAnnotations(), + Annotations: apicast.stagingPodAnnotations(), }, Spec: v1.PodSpec{ Affinity: apicast.Options.StagingAffinity, @@ -230,7 +230,7 @@ func (apicast *Apicast) ProductionDeploymentConfig() *appsv1.DeploymentConfig { Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: apicast.Options.ProductionPodTemplateLabels, - Annotations: apicast.podAnnotations(), + Annotations: apicast.productionPodAnnotations(), }, Spec: v1.PodSpec{ Affinity: apicast.Options.ProductionAffinity, @@ -820,7 +820,7 @@ func (apicast *Apicast) stagingServicePorts() []v1.ServicePort { return ports } -func (apicast *Apicast) podAnnotations() map[string]string { +func (apicast *Apicast) stagingPodAnnotations() map[string]string { annotations := map[string]string{ "prometheus.io/scrape": "true", "prometheus.io/port": "9421", @@ -830,6 +830,27 @@ func (apicast *Apicast) podAnnotations() map[string]string { annotations[key] = val } + for key, val := range apicast.Options.StagingPodTemplateAnnotations { + annotations[key] = val + } + + return annotations +} + +func (apicast *Apicast) productionPodAnnotations() map[string]string { + annotations := map[string]string{ + "prometheus.io/scrape": "true", + "prometheus.io/port": "9421", + } + + for key, val := range apicast.Options.AdditionalPodAnnotations { + annotations[key] = val + } + + for key, val := range apicast.Options.ProductionPodTemplateAnnotations { + annotations[key] = val + } + return annotations } diff --git a/pkg/3scale/amp/component/apicast_options.go b/pkg/3scale/amp/component/apicast_options.go index b8267fe0d..54b120e22 100644 --- a/pkg/3scale/amp/component/apicast_options.go +++ b/pkg/3scale/amp/component/apicast_options.go @@ -82,6 +82,8 @@ type ApicastOptions struct { PriorityClassNameProduction string `validate:"-"` TopologySpreadConstraintsStaging []v1.TopologySpreadConstraint `validate:"-"` TopologySpreadConstraintsProduction []v1.TopologySpreadConstraint `validate:"-"` + StagingPodTemplateAnnotations map[string]string `validate:"-"` + ProductionPodTemplateAnnotations map[string]string `validate:"-"` // Used for monitoring objects // Those objects are namespaced. However, objects includes labels, rules and expressions diff --git a/pkg/3scale/amp/component/backend.go b/pkg/3scale/amp/component/backend.go index bdc679cf1..8e14eb209 100644 --- a/pkg/3scale/amp/component/backend.go +++ b/pkg/3scale/amp/component/backend.go @@ -102,7 +102,8 @@ func (backend *Backend) WorkerDeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": BackendWorkerName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: backend.Options.WorkerPodTemplateLabels, + Labels: backend.Options.WorkerPodTemplateLabels, + Annotations: backend.Options.WorkerPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: backend.Options.WorkerAffinity, @@ -179,7 +180,8 @@ func (backend *Backend) CronDeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": BackendCronName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: backend.Options.CronPodTemplateLabels, + Labels: backend.Options.CronPodTemplateLabels, + Annotations: backend.Options.CronPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: backend.Options.CronAffinity, @@ -256,7 +258,8 @@ func (backend *Backend) ListenerDeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": BackendListenerName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: backend.Options.ListenerPodTemplateLabels, + Labels: backend.Options.ListenerPodTemplateLabels, + Annotations: backend.Options.ListenerPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: backend.Options.ListenerAffinity, diff --git a/pkg/3scale/amp/component/backend_options.go b/pkg/3scale/amp/component/backend_options.go index f01eb7b07..21b23ab03 100644 --- a/pkg/3scale/amp/component/backend_options.go +++ b/pkg/3scale/amp/component/backend_options.go @@ -45,6 +45,10 @@ type BackendOptions struct { TopologySpreadConstraintsWorker []v1.TopologySpreadConstraint `validate:"-"` TopologySpreadConstraintsCron []v1.TopologySpreadConstraint `validate:"-"` + ListenerPodTemplateAnnotations map[string]string `validate:"-"` + WorkerPodTemplateAnnotations map[string]string `validate:"-"` + CronPodTemplateAnnotations map[string]string `validate:"-"` + // Used for monitoring objects // Those objects are namespaced. However, objects includes labels, rules and expressions // that need namespace filtering because they are "global" once imported diff --git a/pkg/3scale/amp/component/memcached.go b/pkg/3scale/amp/component/memcached.go index a30309c6b..7070da9fa 100644 --- a/pkg/3scale/amp/component/memcached.go +++ b/pkg/3scale/amp/component/memcached.go @@ -68,7 +68,8 @@ func (m *Memcached) DeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": SystemMemcachedDeploymentName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: m.Options.PodTemplateLabels, + Labels: m.Options.PodTemplateLabels, + Annotations: m.Options.PodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: m.Options.Affinity, diff --git a/pkg/3scale/amp/component/memcached_options.go b/pkg/3scale/amp/component/memcached_options.go index f18a46d95..cfcfaec9f 100644 --- a/pkg/3scale/amp/component/memcached_options.go +++ b/pkg/3scale/amp/component/memcached_options.go @@ -18,6 +18,7 @@ type MemcachedOptions struct { PriorityClassName string `validate:"-"` TopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + PodTemplateAnnotations map[string]string `validate:"-"` } func NewMemcachedOptions() *MemcachedOptions { diff --git a/pkg/3scale/amp/component/redis.go b/pkg/3scale/amp/component/redis.go index 02ba22afb..aaf655ce3 100644 --- a/pkg/3scale/amp/component/redis.go +++ b/pkg/3scale/amp/component/redis.go @@ -117,7 +117,8 @@ func (redis *Redis) buildPodTemplateSpec() *v1.PodTemplateSpec { TopologySpreadConstraints: redis.Options.BackendRedisTopologySpreadConstraints, }, ObjectMeta: metav1.ObjectMeta{ - Labels: redis.Options.BackendRedisPodTemplateLabels, + Labels: redis.Options.BackendRedisPodTemplateLabels, + Annotations: redis.Options.BackendRedisPodTemplateAnnotations, }, } } @@ -477,7 +478,8 @@ func (redis *Redis) SystemDeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": SystemRedisDeploymentName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: redis.Options.SystemRedisPodTemplateLabels, + Labels: redis.Options.SystemRedisPodTemplateLabels, + Annotations: redis.Options.SystemRedisPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: redis.Options.SystemRedisAffinity, diff --git a/pkg/3scale/amp/component/redis_options.go b/pkg/3scale/amp/component/redis_options.go index c68114aa3..0c510c2d3 100644 --- a/pkg/3scale/amp/component/redis_options.go +++ b/pkg/3scale/amp/component/redis_options.go @@ -34,6 +34,8 @@ type RedisOptions struct { BackendRedisPriorityClassName string `validate:"-"` SystemRedisTopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` BackendRedisTopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + SystemRedisPodTemplateAnnotations map[string]string `validate:"-"` + BackendRedisPodTemplateAnnotations map[string]string `validate:"-"` // secrets BackendStorageURL string `validate:"required"` diff --git a/pkg/3scale/amp/component/system.go b/pkg/3scale/amp/component/system.go index 82a0b0374..751c6500a 100644 --- a/pkg/3scale/amp/component/system.go +++ b/pkg/3scale/amp/component/system.go @@ -596,7 +596,8 @@ func (system *System) AppDeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": SystemAppDeploymentName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: system.Options.AppPodTemplateLabels, + Labels: system.Options.AppPodTemplateLabels, + Annotations: system.Options.AppPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: system.Options.AppAffinity, @@ -859,7 +860,8 @@ func (system *System) SidekiqDeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": SystemSidekiqName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: system.Options.SidekiqPodTemplateLabels, + Labels: system.Options.SidekiqPodTemplateLabels, + Annotations: system.Options.SideKiqPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: system.Options.SidekiqAffinity, diff --git a/pkg/3scale/amp/component/system_mysql.go b/pkg/3scale/amp/component/system_mysql.go index f10a3ff68..0a22b73ef 100644 --- a/pkg/3scale/amp/component/system_mysql.go +++ b/pkg/3scale/amp/component/system_mysql.go @@ -152,7 +152,8 @@ func (mysql *SystemMysql) DeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": SystemMySQLDeploymentName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: mysql.Options.PodTemplateLabels, + Labels: mysql.Options.PodTemplateLabels, + Annotations: mysql.Options.PodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: mysql.Options.Affinity, diff --git a/pkg/3scale/amp/component/system_mysql_options.go b/pkg/3scale/amp/component/system_mysql_options.go index 767557c1b..b9d8ec760 100644 --- a/pkg/3scale/amp/component/system_mysql_options.go +++ b/pkg/3scale/amp/component/system_mysql_options.go @@ -27,6 +27,7 @@ type SystemMysqlOptions struct { PodTemplateLabels map[string]string `validate:"required"` PriorityClassName string `validate:"-"` TopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + PodTemplateAnnotations map[string]string `validate:"-"` } func NewSystemMysqlOptions() *SystemMysqlOptions { diff --git a/pkg/3scale/amp/component/system_options.go b/pkg/3scale/amp/component/system_options.go index 3138ce0e9..074676db6 100644 --- a/pkg/3scale/amp/component/system_options.go +++ b/pkg/3scale/amp/component/system_options.go @@ -108,6 +108,8 @@ type SystemOptions struct { AppTopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` SideKiqTopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + AppPodTemplateAnnotations map[string]string `validate:"-"` + SideKiqPodTemplateAnnotations map[string]string `validate:"-"` // Used for monitoring objects // Those objects are namespaced. However, objects includes labels, rules and expressions diff --git a/pkg/3scale/amp/component/system_postgresql.go b/pkg/3scale/amp/component/system_postgresql.go index 3742809fb..ca6462a90 100644 --- a/pkg/3scale/amp/component/system_postgresql.go +++ b/pkg/3scale/amp/component/system_postgresql.go @@ -111,7 +111,8 @@ func (p *SystemPostgreSQL) DeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": SystemPostgreSQLDeploymentName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: p.Options.PodTemplateLabels, + Labels: p.Options.PodTemplateLabels, + Annotations: p.Options.PodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: p.Options.Affinity, diff --git a/pkg/3scale/amp/component/system_postgresql_options.go b/pkg/3scale/amp/component/system_postgresql_options.go index 4e6def759..a6a0c4ff9 100644 --- a/pkg/3scale/amp/component/system_postgresql_options.go +++ b/pkg/3scale/amp/component/system_postgresql_options.go @@ -26,6 +26,7 @@ type SystemPostgreSQLOptions struct { PodTemplateLabels map[string]string `validate:"required"` PriorityClassName string `validate:"-"` TopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + PodTemplateAnnotations map[string]string `validate:"-"` } func NewSystemPostgreSQLOptions() *SystemPostgreSQLOptions { diff --git a/pkg/3scale/amp/component/system_searchd.go b/pkg/3scale/amp/component/system_searchd.go index 634dc2d68..b727ffceb 100644 --- a/pkg/3scale/amp/component/system_searchd.go +++ b/pkg/3scale/amp/component/system_searchd.go @@ -84,7 +84,8 @@ func (s *SystemSearchd) DeploymentConfig() *appsv1.DeploymentConfig { }, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: s.Options.PodTemplateLabels, + Labels: s.Options.PodTemplateLabels, + Annotations: s.Options.PodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: s.Options.Affinity, diff --git a/pkg/3scale/amp/component/system_searchd_options.go b/pkg/3scale/amp/component/system_searchd_options.go index f0f500521..93760ae82 100644 --- a/pkg/3scale/amp/component/system_searchd_options.go +++ b/pkg/3scale/amp/component/system_searchd_options.go @@ -25,6 +25,7 @@ type SystemSearchdOptions struct { PVCOptions SearchdPVCOptions `validate:"required"` PriorityClassName string `validate:"-"` TopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + PodTemplateAnnotations map[string]string `validate:"-"` } func NewSystemSearchdOptions() *SystemSearchdOptions { diff --git a/pkg/3scale/amp/component/zync.go b/pkg/3scale/amp/component/zync.go index eb6e57a66..5ac724b0c 100644 --- a/pkg/3scale/amp/component/zync.go +++ b/pkg/3scale/amp/component/zync.go @@ -197,11 +197,8 @@ func (zync *Zync) DeploymentConfig() *appsv1.DeploymentConfig { Selector: map[string]string{"deploymentConfig": ZyncName}, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: zync.Options.ZyncPodTemplateLabels, - Annotations: map[string]string{ - "prometheus.io/port": "9393", - "prometheus.io/scrape": "true", - }, + Labels: zync.Options.ZyncPodTemplateLabels, + Annotations: zync.Options.ZyncPodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: zync.Options.ZyncAffinity, @@ -355,11 +352,8 @@ func (zync *Zync) QueDeploymentConfig() *appsv1.DeploymentConfig { }, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{ - "prometheus.io/port": "9394", - "prometheus.io/scrape": "true", - }, - Labels: zync.Options.ZyncQuePodTemplateLabels, + Labels: zync.Options.ZyncQuePodTemplateLabels, + Annotations: zync.Options.ZyncQuePodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: zync.Options.ZyncQueAffinity, @@ -439,7 +433,8 @@ func (zync *Zync) DatabaseDeploymentConfig() *appsv1.DeploymentConfig { }, Template: &v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ - Labels: zync.Options.ZyncDatabasePodTemplateLabels, + Labels: zync.Options.ZyncDatabasePodTemplateLabels, + Annotations: zync.Options.ZyncDatabasePodTemplateAnnotations, }, Spec: v1.PodSpec{ Affinity: zync.Options.ZyncDatabaseAffinity, diff --git a/pkg/3scale/amp/component/zync_options.go b/pkg/3scale/amp/component/zync_options.go index c42bd408d..acfff3824 100644 --- a/pkg/3scale/amp/component/zync_options.go +++ b/pkg/3scale/amp/component/zync_options.go @@ -49,6 +49,10 @@ type ZyncOptions struct { ZyncQueTopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` ZyncDatabaseTopologySpreadConstraints []v1.TopologySpreadConstraint `validate:"-"` + ZyncPodTemplateAnnotations map[string]string `validate:"-"` + ZyncQuePodTemplateAnnotations map[string]string `validate:"-"` + ZyncDatabasePodTemplateAnnotations map[string]string `validate:"-"` + // Used for monitoring objects // Those objects are namespaced. However, objects includes labels, rules and expressions // that need namespace filtering because they are "global" once imported diff --git a/pkg/3scale/amp/operator/apicast_options_provider.go b/pkg/3scale/amp/operator/apicast_options_provider.go index ec7a6cb9d..085585a9c 100644 --- a/pkg/3scale/amp/operator/apicast_options_provider.go +++ b/pkg/3scale/amp/operator/apicast_options_provider.go @@ -88,6 +88,7 @@ func (a *ApicastOptionsProvider) GetApicastOptions() (*component.ApicastOptions, a.setReplicas() a.setPriorityClassNames() a.setTopologySpreadConstraints() + a.setPodTemplateAnnotations() err := a.setCustomPolicies() if err != nil { @@ -481,3 +482,8 @@ func (a *ApicastOptionsProvider) setTopologySpreadConstraints() { a.apicastOptions.TopologySpreadConstraintsProduction = a.apimanager.Spec.Apicast.ProductionSpec.TopologySpreadConstraints } } + +func (a *ApicastOptionsProvider) setPodTemplateAnnotations() { + a.apicastOptions.StagingPodTemplateAnnotations = a.apimanager.Spec.Apicast.StagingSpec.Annotations + a.apicastOptions.ProductionPodTemplateAnnotations = a.apimanager.Spec.Apicast.ProductionSpec.Annotations +} diff --git a/pkg/3scale/amp/operator/apicast_reconciler.go b/pkg/3scale/amp/operator/apicast_reconciler.go index 361f45f04..6e4c710c2 100644 --- a/pkg/3scale/amp/operator/apicast_reconciler.go +++ b/pkg/3scale/amp/operator/apicast_reconciler.go @@ -81,6 +81,7 @@ func (r *ApicastReconciler) Reconcile() (reconcile.Result, error) { apicastPodTemplateEnvConfigMapAnnotationsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, } if r.apiManager.Spec.Apicast.StagingSpec.Replicas != nil { @@ -116,6 +117,7 @@ func (r *ApicastReconciler) Reconcile() (reconcile.Result, error) { apicastPodTemplateEnvConfigMapAnnotationsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, } if r.apiManager.Spec.Apicast.ProductionSpec.Replicas != nil { diff --git a/pkg/3scale/amp/operator/backend_options_provider.go b/pkg/3scale/amp/operator/backend_options_provider.go index a2289fbb1..742050cd6 100644 --- a/pkg/3scale/amp/operator/backend_options_provider.go +++ b/pkg/3scale/amp/operator/backend_options_provider.go @@ -45,6 +45,7 @@ func (o *OperatorBackendOptionsProvider) GetBackendOptions() (*component.Backend o.setReplicas() o.setPriorityClassNames() o.setTopologySpreadConstraints() + o.setPodTemplateAnnotations() o.backendOptions.CommonLabels = o.commonLabels() o.backendOptions.CommonListenerLabels = o.commonListenerLabels() @@ -245,6 +246,12 @@ func (o *OperatorBackendOptionsProvider) setPriorityClassNames() { } } +func (o *OperatorBackendOptionsProvider) setPodTemplateAnnotations() { + o.backendOptions.ListenerPodTemplateAnnotations = o.apimanager.Spec.Backend.ListenerSpec.Annotations + o.backendOptions.WorkerPodTemplateAnnotations = o.apimanager.Spec.Backend.WorkerSpec.Annotations + o.backendOptions.CronPodTemplateAnnotations = o.apimanager.Spec.Backend.CronSpec.Annotations +} + func (o *OperatorBackendOptionsProvider) setTopologySpreadConstraints() { if o.apimanager.Spec.Backend.ListenerSpec.TopologySpreadConstraints != nil { o.backendOptions.TopologySpreadConstraintsListener = o.apimanager.Spec.Backend.ListenerSpec.TopologySpreadConstraints diff --git a/pkg/3scale/amp/operator/memcached_options_provider.go b/pkg/3scale/amp/operator/memcached_options_provider.go index 42035867f..ea74e4a72 100644 --- a/pkg/3scale/amp/operator/memcached_options_provider.go +++ b/pkg/3scale/amp/operator/memcached_options_provider.go @@ -27,6 +27,7 @@ func (m *MemcachedOptionsProvider) GetMemcachedOptions() (*component.MemcachedOp m.memcachedOptions.ImageTag = product.ThreescaleRelease m.memcachedOptions.DeploymentLabels = m.deploymentLabels() m.memcachedOptions.PodTemplateLabels = m.podTemplateLabels() + m.memcachedOptions.PodTemplateAnnotations = m.apimanager.Spec.System.MemcachedAnnotations m.setResourceRequirementsOptions() m.setNodeAffinityAndTolerationsOptions() diff --git a/pkg/3scale/amp/operator/memcached_reconciler.go b/pkg/3scale/amp/operator/memcached_reconciler.go index 1dc4d958d..08ee2c6f7 100644 --- a/pkg/3scale/amp/operator/memcached_reconciler.go +++ b/pkg/3scale/amp/operator/memcached_reconciler.go @@ -32,6 +32,7 @@ func (r *MemcachedReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, ) err = r.ReconcileDeploymentConfig(memcached.DeploymentConfig(), mutator) if err != nil { diff --git a/pkg/3scale/amp/operator/redis_options_provider.go b/pkg/3scale/amp/operator/redis_options_provider.go index 51b507f7b..a5ff911b1 100644 --- a/pkg/3scale/amp/operator/redis_options_provider.go +++ b/pkg/3scale/amp/operator/redis_options_provider.go @@ -59,6 +59,7 @@ func (r *RedisOptionsProvider) GetRedisOptions() (*component.RedisOptions, error r.setPersistentVolumeClaimOptions() r.setPriorityClassNames() r.setTopologySpreadConstraints() + r.setPodTemplateAnnotations() // Should the operator be reading redis secrets? // When HA is disabled, do we support external redis? @@ -270,3 +271,12 @@ func (r *RedisOptionsProvider) setTopologySpreadConstraints() { r.options.BackendRedisTopologySpreadConstraints = r.apimanager.Spec.Backend.RedisTopologySpreadConstraints } } + +func (r *RedisOptionsProvider) setPodTemplateAnnotations() { + if r.apimanager.Spec.System != nil { + r.options.SystemRedisPodTemplateAnnotations = r.apimanager.Spec.System.RedisAnnotations + } + if r.apimanager.Spec.Backend != nil { + r.options.BackendRedisPodTemplateAnnotations = r.apimanager.Spec.Backend.RedisAnnotations + } +} diff --git a/pkg/3scale/amp/operator/redis_reconciler.go b/pkg/3scale/amp/operator/redis_reconciler.go index 78a2c11c2..1b8676c3e 100644 --- a/pkg/3scale/amp/operator/redis_reconciler.go +++ b/pkg/3scale/amp/operator/redis_reconciler.go @@ -67,6 +67,7 @@ func (r *RedisReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, ) err = r.ReconcileDeploymentConfig(r.DeploymentConfig(redis), dcMutator) if err != nil { diff --git a/pkg/3scale/amp/operator/system_mysql_options_provider.go b/pkg/3scale/amp/operator/system_mysql_options_provider.go index c6b2e6a4a..4872bed20 100644 --- a/pkg/3scale/amp/operator/system_mysql_options_provider.go +++ b/pkg/3scale/amp/operator/system_mysql_options_provider.go @@ -47,6 +47,8 @@ func (s *SystemMysqlOptionsProvider) GetMysqlOptions() (*component.SystemMysqlOp s.setPersistentVolumeClaimOptions() s.setNodeAffinityAndTolerationsOptions() s.setPriorityClassNames() + s.setTopologySpreadConstraints() + s.setPodTemplateAnnotations() err = s.mysqlOptions.Validate() if err != nil { @@ -227,3 +229,10 @@ func (s *SystemMysqlOptionsProvider) setTopologySpreadConstraints() { s.mysqlOptions.TopologySpreadConstraints = s.apimanager.Spec.System.DatabaseSpec.MySQL.TopologySpreadConstraints } } + +func (s *SystemMysqlOptionsProvider) setPodTemplateAnnotations() { + if s.apimanager.Spec.System.DatabaseSpec != nil && + s.apimanager.Spec.System.DatabaseSpec.MySQL != nil { + s.mysqlOptions.PodTemplateAnnotations = s.apimanager.Spec.System.DatabaseSpec.MySQL.Annotations + } +} diff --git a/pkg/3scale/amp/operator/system_mysql_reconciler.go b/pkg/3scale/amp/operator/system_mysql_reconciler.go index a02604fd1..389e36e95 100644 --- a/pkg/3scale/amp/operator/system_mysql_reconciler.go +++ b/pkg/3scale/amp/operator/system_mysql_reconciler.go @@ -33,6 +33,7 @@ func (r *SystemMySQLReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, ) err = r.ReconcileDeploymentConfig(systemMySQL.DeploymentConfig(), dcMutator) if err != nil { diff --git a/pkg/3scale/amp/operator/system_options_provider.go b/pkg/3scale/amp/operator/system_options_provider.go index 50c966de8..3805a35aa 100644 --- a/pkg/3scale/amp/operator/system_options_provider.go +++ b/pkg/3scale/amp/operator/system_options_provider.go @@ -62,6 +62,7 @@ func (s *SystemOptionsProvider) GetSystemOptions() (*component.SystemOptions, er s.setReplicas() s.setPriorityClassNames() s.setTopologySpreadConstraints() + s.setPodTemplateAnnotations() s.options.SideKiqMetrics = true s.options.AppMetrics = true @@ -618,3 +619,8 @@ func (s *SystemOptionsProvider) setTopologySpreadConstraints() { s.options.SideKiqTopologySpreadConstraints = s.apimanager.Spec.System.SidekiqSpec.TopologySpreadConstraints } } + +func (s *SystemOptionsProvider) setPodTemplateAnnotations() { + s.options.AppPodTemplateAnnotations = s.apimanager.Spec.System.AppSpec.Annotations + s.options.SideKiqPodTemplateAnnotations = s.apimanager.Spec.System.SidekiqSpec.Annotations +} diff --git a/pkg/3scale/amp/operator/system_postgresql_options_provider.go b/pkg/3scale/amp/operator/system_postgresql_options_provider.go index 17242f449..91c71aff3 100644 --- a/pkg/3scale/amp/operator/system_postgresql_options_provider.go +++ b/pkg/3scale/amp/operator/system_postgresql_options_provider.go @@ -47,6 +47,7 @@ func (s *SystemPostgresqlOptionsProvider) GetSystemPostgreSQLOptions() (*compone s.setNodeAffinityAndTolerationsOptions() s.setPriorityClassNames() s.setTopologySpreadConstraints() + s.setPodTemplateAnnotations() err = s.options.Validate() if err != nil { @@ -211,3 +212,9 @@ func (s *SystemPostgresqlOptionsProvider) setTopologySpreadConstraints() { s.options.TopologySpreadConstraints = s.apimanager.Spec.System.DatabaseSpec.PostgreSQL.TopologySpreadConstraints } } + +func (s *SystemPostgresqlOptionsProvider) setPodTemplateAnnotations() { + if s.apimanager.IsSystemPostgreSQLEnabled() { + s.options.PodTemplateAnnotations = s.apimanager.Spec.System.DatabaseSpec.PostgreSQL.Annotations + } +} diff --git a/pkg/3scale/amp/operator/system_postgresql_reconciler.go b/pkg/3scale/amp/operator/system_postgresql_reconciler.go index 3478bd293..8dbcc0e83 100644 --- a/pkg/3scale/amp/operator/system_postgresql_reconciler.go +++ b/pkg/3scale/amp/operator/system_postgresql_reconciler.go @@ -34,6 +34,7 @@ func (r *SystemPostgreSQLReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, ) err = r.ReconcileDeploymentConfig(systemPostgreSQL.DeploymentConfig(), dcMutator) if err != nil { diff --git a/pkg/3scale/amp/operator/system_reconciler.go b/pkg/3scale/amp/operator/system_reconciler.go index f1ac778be..fef990493 100644 --- a/pkg/3scale/amp/operator/system_reconciler.go +++ b/pkg/3scale/amp/operator/system_reconciler.go @@ -84,6 +84,7 @@ func (r *SystemReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, r.systemAppDCResourceMutator, reconcilers.DeploymentConfigRemoveDuplicateEnvVarMutator, // 3scale 2.13 -> 2.14 @@ -113,6 +114,7 @@ func (r *SystemReconciler) Reconcile() (reconcile.Result, error) { upgrade.SphinxAddressReference, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, } if r.apiManager.Spec.System.SidekiqSpec.Replicas != nil { diff --git a/pkg/3scale/amp/operator/system_searchd_options_provider.go b/pkg/3scale/amp/operator/system_searchd_options_provider.go index fc32c62e3..40c6b6043 100644 --- a/pkg/3scale/amp/operator/system_searchd_options_provider.go +++ b/pkg/3scale/amp/operator/system_searchd_options_provider.go @@ -33,6 +33,7 @@ func (s *SystemSearchdOptionsProvider) GetOptions() (*component.SystemSearchdOpt s.setPVCOptions() s.setPriorityClassNames() s.setTopologySpreadConstraints() + s.setPodTemplateAnnotations() err := s.options.Validate() if err != nil { @@ -127,3 +128,10 @@ func (s *SystemSearchdOptionsProvider) setTopologySpreadConstraints() { s.options.TopologySpreadConstraints = s.apimanager.Spec.System.SearchdSpec.TopologySpreadConstraints } } + +func (s *SystemSearchdOptionsProvider) setPodTemplateAnnotations() { + if s.apimanager.Spec.System != nil && + s.apimanager.Spec.System.SearchdSpec != nil { + s.options.PodTemplateAnnotations = s.apimanager.Spec.System.SearchdSpec.Annotations + } +} diff --git a/pkg/3scale/amp/operator/system_searchd_reconciler.go b/pkg/3scale/amp/operator/system_searchd_reconciler.go index 4685b48da..31cbff7b8 100644 --- a/pkg/3scale/amp/operator/system_searchd_reconciler.go +++ b/pkg/3scale/amp/operator/system_searchd_reconciler.go @@ -56,6 +56,7 @@ func (r *SystemSearchdReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigStrategyMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, ) err = r.ReconcileDeploymentConfig(searchd.DeploymentConfig(), searchdDCmutator) if err != nil { diff --git a/pkg/3scale/amp/operator/zync_options_provider.go b/pkg/3scale/amp/operator/zync_options_provider.go index 66d8eba63..035c384a3 100644 --- a/pkg/3scale/amp/operator/zync_options_provider.go +++ b/pkg/3scale/amp/operator/zync_options_provider.go @@ -53,6 +53,9 @@ func (z *ZyncOptionsProvider) GetZyncOptions() (*component.ZyncOptions, error) { z.zyncOptions.ZyncPodTemplateLabels = z.zyncPodTemplateLabels() z.zyncOptions.ZyncQuePodTemplateLabels = z.zyncQuePodTemplateLabels() z.zyncOptions.ZyncDatabasePodTemplateLabels = z.zyncDatabasePodTemplateLabels() + z.zyncOptions.ZyncPodTemplateAnnotations = z.zyncPodTemplateAnnotations() + z.zyncOptions.ZyncQuePodTemplateAnnotations = z.zyncQuePodTemplateAnnotations() + z.zyncOptions.ZyncDatabasePodTemplateAnnotations = z.apimanager.Spec.Zync.DatabaseAnnotations z.zyncOptions.ZyncMetrics = true @@ -314,3 +317,23 @@ func (z *ZyncOptionsProvider) setTopologySpreadConstraints() { z.zyncOptions.ZyncDatabaseTopologySpreadConstraints = z.apimanager.Spec.Zync.DatabaseTopologySpreadConstraints } } + +func (z *ZyncOptionsProvider) zyncPodTemplateAnnotations() map[string]string { + annotations := make(map[string]string) + annotations["prometheus.io/port"] = "9393" + annotations["prometheus.io/scrape"] = "true" + for k, v := range z.apimanager.Spec.Zync.AppSpec.Annotations { + annotations[k] = v + } + return annotations +} + +func (z *ZyncOptionsProvider) zyncQuePodTemplateAnnotations() map[string]string { + annotations := make(map[string]string) + annotations["prometheus.io/port"] = "9393" + annotations["prometheus.io/scrape"] = "true" + for k, v := range z.apimanager.Spec.Zync.QueSpec.Annotations { + annotations[k] = v + } + return annotations +} diff --git a/pkg/3scale/amp/operator/zync_options_provider_test.go b/pkg/3scale/amp/operator/zync_options_provider_test.go index 992871324..3d45b7cd6 100644 --- a/pkg/3scale/amp/operator/zync_options_provider_test.go +++ b/pkg/3scale/amp/operator/zync_options_provider_test.go @@ -95,6 +95,13 @@ func testZyncDatabasePodTemplateCommonLabels() map[string]string { return labels } +func testZyncPodTemplateAnnotations() map[string]string { + annotations := make(map[string]string) + annotations["prometheus.io/port"] = "9393" + annotations["prometheus.io/scrape"] = "true" + return annotations +} + func testZyncAffinity() *v1.Affinity { return getTestAffinity("zync") } @@ -225,6 +232,8 @@ func defaultZyncOptions(opts *component.ZyncOptions) *component.ZyncOptions { ZyncPodTemplateLabels: testZyncPodTemplateLabels(), ZyncQuePodTemplateLabels: testZyncQuePodTemplateCommonLabels(), ZyncDatabasePodTemplateLabels: testZyncDatabasePodTemplateCommonLabels(), + ZyncPodTemplateAnnotations: testZyncPodTemplateAnnotations(), + ZyncQuePodTemplateAnnotations: testZyncPodTemplateAnnotations(), ZyncMetrics: true, ZyncQueServiceAccountImagePullSecrets: component.DefaultZyncQueServiceAccountImagePullSecrets(), Namespace: opts.Namespace, diff --git a/pkg/3scale/amp/operator/zync_reconciler.go b/pkg/3scale/amp/operator/zync_reconciler.go index ef5326f17..c650c2aa5 100644 --- a/pkg/3scale/amp/operator/zync_reconciler.go +++ b/pkg/3scale/amp/operator/zync_reconciler.go @@ -53,6 +53,7 @@ func (r *ZyncReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, } if r.apiManager.Spec.Zync.AppSpec.Replicas != nil { zyncMutators = append(zyncMutators, reconcilers.DeploymentConfigReplicasMutator) @@ -71,6 +72,7 @@ func (r *ZyncReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, } if r.apiManager.Spec.Zync.QueSpec.Replicas != nil { zyncQueMutators = append(zyncQueMutators, reconcilers.DeploymentConfigReplicasMutator) @@ -96,6 +98,7 @@ func (r *ZyncReconciler) Reconcile() (reconcile.Result, error) { reconcilers.DeploymentConfigPodTemplateLabelsMutator, reconcilers.DeploymentConfigPriorityClassMutator, reconcilers.DeploymentConfigTopologySpreadConstraintsMutator, + reconcilers.DeploymentConfigPodTemplateAnnotationsMutator, ) err = r.ReconcileDeploymentConfig(zync.DatabaseDeploymentConfig(), zyncDBDCMutator) if err != nil { diff --git a/pkg/reconcilers/deploymentconfig.go b/pkg/reconcilers/deploymentconfig.go index 0f9c38f95..25738dc46 100644 --- a/pkg/reconcilers/deploymentconfig.go +++ b/pkg/reconcilers/deploymentconfig.go @@ -53,6 +53,7 @@ func GenericBackendMutators() []DCMutateFn { DeploymentConfigPodTemplateLabelsMutator, DeploymentConfigPriorityClassMutator, DeploymentConfigTopologySpreadConstraintsMutator, + DeploymentConfigPodTemplateAnnotationsMutator, } } @@ -273,3 +274,12 @@ func DeploymentConfigTopologySpreadConstraintsMutator(desired, existing *appsv1. return updated, nil } + +// DeploymentConfigPodTemplateAnnotationsMutator ensures Pod Template Annotations is reconciled +func DeploymentConfigPodTemplateAnnotationsMutator(desired, existing *appsv1.DeploymentConfig) (bool, error) { + updated := false + + helper.MergeMapStringString(&updated, &existing.Spec.Template.Annotations, desired.Spec.Template.Annotations) + + return updated, nil +} diff --git a/pkg/reconcilers/deploymentconfig_test.go b/pkg/reconcilers/deploymentconfig_test.go index 217211c7c..909b4b61f 100644 --- a/pkg/reconcilers/deploymentconfig_test.go +++ b/pkg/reconcilers/deploymentconfig_test.go @@ -777,7 +777,6 @@ func TestDeploymentConfigPodTemplateLabelsMutator(t *testing.T) { if update != tc.expectedResult { subT.Fatalf("result failed, expected: %t, got: %t", tc.expectedResult, update) } - // It should be tested changes in triggers on image change only, but good enough for now if !reflect.DeepEqual(existing.Spec.Template.Labels, tc.expectedNewLabels) { subT.Fatal(cmp.Diff(existing.Spec.Template.Labels, tc.expectedNewLabels)) } @@ -916,3 +915,70 @@ func TestDeploymentConfigTopologySpreadConstraintsMutator(t *testing.T) { } } + +func TestDeploymentConfigPodTemplateAnnotationsMutator(t *testing.T) { + dcFactory := func(annotations map[string]string) *appsv1.DeploymentConfig { + return &appsv1.DeploymentConfig{ + TypeMeta: metav1.TypeMeta{ + Kind: "DeploymentConfig", + APIVersion: "apps.openshift.io/v1", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "myDC", + Namespace: "myNS", + }, + Spec: appsv1.DeploymentConfigSpec{ + Template: &corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Annotations: annotations, + }, + }, + }, + } + } + + mapCopy := func(originalMap map[string]string) map[string]string { + // Create the target map + targetMap := make(map[string]string) + + // Copy from the original map to the target map + for key, value := range originalMap { + targetMap[key] = value + } + + return targetMap + } + + annotationsA := map[string]string{"a": "1", "a2": "2"} + annotationsB := map[string]string{"a": "other", "b": "1"} + + cases := []struct { + testName string + existingAnnotations map[string]string + desiredAnnotations map[string]string + expectedResult bool + expectedNewAnnotations map[string]string + }{ + {"NothingToReconcile", mapCopy(annotationsA), mapCopy(annotationsA), false, mapCopy(annotationsA)}, + {"AnnotationsReconciled", mapCopy(annotationsB), mapCopy(annotationsA), true, map[string]string{ + "a": "1", "a2": "2", "b": "1", + }}, + } + + for _, tc := range cases { + t.Run(tc.testName, func(subT *testing.T) { + existing := dcFactory(tc.existingAnnotations) + desired := dcFactory(tc.desiredAnnotations) + update, err := DeploymentConfigPodTemplateAnnotationsMutator(desired, existing) + if err != nil { + subT.Fatal(err) + } + if update != tc.expectedResult { + subT.Fatalf("result failed, expected: %t, got: %t", tc.expectedResult, update) + } + if !reflect.DeepEqual(existing.Spec.Template.Annotations, tc.expectedNewAnnotations) { + subT.Fatal(cmp.Diff(existing.Spec.Template.Annotations, tc.expectedNewAnnotations)) + } + }) + } +}