Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
feat: add extraLabels
Browse files Browse the repository at this point in the history
  • Loading branch information
lenglet-k authored and eshepelyuk committed Dec 1, 2023
1 parent 44023f5 commit 7df5ed2
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 4 deletions.
9 changes: 9 additions & 0 deletions templates/deployment-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ metadata:
name: {{ include "apicurio-registry.name" . }}
labels:
{{- include "apicurio-registry.labels" . | nindent 4 }}
{{- with .Values.registry.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "apicurio-registry.selectorLabels" . | nindent 6 }}
{{- with .Values.registry.extraLabels }}
{{- toYaml . | nindent 6 }}
{{- end }}
app.kubernetes.io/component: registry
template:
metadata:
labels:
{{- include "apicurio-registry.selectorLabels" . | nindent 8 }}
{{- with .Values.registry.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
app.kubernetes.io/component: registry
spec:
serviceAccountName: {{ include "apicurio-registry.name" . }}
Expand Down
9 changes: 9 additions & 0 deletions templates/deployment-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ metadata:
name: {{ include "apicurio-registry.name" . }}-sync
labels:
{{- include "apicurio-registry.labels" . | nindent 4 }}
{{- with .Values.sync.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "apicurio-registry.selectorLabels" . | nindent 6 }}
{{- with .Values.sync.extraLabels }}
{{- toYaml . | nindent 6 }}
{{- end }}
app.kubernetes.io/component: sync
template:
metadata:
labels:
{{- include "apicurio-registry.selectorLabels" . | nindent 8 }}
{{- with .Values.sync.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
app.kubernetes.io/component: sync
spec:
serviceAccountName: {{ include "apicurio-registry.name" . }}
Expand Down
10 changes: 10 additions & 0 deletions test/lint/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,13 @@ tests:
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- registry.ingress.ingressClassName: Invalid type. Expected: string, given: integer
- it: extraLabels is not object
set:
registry:
extraLabels: 1
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- registry.extraLabels: Invalid type. Expected: object, given: integer
10 changes: 10 additions & 0 deletions test/lint/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ suite: lint sync values
templates:
- fake.yaml
tests:
- it: extraLabels is not object
set:
sync:
extraLabels: 1
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- sync.extraLabels: Invalid type. Expected: object, given: integer
- it: nodeSelector is not object
set:
sync:
Expand Down
31 changes: 30 additions & 1 deletion test/unit/deployment_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,33 @@ tests:
value: bar
- equal:
path: spec.template.spec.containers[0].env[3].valueFrom.secretKeyRef.key
value: baz
value: baz
- it: no extraLabels
set:
registry:
extraLabels:
testLabel: "myLabel"
asserts:
- equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/component: registry
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
testLabel: myLabel
- equal:
path: metadata.labels
value:
helm.sh/chart: "apicurio-registry-0.0.0"
app.kubernetes.io/version: "0.0.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: apicurio-registry
app.kubernetes.io/instance: RELEASE-NAME
testLabel: myLabel
- equal:
path: spec.template.metadata.labels
value:
app.kubernetes.io/component: registry
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
testLabel: myLabel
51 changes: 51 additions & 0 deletions test/unit/deployment_sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,54 @@ tests:
- equal:
path: spec.template.spec.initContainers[0].env[0].value
value: VALUE
- it: no extraLabels
asserts:
- equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/component: sync
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
- equal:
path: metadata.labels
value:
helm.sh/chart: "apicurio-registry-0.0.0"
app.kubernetes.io/version: "0.0.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: apicurio-registry
app.kubernetes.io/instance: RELEASE-NAME
- equal:
path: spec.template.metadata.labels
value:
app.kubernetes.io/component: sync
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
- it: with extraLabels
set:
sync:
extraLabels:
testLabel: "myLabel"
asserts:
- equal:
path: spec.selector.matchLabels
value:
app.kubernetes.io/component: sync
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
testLabel: myLabel
- equal:
path: metadata.labels
value:
helm.sh/chart: "apicurio-registry-0.0.0"
app.kubernetes.io/version: "0.0.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: apicurio-registry
app.kubernetes.io/instance: RELEASE-NAME
testLabel: myLabel
- equal:
path: spec.template.metadata.labels
value:
app.kubernetes.io/component: sync
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
testLabel: myLabel
9 changes: 7 additions & 2 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"volumes": {
"type": "array", "default": []
},
"labels": {
"type": "object", "default": {}
},
"ingress": {
"type": "object", "title": "ingress resource for registry",
"required": ["enabled", "host", "path"],
Expand Down Expand Up @@ -102,7 +105,8 @@
"extraVolumes": {"$ref": "#/definitions/volumes", "title": "extra volumes for registry"},
"kafka": {"$ref": "#/definitions/persistence/kafka"},
"sql": {"$ref": "#/definitions/persistence/sql"},
"ingress": {"$ref": "#/definitions/ingress"}
"ingress": {"$ref": "#/definitions/ingress"},
"extraLabels": {"$ref": "#/definitions/labels", "title": "deployment and pod resources labels for registry"}
}
},
"sync": {
Expand All @@ -116,7 +120,8 @@
"resources": {"$ref": "#/definitions/podResources"},
"extraVolumeMounts": {"$ref": "#/definitions/volumeMounts", "title": "extra volume mounts for registry content sync"},
"extraVolumes": {"$ref": "#/definitions/volumes", "title": "extra volumes for registry content sync"},
"registryUrl": {"type": ["null", "string"], "default": null}
"registryUrl": {"type": ["null", "string"], "default": null},
"extraLabels": {"$ref": "#/definitions/labels", "title": "deployment and pod resources labels for sync"}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ registry:
# - name: kafkauser
# secret:
# secretName: kafka-user
# add extraLabels in deployment and pod objects
extraLabels: {}

ingress:
enabled: false
Expand Down Expand Up @@ -78,4 +80,5 @@ sync:
# - name: kafkauser
# secret:
# secretName: kafka-user

# add extraLabels in deployment and pod objects
extraLabels: {}

0 comments on commit 7df5ed2

Please sign in to comment.