Helm 3 - Fix Job Labels

If labels are not specified on a Job, kubernetes defaults them
to include the labels of their underlying Pod template. Helm 3
injects metadata into all resources [0] including a
`app.kubernetes.io/managed-by: Helm` label. Thus when kubernetes
sees a Job's labels they are no longer empty and thus do not get
defaulted to the underlying Pod template's labels. This is a
problem since Job labels are depended on by
- Armada pre-upgrade delete hooks
- Armada wait logic configurations
- kubernetes-entrypoint dependencies

Thus for each Job template this adds labels matching the
underlying Pod template to retain the same labels that were
present with Helm 2.

[0]: https://github.com/helm/helm/pull/7649

Change-Id: Ib5a7eb494fb776d74e1edc767b9522b02453b19d
This commit is contained in:
Gage Hugo 2021-10-01 17:13:56 -05:00
parent a772a30f07
commit 1e651dc3c3
27 changed files with 39 additions and 8 deletions

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Cinder
name: cinder
version: 0.2.9
version: 0.2.10
home: https://docs.openstack.org/cinder/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Cinder/OpenStack_Project_Cinder_vertical.png
sources:

View File

@ -50,6 +50,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: cinder-backup-storage-init
labels:
{{ tuple $envAll "cinder" "backup-storage-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
spec:

View File

@ -49,6 +49,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: {{ print "cinder-clean" }}
labels:
{{ tuple $envAll "cinder" "clean" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded

View File

@ -34,7 +34,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation
{{- end }}
labels:
application: {{ printf "%s-%s" $serviceUserPretty "create-internal-tenant" | quote }}
{{ tuple $envAll "cinder" "create-internal-tenant" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
spec:
template:
metadata:

View File

@ -52,6 +52,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: cinder-storage-init
labels:
{{ tuple $envAll "cinder" "storage-init" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
spec:
template:
metadata:

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Glance
name: glance
version: 0.2.7
version: 0.2.8
home: https://docs.openstack.org/glance/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Glance/OpenStack_Project_Glance_vertical.png
sources:

View File

@ -22,6 +22,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: glance-metadefs-load
labels:
{{ tuple $envAll "glance" "metadefs-load" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{- if .Values.helm3_hook }}
helm.sh/hook: post-install,post-upgrade

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Heat
name: heat
version: 0.2.6
version: 0.2.7
home: https://docs.openstack.org/heat/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Heat/OpenStack_Project_Heat_vertical.png
sources:

View File

@ -22,6 +22,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: heat-domain-ks-user
labels:
{{ tuple $envAll "heat" "ks-user-domain" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{- if .Values.helm3_hook }}
"helm.sh/hook": post-install,post-upgrade

View File

@ -24,6 +24,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: heat-trusts
labels:
{{ tuple $envAll "heat" "trusts" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{- if .Values.helm3_hook }}
"helm.sh/hook": post-install,post-upgrade

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Horizon
name: horizon
version: 0.2.9
version: 0.2.10
home: https://docs.openstack.org/horizon/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Horizon/OpenStack_Project_Horizon_vertical.png
sources:

View File

@ -25,6 +25,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: horizon-db-sync
labels:
{{ tuple $envAll "horizon" "db-sync" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
spec:

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Keystone
name: keystone
version: 0.2.11
version: 0.2.12
home: https://docs.openstack.org/keystone/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Keystone/OpenStack_Project_Keystone_vertical.png
sources:

View File

@ -28,6 +28,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: "keystone-credential-cleanup"
labels:
{{ tuple $envAll "keystone" "credential-cleanup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded, hook-failed

View File

@ -53,6 +53,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: keystone-credential-setup
labels:
{{ tuple $envAll "keystone" "credential-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{- if .Values.helm3_hook }}
"helm.sh/hook": post-install,post-upgrade

View File

@ -25,6 +25,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: keystone-domain-manage
labels:
{{ tuple $envAll "keystone" "domain-manage" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation

View File

@ -14,7 +14,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Nova
name: nova
version: 0.2.20
version: 0.2.21
home: https://docs.openstack.org/nova/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Nova/OpenStack_Project_Nova_vertical.png
sources:

View File

@ -22,6 +22,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: nova-cell-setup
labels:
{{ tuple $envAll "nova" "cell-setup" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
spec:

View File

@ -16,7 +16,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Placement
name: placement
version: 0.2.3
version: 0.2.4
home: https://docs.openstack.org/placement/latest/
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Placement/OpenStack_Project_Placement_vertical.png
sources:

View File

@ -22,6 +22,8 @@ apiVersion: batch/v1
kind: Job
metadata:
name: placement-db-migrate
labels:
{{ tuple $envAll "placement" "db-migrate" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
annotations:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
spec:

View File

@ -26,4 +26,5 @@ cinder:
- 0.2.7 Add Victoria and Wallaby releases support
- 0.2.8 Add logic to bootstrap to handle upgrade timing issue
- 0.2.9 Mount rabbitmq TLS secret for audit usage cronjob
- 0.2.10 Helm 3 - Fix Job Labels
...

View File

@ -17,4 +17,5 @@ glance:
- 0.2.5 Add Ussuri release support
- 0.2.6 Add Victoria and Wallaby releases support
- 0.2.7 Added helm.sh/hook for the jobs
- 0.2.8 Helm 3 - Fix Job Labels
...

View File

@ -13,4 +13,5 @@ heat:
- 0.2.4 Add Ussuri release support
- 0.2.5 Add Victoria and Wallaby releases support
- 0.2.6 Added post-install and post-upgrade helm-hook for jobs
- 0.2.7 Helm 3 - Fix Job Labels
...

View File

@ -19,4 +19,5 @@ horizon:
- 0.2.7 Fix OPENSTACK_ENABLE_PASSWORD_RETRIEVE value
- 0.2.8 Add default polices
- 0.2.9 Removed default policy in chart in favor of default policy in code
- 0.2.10 Helm 3 - Fix Job Labels
...

View File

@ -27,4 +27,5 @@ keystone:
- 0.2.9 Add Victoria and Wallaby releases support
- 0.2.10 Make internal TLS more robust
- 0.2.11 Add missing slash
- 0.2.12 Helm 3 - Fix Job Labels
...

View File

@ -41,4 +41,5 @@ nova:
- 0.2.18 Give service time to restore
- 0.2.19 Define service cleaner sleep time
- 0.2.20 Update script to true of grep does get anything.
- 0.2.21 Helm 3 - Fix Job Labels
...

View File

@ -12,4 +12,5 @@ placement:
- 0.2.1 Add Ussuri release support
- 0.2.2 Add Victoria and Wallaby releases support
- 0.2.3 Added helm.sh/hook annotations for Jobs
- 0.2.4 Helm 3 - Fix Job Labels
...