From b91ce44d6774b0769547bb45ea8b87a8b2d09152 Mon Sep 17 00:00:00 2001 From: Alex Ku <52829374+aku-oanda@users.noreply.github.com> Date: Wed, 13 Sep 2023 11:32:17 -0400 Subject: [PATCH] Add optional custom labels for workload resources (#3331) Signed-off-by: Alex Ku --- charts/artifact-hub/Chart.yaml | 2 +- .../templates/db_migrator_job.yaml | 9 +++ .../templates/hub_deployment.yaml | 6 ++ .../templates/scanner_cronjob.yaml | 9 +++ .../templates/tracker_cronjob.yaml | 9 +++ .../templates/trivy_deployment.yaml | 6 ++ charts/artifact-hub/values.schema.json | 60 +++++++++++++++++++ charts/artifact-hub/values.yaml | 20 +++++++ 8 files changed, 120 insertions(+), 1 deletion(-) diff --git a/charts/artifact-hub/Chart.yaml b/charts/artifact-hub/Chart.yaml index 03e9d6a06..56b8aeb42 100644 --- a/charts/artifact-hub/Chart.yaml +++ b/charts/artifact-hub/Chart.yaml @@ -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 diff --git a/charts/artifact-hub/templates/db_migrator_job.yaml b/charts/artifact-hub/templates/db_migrator_job.yaml index fe640e203..941f49623 100644 --- a/charts/artifact-hub/templates/db_migrator_job.yaml +++ b/charts/artifact-hub/templates/db_migrator_job.yaml @@ -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: diff --git a/charts/artifact-hub/templates/hub_deployment.yaml b/charts/artifact-hub/templates/hub_deployment.yaml index d3f211274..7f097561e 100644 --- a/charts/artifact-hub/templates/hub_deployment.yaml +++ b/charts/artifact-hub/templates/hub_deployment.yaml @@ -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: @@ -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: diff --git a/charts/artifact-hub/templates/scanner_cronjob.yaml b/charts/artifact-hub/templates/scanner_cronjob.yaml index 4aa9ad26a..f5f093b56 100644 --- a/charts/artifact-hub/templates/scanner_cronjob.yaml +++ b/charts/artifact-hub/templates/scanner_cronjob.yaml @@ -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 @@ -15,6 +19,11 @@ spec: jobTemplate: spec: template: + {{- with .Values.scanner.cronjob.extraJobLabels }} + metadata: + labels: + {{- toYaml . | nindent 12 }} + {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/charts/artifact-hub/templates/tracker_cronjob.yaml b/charts/artifact-hub/templates/tracker_cronjob.yaml index 7adab3f49..82db6be2b 100644 --- a/charts/artifact-hub/templates/tracker_cronjob.yaml +++ b/charts/artifact-hub/templates/tracker_cronjob.yaml @@ -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 @@ -14,6 +18,11 @@ spec: jobTemplate: spec: template: + {{- with .Values.tracker.cronjob.extraJobLabels }} + metadata: + labels: + {{- toYaml . | nindent 12 }} + {{- end }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: diff --git a/charts/artifact-hub/templates/trivy_deployment.yaml b/charts/artifact-hub/templates/trivy_deployment.yaml index 8dfe1079e..fb7263771 100644 --- a/charts/artifact-hub/templates/trivy_deployment.yaml +++ b/charts/artifact-hub/templates/trivy_deployment.yaml @@ -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: @@ -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: diff --git a/charts/artifact-hub/values.schema.json b/charts/artifact-hub/values.schema.json index b37866701..cd8e2b490 100644 --- a/charts/artifact-hub/values.schema.json +++ b/charts/artifact-hub/values.schema.json @@ -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": { @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/charts/artifact-hub/values.yaml b/charts/artifact-hub/values.yaml index 7c0870b6e..e1155ced3 100644 --- a/charts/artifact-hub/values.yaml +++ b/charts/artifact-hub/values.yaml @@ -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: {} @@ -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 @@ -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 @@ -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 @@ -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