Skip to content

Commit a276145

Browse files
committed
Testing annotation change
Signed-off-by: Veronika Fisarova <vfisarov@redhat.com>
1 parent 80e7527 commit a276145

5 files changed

Lines changed: 95 additions & 1 deletion

File tree

api/bases/neutron.openstack.org_neutronapis.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,28 @@ spec:
14551455
from the Secret
14561456
type: string
14571457
type: object
1458+
podAnnotations:
1459+
description: PodAnnotations are added to the Neutron API Deployment
1460+
pod template.
1461+
items:
1462+
description: |-
1463+
PodAnnotation is a single key/value pair that will be applied to the Neutron API
1464+
Deployment PodTemplate as an annotation.
1465+
properties:
1466+
name:
1467+
description: Name is the annotation key.
1468+
type: string
1469+
value:
1470+
description: Value is the annotation value.
1471+
type: string
1472+
required:
1473+
- name
1474+
- value
1475+
type: object
1476+
type: array
1477+
x-kubernetes-list-map-keys:
1478+
- name
1479+
x-kubernetes-list-type: map
14581480
preserveJobs:
14591481
default: false
14601482
description: PreserveJobs - do not delete jobs after they finished

api/v1beta1/neutronapi_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,21 @@ type NeutronAPISpecCore struct {
177177
// An empty value "" leaves the notification drivers unconfigured and emitting no notifications at all.
178178
// Avoid colocating it with RabbitMqClusterName used for RPC.
179179
NotificationsBusInstance *string `json:"notificationsBusInstance,omitempty" deprecated:"notificationsBus.cluster"`
180+
181+
// +kubebuilder:validation:Optional
182+
// +listType=map
183+
// +listMapKey=name
184+
// PodAnnotations are added to the Neutron API Deployment pod template.
185+
PodAnnotations []PodAnnotation `json:"podAnnotations,omitempty"`
186+
}
187+
188+
// PodAnnotation is a single key/value pair that will be applied to the Neutron API
189+
// Deployment PodTemplate as an annotation.
190+
type PodAnnotation struct {
191+
// Name is the annotation key.
192+
Name string `json:"name"`
193+
// Value is the annotation value.
194+
Value string `json:"value"`
180195
}
181196

182197
type NeutronApiTLS struct {

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/neutron.openstack.org_neutronapis.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,28 @@ spec:
14551455
from the Secret
14561456
type: string
14571457
type: object
1458+
podAnnotations:
1459+
description: PodAnnotations are added to the Neutron API Deployment
1460+
pod template.
1461+
items:
1462+
description: |-
1463+
PodAnnotation is a single key/value pair that will be applied to the Neutron API
1464+
Deployment PodTemplate as an annotation.
1465+
properties:
1466+
name:
1467+
description: Name is the annotation key.
1468+
type: string
1469+
value:
1470+
description: Value is the annotation value.
1471+
type: string
1472+
required:
1473+
- name
1474+
- value
1475+
type: object
1476+
type: array
1477+
x-kubernetes-list-map-keys:
1478+
- name
1479+
x-kubernetes-list-type: map
14581480
preserveJobs:
14591481
default: false
14601482
description: PreserveJobs - do not delete jobs after they finished

internal/neutronapi/deployment.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@ func Deployment(
134134
apiVolumeMounts = append(apiVolumeMounts, svc.CreateVolumeMounts("ovndb")...)
135135
}
136136

137+
podAnnotations := map[string]string{}
138+
139+
// keep existing annotations first
140+
for k, v := range annotations {
141+
podAnnotations[k] = v
142+
}
143+
144+
// overlay user-provided annotations
145+
for _, ann := range instance.Spec.PodAnnotations {
146+
if ann.Name == "" {
147+
continue
148+
}
149+
podAnnotations[ann.Name] = ann.Value
150+
}
151+
137152
deployment := &appsv1.Deployment{
138153
ObjectMeta: metav1.ObjectMeta{
139154
Name: ServiceName,
@@ -146,7 +161,7 @@ func Deployment(
146161
Replicas: instance.Spec.Replicas,
147162
Template: corev1.PodTemplateSpec{
148163
ObjectMeta: metav1.ObjectMeta{
149-
Annotations: annotations,
164+
Annotations: podAnnotations,
150165
Labels: labels,
151166
},
152167
Spec: corev1.PodSpec{

0 commit comments

Comments
 (0)