Skip to content

Commit

Permalink
Use common labels for the NATS manager resources (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobebway authored Dec 5, 2023
1 parent be29ce6 commit 7854d5f
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 33 deletions.
1 change: 1 addition & 0 deletions config/crd/bases/operator.kyma-project.io_nats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: nats.operator.kyma-project.io
labels: {}
spec:
group: operator.kyma-project.io
names:
Expand Down
14 changes: 10 additions & 4 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ namespace: kyma-system
namePrefix: nats-

# Labels to add to all resources and selectors.
#labels:
#- includeSelectors: true
# pairs:
# someName: someValue
labels:
- includeSelectors: false
pairs:
app.kubernetes.io/component: nats-manager
app.kubernetes.io/created-by: nats-manager
app.kubernetes.io/instance: nats-manager
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: nats-manager
app.kubernetes.io/part-of: Kyma
control-plane: nats-manager

resources:
- ../crd
Expand Down
9 changes: 1 addition & 8 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@ kind: Deployment
metadata:
name: manager
namespace: system
labels:
control-plane: manager
app.kubernetes.io/name: deployment
app.kubernetes.io/instance: manager
app.kubernetes.io/component: manager
app.kubernetes.io/created-by: nats-manager
app.kubernetes.io/part-of: nats-manager
app.kubernetes.io/managed-by: kustomize
labels: {}
spec:
selector:
matchLabels:
Expand Down
1 change: 1 addition & 0 deletions config/manager/priority-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: manager-priority-class
labels: {}
value: 2000000
globalDefault: false
description: "Scheduling priority of the NATS-Manager module. Must not be blocked by unschedulable user workloads."
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
labels: {}
name: manager-role
rules:
- apiGroups:
Expand Down
8 changes: 1 addition & 7 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
app.kubernetes.io/name: clusterrolebinding
app.kubernetes.io/instance: manager-rolebinding
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: nats-manager
app.kubernetes.io/part-of: nats-manager
app.kubernetes.io/managed-by: kustomize
labels: {}
name: manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
8 changes: 1 addition & 7 deletions config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: serviceaccount
app.kubernetes.io/instance: manager-sa
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: nats-manager
app.kubernetes.io/part-of: nats-manager
app.kubernetes.io/managed-by: kustomize
labels: {}
name: manager
namespace: system
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,6 @@ func Test_Validate_CreateNATS(t *testing.T) {
// object in the K8s cluster, then tries to modify it with givenUpdates, and test the error that was caused by this
// update, against a wantErrMsg.
func Test_Validate_UpdateNATS(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
givenNATS *v1alpha1.NATS
Expand Down Expand Up @@ -303,7 +301,6 @@ func Test_Validate_UpdateNATS(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
g := gomega.NewGomegaWithT(t)

// given
Expand Down
10 changes: 8 additions & 2 deletions pkg/manager/overrides_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,14 @@ func Test_Overrides_Keys(t *testing.T) {
ResourceRequestsMemKey: "64Mi",
ResourceLimitsCPUKey: "500m",
ResourceLimitsMemKey: "1Gi",
CommonLabelsKey: map[string]interface{}{},
CommonAnnotationsKey: map[string]interface{}{},
CommonLabelsKey: map[string]interface{}{
"app.kubernetes.io/component": "nats-manager",
"app.kubernetes.io/created-by": "nats-manager",
"app.kubernetes.io/managed-by": "nats-manager",
"app.kubernetes.io/part-of": "nats-manager",
"control-plane": "nats-manager",
},
CommonAnnotationsKey: map[string]interface{}{},
}

// run test cases
Expand Down
1 change: 0 additions & 1 deletion resources/nats/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ helm.sh/chart: {{ include "nats.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Expand Down
7 changes: 6 additions & 1 deletion resources/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,12 @@ appProtocol:
k8sClusterDomain: cluster.local

# Add labels to all the deployed resources
commonLabels: {}
commonLabels:
app.kubernetes.io/component: nats-manager
app.kubernetes.io/created-by: nats-manager
app.kubernetes.io/managed-by: nats-manager
app.kubernetes.io/part-of: nats-manager
control-plane: nats-manager

# Add annotations to all the deployed resources
commonAnnotations: {}
Expand Down

0 comments on commit 7854d5f

Please sign in to comment.