Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Allow for overriding of Labels & Annotations for Service and Pods #115

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/charts/version-checker/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ description: A Helm chart for version-checker
home: https://github.com/jetstack/version-checker
name: version-checker
maintainers:
- name: davidcollom
- name: davidcollom
13 changes: 9 additions & 4 deletions deploy/charts/version-checker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@ kind: Deployment
metadata:
name: {{ $chartname }}
labels:
{{ include "version-checker.labels" . | nindent 2 }}
{{ include "version-checker.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ $chartname }}
{{- include "version-checker.labels" . | nindent 6 }}
template:
metadata:
labels:
app: {{ $chartname }}
{{ include "version-checker.labels" . | nindent 8 }}
{{- include "version-checker.labels" . | nindent 8 }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels | nindent 8 }}
{{- end }}
annotations:
prometheus.io/path: "/metrics"
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
enable.version-checker.io/{{ $chartname }}: "true"
{{- if .Values.additionalAnnotations }}
{{ toYaml .Values.additionalAnnotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ $chartname }}
containers:
Expand Down
11 changes: 9 additions & 2 deletions deploy/charts/version-checker/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ metadata:
name: {{ include "version-checker.name" . }}
labels:
app: {{ include "version-checker.name" . }}
{{ include "version-checker.labels" . | indent 4 }}
{{ include "version-checker.labels" . | nindent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | nindent 4 }}
{{- end }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
spec:
ports:
- port: {{ .Values.service.port }}
targetPort: 8080
protocol: TCP
name: web
selector:
app: {{ include "version-checker.name" . }}
{{ include "version-checker.labels" . | nindent 4 }}
83 changes: 83 additions & 0 deletions deploy/charts/version-checker/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,57 @@ tests:
- isNullOrEmpty:
path: spec.template.spec.volumes

# Custom Envs
- it: Custom Env vars
set:
env:
- name: CUSTOM_ENV_VAR
value: CUSTOM_ENV_VALUE
asserts:
- contains:
path: spec.template.spec.containers[0].env
count: 1
content:
name: CUSTOM_ENV_VAR
value: CUSTOM_ENV_VALUE

# Param changes
- it: imageCacheTimeout
set:
versionChecker.imageCacheTimeout: 60m
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--image-cache-timeout=60m"

- it: logLevel
set:
versionChecker.logLevel: debug
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--log-level=debug"

- it: metricsServingAddress
set:
versionChecker.metricsServingAddress: 0.0.0.0:9999
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--metrics-serving-address=0.0.0.0:9999"

- it: testAllContainers
set:
versionChecker.testAllContainers: false
asserts:
- contains:
path: spec.template.spec.containers[0].args
count: 1
content: "--test-all-containers=false"

# ACR
- it: ACR should work
set:
Expand Down Expand Up @@ -306,3 +357,35 @@ tests:
name: version-checker
secret:
secretName: version-checker

- it: Resources are reflected
set:
resources:
limits:
cpu: 100m
memory: 512Mi
asserts:
- equal:
path: spec.template.spec.containers[0].resources
value:
limits:
cpu: 100m
memory: 512Mi

- it: Custom Labels to Pod
set:
additionalLabels:
foo: bar
asserts:
- equal:
path: spec.template.metadata.labels["foo"]
value: bar

- it: Custom Annotations to Pod
set:
additionalAnnotations:
foo: bar
asserts:
- equal:
path: spec.template.metadata.annotations["foo"]
value: bar
29 changes: 29 additions & 0 deletions deploy/charts/version-checker/tests/service_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,38 @@ tests:
kind: Service
apiVersion: v1
name: version-checker
- equal:
path: spec.ports[0].port
value: 8080
- equal:
path: spec.ports[0].targetPort
value: 8080
- equal:
path: spec.ports[0].name
value: web

- it: Custom Port
set:
service.port: 9999
asserts:
- equal:
path: spec.ports[0].port
value: 9999

- it: Custom Labels
set:
service.labels:
foo: bar
asserts:
- equal:
path: metadata.labels["foo"]
value: bar

- it: Custom Annotations
set:
service.annotations:
foo: bar
asserts:
- equal:
path: metadata.annotations["foo"]
value: bar
12 changes: 9 additions & 3 deletions deploy/charts/version-checker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@

replicaCount: 1

additionalLabels: {}
additionalAnnotations: {}

image:
repository: quay.io/jetstack/version-checker
# Override the chart version
tag:
pullPolicy: IfNotPresent

service:
labels: {}
annotations: {}
port: 8080

versionChecker:
Expand Down Expand Up @@ -48,7 +53,8 @@ quay:
# Can be used to provide custom environment variables e.g. proxy settings
env: {}

selfhosted: {}
selfhosted:
{}
#- name: REGISTRY
# host: http://registry:5000
# username:
Expand All @@ -60,7 +66,8 @@ selfhosted: {}
# password: bar
# token:

resources: {}
resources:
{}
# limits:
# cpu: 100m
# memory: 128Mi
Expand All @@ -85,7 +92,6 @@ livenessProbe:
initialDelaySeconds: 3
periodSeconds: 3


# Prometheus Operator
prometheus:
enabled: false
Expand Down
Loading