Skip to content

Commit

Permalink
Add optional custom labels for workload resources (#3331)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ku <aku@oanda.com>
  • Loading branch information
aku-oanda authored Sep 13, 2023
1 parent 8e27b0b commit b91ce44
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/artifact-hub/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: artifact-hub
description: Artifact Hub is a web-based application that enables finding, installing, and publishing Kubernetes packages.
type: application
version: 1.15.1-0
version: 1.15.1-1
appVersion: 1.15.0
kubeVersion: ">= 1.19.0-0"
home: https://artifacthub.io
Expand Down
9 changes: 9 additions & 0 deletions charts/artifact-hub/templates/db_migrator_job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ metadata:
"helm.sh/hook-weight": "0"
"helm.sh/hook-delete-policy": before-hook-creation
{{- end }}
{{- with .Values.dbMigrator.job.extraJobLabels }}
labels:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ttlSecondsAfterFinished: {{ .Values.dbMigrator.job.ttlSecondsAfterFinished }}
template:
{{- with .Values.dbMigrator.job.extraPodLabels }}
metadata:
labels:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
6 changes: 6 additions & 0 deletions charts/artifact-hub/templates/hub_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ metadata:
labels:
app.kubernetes.io/component: hub
{{- include "chart.labels" . | nindent 4 }}
{{- with .Values.hub.deploy.extraDeploymentLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.hub.deploy.replicaCount }}
selector:
Expand All @@ -20,6 +23,9 @@ spec:
labels:
app.kubernetes.io/component: hub
{{- include "chart.selectorLabels" . | nindent 8 }}
{{- with .Values.hub.deploy.extraPodLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.hub.deploy.readinessGates }}
readinessGates:
Expand Down
9 changes: 9 additions & 0 deletions charts/artifact-hub/templates/scanner_cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "chart.resourceNamePrefix" . }}scanner
{{- with .Values.scanner.cronjob.extraCronJobLabels }}
labels:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
schedule: "15,45 * * * *"
successfulJobsHistoryLimit: 1
Expand All @@ -15,6 +19,11 @@ spec:
jobTemplate:
spec:
template:
{{- with .Values.scanner.cronjob.extraJobLabels }}
metadata:
labels:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
9 changes: 9 additions & 0 deletions charts/artifact-hub/templates/tracker_cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "chart.resourceNamePrefix" . }}tracker
{{- with .Values.tracker.cronjob.extraCronJobLabels }}
labels:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
schedule: "1,30 * * * *"
successfulJobsHistoryLimit: 1
Expand All @@ -14,6 +18,11 @@ spec:
jobTemplate:
spec:
template:
{{- with .Values.tracker.cronjob.extraJobLabels }}
metadata:
labels:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
6 changes: 6 additions & 0 deletions charts/artifact-hub/templates/trivy_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ metadata:
labels:
app.kubernetes.io/component: trivy
{{- include "chart.labels" . | nindent 4 }}
{{- with .Values.trivy.deploy.extraDeploymentLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: 1
strategy:
Expand All @@ -19,6 +22,9 @@ spec:
labels:
app.kubernetes.io/component: trivy
{{- include "chart.selectorLabels" . | nindent 8 }}
{{- with .Values.trivy.deploy.extraPodLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.trivy.deploy.securityContext }}
securityContext:
Expand Down
60 changes: 60 additions & 0 deletions charts/artifact-hub/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@
"job": {
"type": "object",
"properties": {
"extraJobLabels": {
"title": "Additional labels for the DB migrator job",
"description": "Optionally specify extra list of additional labels for the dbMigrator job",
"type": "object",
"default": {}
},
"extraPodLabels": {
"title": "Additional labels for the DB migrator pod",
"description": "Optionally specify extra list of additional labels for the dbMigrator pod",
"type": "object",
"default": {}
},
"image": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -242,6 +254,18 @@
"deploy": {
"type": "object",
"properties": {
"extraDeploymentLabels": {
"title": "Extra deployment labels",
"description": "Optionally specify extra list of additional labels for the hub deployment",
"type": "object",
"default": {}
},
"extraPodLabels": {
"title": "Extra pod labels",
"description": "Optionally specify extra list of additional labels for the hub pods",
"type": "object",
"default": {}
},
"extraVolumes": {
"title": "Extra volumes",
"description": "Optionally specify extra list of additional volumes for the hub deployment",
Expand Down Expand Up @@ -947,6 +971,18 @@
"cronjob": {
"type": "object",
"properties": {
"extraCronJobLabels": {
"title": "Extra cronjob labels",
"description": "Optionally specify extra list of additional labels for the scanner cronjob",
"type": "object",
"default": {}
},
"extraJobLabels": {
"title": "Extra job labels",
"description": "Optionally specify extra list of additional labels for the jobs spawned by the scanner cronjob",
"type": "object",
"default": {}
},
"extraVolumes": {
"title": "Extra volumes",
"description": "Optionally specify extra list of additional volumes for the scanner cronjob",
Expand Down Expand Up @@ -1043,6 +1079,18 @@
"cronjob": {
"type": "object",
"properties": {
"extraCronJobLabels": {
"title": "Extra cronjob labels",
"description": "Optionally specify extra list of additional labels for the tracker cronjob",
"type": "object",
"default": {}
},
"extraJobLabels": {
"title": "Extra job labels",
"description": "Optionally specify extra list of additional labels for the jobs spawned by the tracker cronjob",
"type": "object",
"default": {}
},
"extraVolumes": {
"title": "Extra volumes",
"description": "Optionally specify extra list of additional volumes for the tracker cronjob",
Expand Down Expand Up @@ -1133,6 +1181,18 @@
"deploy": {
"type": "object",
"properties": {
"extraDeploymentLabels": {
"title": "Extra deployment labels",
"description": "Optionally specify extra list of additional labels for the trivy deployment",
"type": "object",
"default": {}
},
"extraPodLabels": {
"title": "Extra pod labels",
"description": "Optionally specify extra list of additional labels for the trivy pods",
"type": "object",
"default": {}
},
"extraVolumes": {
"title": "Extra volumes",
"description": "Optionally specify extra list of additional volumes for the trivy deployment",
Expand Down
20 changes: 20 additions & 0 deletions charts/artifact-hub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ dbMigrator:
image:
# Database migrator image repository (without the tag)
repository: artifacthub/db-migrator
# Optionally specify extra list of additional labels for the dbMigrator job
extraJobLabels: {}
# Optionally specify extra list of additional labels for the dbMigrator pod
extraPodLabels: {}
# Limits the lifetime of the job after it has finished execution
ttlSecondsAfterFinished: null
securityContext: {}
Expand Down Expand Up @@ -167,6 +171,10 @@ hub:
# requests:
# cpu: 100m
# memory: 128Mi
# Optionally specify extra list of additional labels for the hub deployment
extraDeploymentLabels: {}
# Optionally specify extra list of additional labels for hub pods
extraPodLabels: {}
# Optionally specify extra list of additional volumes for the hub deployment
extraVolumes: []
# Optionally specify extra list of additional volume mounts for the hub deployment
Expand Down Expand Up @@ -307,6 +315,10 @@ scanner:
# requests:
# cpu: 100m
# memory: 128Mi
# Optionally specify extra list of additional labels for the scanner cronjob
extraCronJobLabels: {}
# Optionally specify extra list of additional labels for the jobs spawned by the scanner cronjob
extraJobLabels: {}
# Optionally specify extra list of additional volumes for the scanner cronjob
extraVolumes: []
# Optionally specify extra list of additional volume mounts for the scanner cronjob
Expand Down Expand Up @@ -337,6 +349,10 @@ tracker:
# requests:
# cpu: 100m
# memory: 128Mi
# Optionally specify extra list of additional labels for the tracker cronjob
extraCronJobLabels: {}
# Optionally specify extra list of additional labels for the Jobs spawned by the tracker cronjob
extraJobLabels: {}
# Optionally specify extra list of additional volumes for the tracker cronjob
extraVolumes: []
# Optionally specify extra list of additional volume mounts for the tracker cronjob
Expand Down Expand Up @@ -372,6 +388,10 @@ trivy:
# requests:
# cpu: 100m
# memory: 128Mi
# Optionally specify extra list of additional labels for the trivy deployment
extraDeploymentLabels: {}
# Optionally specify extra list of additional labels for trivy pods
extraPodLabels: {}
# Optionally specify extra list of additional volumes for the trivy deployment
extraVolumes: []
# Optionally specify extra list of additional volume mounts for the trivy deployment
Expand Down

0 comments on commit b91ce44

Please sign in to comment.