Skip to content

Commit 815f2a0

Browse files
committed
service: correct annotations handling
1 parent 0a3ee29 commit 815f2a0

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

api/v1/zz_generated.deepcopy.go

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/coroot.com_coroots.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7400,6 +7400,11 @@ spec:
74007400
service:
74017401
description: Service configuration for Coroot.
74027402
properties:
7403+
annotations:
7404+
additionalProperties:
7405+
type: string
7406+
description: Annotations for the service.
7407+
type: object
74037408
nodePort:
74047409
description: NodePort number (if type is NodePort).
74057410
format: int32

controller/controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ func (r *CorootReconciler) CreateOrUpdatePVC(ctx context.Context, cr *corootv1.C
260260

261261
func (r *CorootReconciler) CreateOrUpdateService(ctx context.Context, cr *corootv1.Coroot, s *corev1.Service) {
262262
spec := s.Spec
263+
annotations := s.Annotations
263264
r.CreateOrUpdate(ctx, cr, s, false, false, func() error {
264-
err := MergeSpecs(s, &s.Spec, spec, nil)
265+
err := MergeSpecs(s, &s.Spec, spec, annotations)
265266
s.Spec.Ports = spec.Ports
266267
return err
267268
})
@@ -299,7 +300,7 @@ func (r *CorootReconciler) CreateOrUpdateClusterRoleBinding(ctx context.Context,
299300

300301
func (r *CorootReconciler) CreateOrUpdateIngress(ctx context.Context, cr *corootv1.Coroot, i *networkingv1.Ingress, delete bool) {
301302
spec := i.Spec
302-
annotations := i.ObjectMeta.Annotations
303+
annotations := i.Annotations
303304
r.CreateOrUpdate(ctx, cr, i, delete, false, func() error {
304305
return MergeSpecs(i, &i.Spec, spec, annotations)
305306
})

controller/coroot.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ func (r *CorootReconciler) corootService(cr *corootv1.Coroot) *corev1.Service {
4141

4242
s := &corev1.Service{
4343
ObjectMeta: metav1.ObjectMeta{
44-
Name: fmt.Sprintf("%s-coroot", cr.Name),
45-
Namespace: cr.Namespace,
46-
Labels: ls,
44+
Name: fmt.Sprintf("%s-coroot", cr.Name),
45+
Namespace: cr.Namespace,
46+
Labels: ls,
47+
Annotations: cr.Spec.Service.Annotations,
4748
},
4849
}
4950

@@ -54,7 +55,6 @@ func (r *CorootReconciler) corootService(cr *corootv1.Coroot) *corev1.Service {
5455
s.Spec = corev1.ServiceSpec{
5556
Selector: ls,
5657
Type: cr.Spec.Service.Type,
57-
Annotations: cr.Spec.Service.Annotations,
5858
Ports: []corev1.ServicePort{
5959
{
6060
Name: "http",

0 commit comments

Comments
 (0)