Support custom labels for controlPlane's job
Component(s)
controlplane, helm
Is your feature request related to a problem? Please describe.
My company uses Istio mesh, so we usually use labels in the namespace to inject the sidecar istio proxy in each pod. helm installs or upgrades are failing since istio-proxy are injecting in pods from Jobs. because the pods don't finish in a completed state.
Describe the solution you'd like
if jobs support custom labels, I am going to have more control which labels are injecting on Job Pods. It will also help to identify attributes of objects that are meaningful and relevant. also I can tell to istio controller to don't inject istio-sidecar
Describe alternatives you've considered
This is my proposal solution. You will notice that I added a new variable called customLabelsJobsControplane
# The otelcollector provides the necessary database schema for the migration
{{- if .Values.global.otelcollector.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ include "controlplane.fullname" . }}-clickhouse-migration-{{ now | unixEpoch }}"
labels:
{{- include "controlplane.labels" . | nindent 4 }}
{{- if .Values.customLabelsJobsControplane }}{{ toYaml .Values.customLabelsJobsControplane | nindent 4 }}{{- end }}
annotations:
# Run migration job before helm install/upgrade
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
# Less priority than the migration job so the secret is created before the migration job
"helm.sh/hook-weight": "-5"
# Support for k14s.io. This annotation ensure that the job is run after clickhouse deployment
{{- if .Values.global.clickhouse.enabled }}
kapp.k14s.io/change-rule.clickhouse: "upsert after upserting cosmo.apps.clickhouse.wundergraph.com/deployment"
{{- end }}
{{- if .Values.global.otelcollector.enabled }}
kapp.k14s.io/change-rule.otelcollector: "upsert after upserting cosmo.apps.otelcollector.wundergraph.com/deployment"
{{- end }}
# Create a new change-group so the controlplane can be deployed after the clickhouse migration
kapp.k14s.io/change-group: "cosmo.apps.controlplane.wundergraph.com/ch-migration"
spec:
backoffLimit: 10
parallelism: 1
template:
metadata:
name: "{{ include "controlplane.fullname" . }}-clickhouse-migration"
labels:
{{- include "controlplane.labels" . | nindent 8 }}
{{- if .Values.customLabelsJobsControplane }}{{ toYaml .Values.customLabelsJobsControplane | nindent 8 }}{{- end }}
spec:
restartPolicy: OnFailure
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: seed
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ include "controlplane.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: CLICKHOUSE_DSN
valueFrom:
secretKeyRef:
name: {{ include "controlplane.secretName" . }}
key: clickhouseMigrationDsn
args:
- "/app/dist/bin/ch-migrate.js"
{{- end }}
Additional context
No response
WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible. The roadmap is driven by our customers and we have to prioritize issues that are important to them. You can influence the priority by becoming a customer. Please contact us here.
Hi @esparta86 thanks for the report. We'll take a deeper look and come back. Would you be open to create a PR after we have agreed on a solution?
of course, I made those changes in my local and tested it. let me know when you have an agreement solution.
Hi @StarpTech any update on this? I'll appreciate it
Hi @esparta86, sry for the late response. It's on my list. I'm going to come up with a solution asap.
hi @StarpTech any updates on it? would like to know if there a plan to have custom labels for all components
+1 on this.
It would be very useful the support of custom labels.
Hi @esparta86, @keadex we're addressing this in the coming week.
Hi @esparta86 thank you for coming up with this,
I released https://artifacthub.io/packages/helm/cosmo-platform/cosmo/0.9.0.
You can now pass over additional labels to the jobs. Have a look here https://github.com/wundergraph/cosmo/blob/f2a6ba5f0b25a2f2093536fceb3c865090ba4f5a/helm/cosmo/values.yaml#L105
e.g.:
controlplane:
additionalJobLabels: # added to all jobs
sidecar.istio.io/inject: false
...
jobs:
seedOrganization:
additionalLabels: {} # added e.g. to the seed job
Let me know if this works out for you.
Hi @AndreasZeissner we can close it. I tested that version and it is working as expected.