diff --git a/internal/controllers/services.go b/internal/controllers/services.go index 58ec16f5..4f402e83 100644 --- a/internal/controllers/services.go +++ b/internal/controllers/services.go @@ -47,11 +47,13 @@ func (r *Reconciler) reconcileCoreService(ctx context.Context, cr *model.Cryosta "app": cr.Name, "component": "cryostat", } + appProtocol := "http" svc.Spec.Ports = []corev1.ServicePort{ { - Name: "http", - Port: *config.HTTPPort, - TargetPort: intstr.IntOrString{IntVal: constants.AuthProxyHttpContainerPort}, + Name: "http", + Port: *config.HTTPPort, + TargetPort: intstr.IntOrString{IntVal: constants.AuthProxyHttpContainerPort}, + AppProtocol: &appProtocol, }, } return nil @@ -214,6 +216,10 @@ func configureService(config *operatorv1beta2.ServiceConfig, appLabel string, co // Add required labels, overriding any user-specified labels with the same keys config.Labels["app"] = appLabel config.Labels["component"] = componentLabel + config.Labels["app.kubernetes.io/name"] = "cryostat" + config.Labels["app.kubernetes.io/instance"] = appLabel + config.Labels["app.kubernetes.io/component"] = componentLabel + config.Labels["app.kubernetes.io/part-of"] = "cryostat" } func (r *Reconciler) createOrUpdateService(ctx context.Context, svc *corev1.Service, owner metav1.Object, diff --git a/internal/test/resources.go b/internal/test/resources.go index 0e804e80..015dd385 100644 --- a/internal/test/resources.go +++ b/internal/test/resources.go @@ -760,13 +760,18 @@ func (r *TestResources) NewCryostatWithAdditionalMetadata() *model.CryostatInsta } func (r *TestResources) NewCryostatService() *corev1.Service { + appProtocol := "http" return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, Namespace: r.Namespace, Labels: map[string]string{ - "app": r.Name, - "component": "cryostat", + "app": r.Name, + "component": "cryostat", + "app.kubernetes.io/name": "cryostat", + "app.kubernetes.io/instance": r.Name, + "app.kubernetes.io/component": "cryostat", + "app.kubernetes.io/part-of": "cryostat", }, }, Spec: corev1.ServiceSpec{ @@ -777,9 +782,10 @@ func (r *TestResources) NewCryostatService() *corev1.Service { }, Ports: []corev1.ServicePort{ { - Name: "http", - Port: 4180, - TargetPort: intstr.FromInt(4180), + Name: "http", + Port: 4180, + TargetPort: intstr.FromInt(4180), + AppProtocol: &appProtocol, }, }, }, @@ -792,8 +798,12 @@ func (r *TestResources) NewReportsService() *corev1.Service { Name: r.Name + "-reports", Namespace: r.Namespace, Labels: map[string]string{ - "app": r.Name, - "component": "reports", + "app": r.Name, + "component": "reports", + "app.kubernetes.io/name": "cryostat", + "app.kubernetes.io/instance": r.Name, + "app.kubernetes.io/component": "reports", + "app.kubernetes.io/part-of": "cryostat", }, }, Spec: corev1.ServiceSpec{ @@ -819,8 +829,12 @@ func (r *TestResources) NewAgentProxyService() *corev1.Service { Name: r.Name + "-agent", Namespace: r.Namespace, Labels: map[string]string{ - "app": r.Name, - "component": "cryostat", + "app": r.Name, + "component": "cryostat", + "app.kubernetes.io/name": "cryostat", + "app.kubernetes.io/instance": r.Name, + "app.kubernetes.io/component": "cryostat", + "app.kubernetes.io/part-of": "cryostat", }, }, Spec: corev1.ServiceSpec{ @@ -848,9 +862,13 @@ func (r *TestResources) NewCustomizedCoreService() *corev1.Service { "my/custom": "annotation", } svc.Labels = map[string]string{ - "app": r.Name, - "component": "cryostat", - "my": "label", + "app": r.Name, + "component": "cryostat", + "my": "label", + "app.kubernetes.io/name": "cryostat", + "app.kubernetes.io/instance": r.Name, + "app.kubernetes.io/component": "cryostat", + "app.kubernetes.io/part-of": "cryostat", } return svc } @@ -863,9 +881,13 @@ func (r *TestResources) NewCustomizedReportsService() *corev1.Service { "my/custom": "annotation", } svc.Labels = map[string]string{ - "app": r.Name, - "component": "reports", - "my": "label", + "app": r.Name, + "component": "reports", + "my": "label", + "app.kubernetes.io/name": "cryostat", + "app.kubernetes.io/instance": r.Name, + "app.kubernetes.io/component": "reports", + "app.kubernetes.io/part-of": "cryostat", } return svc } @@ -878,9 +900,13 @@ func (r *TestResources) NewCustomizedAgentService() *corev1.Service { "my/custom": "annotation", } svc.Labels = map[string]string{ - "app": r.Name, - "component": "cryostat", - "my": "label", + "app": r.Name, + "component": "cryostat", + "my": "label", + "app.kubernetes.io/name": "cryostat", + "app.kubernetes.io/instance": r.Name, + "app.kubernetes.io/component": "cryostat", + "app.kubernetes.io/part-of": "cryostat", } return svc }