mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
make selectorlabels a bit better
This commit is contained in:
@@ -62,6 +62,13 @@ tests:
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
- documentIndex: *cronJobDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.selector.matchLabels
|
||||
value:
|
||||
pod.name: workload-name
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
- documentIndex: *cronJobDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
@@ -107,6 +114,13 @@ tests:
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-other-workload-name
|
||||
- documentIndex: *cronJobDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.selector.matchLabels
|
||||
value:
|
||||
pod.name: other-workload-name
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
- documentIndex: *cronJobDoc
|
||||
isSubset:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
@@ -121,6 +135,13 @@ tests:
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test
|
||||
- documentIndex: *otherCronJobDoc
|
||||
equal:
|
||||
path: spec.jobTemplate.spec.selector.matchLabels
|
||||
value:
|
||||
pod.name: workload-name
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
- documentIndex: *otherCronJobDoc
|
||||
isSubset:
|
||||
path: spec.jobTemplate.spec.template.metadata.labels
|
||||
|
||||
@@ -61,6 +61,13 @@ tests:
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
- documentIndex: *jobDoc
|
||||
equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
pod.name: workload-name
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
- documentIndex: *jobDoc
|
||||
equal:
|
||||
path: spec.template.metadata.labels
|
||||
@@ -104,6 +111,13 @@ tests:
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test-other-workload-name
|
||||
- documentIndex: *jobDoc
|
||||
equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
pod.name: other-workload-name
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
- documentIndex: *jobDoc
|
||||
isSubset:
|
||||
path: spec.template.metadata.labels
|
||||
@@ -118,6 +132,13 @@ tests:
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: release-name-common-test
|
||||
- documentIndex: *otherJobDoc
|
||||
equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
pod.name: workload-name
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
- documentIndex: *otherJobDoc
|
||||
isSubset:
|
||||
path: spec.template.metadata.labels
|
||||
|
||||
@@ -32,6 +32,14 @@ tests:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 12345
|
||||
my-service2:
|
||||
enabled: true
|
||||
primary: false
|
||||
ports:
|
||||
port-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: 1234
|
||||
workload:
|
||||
my-workload:
|
||||
enabled: true
|
||||
@@ -60,10 +68,31 @@ tests:
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/version: *appVer
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: common-test
|
||||
service.name: release-name-common-test
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
label1: label1
|
||||
label2: label2
|
||||
- documentIndex: &otherServiceDoc 2
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *otherServiceDoc
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
service.name: release-name-common-test-my-service2
|
||||
app: common-test-1.0.0
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/version: *appVer
|
||||
g_label1: global_label1
|
||||
g_label2: global_label2
|
||||
helm-revision: 0
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
|
||||
- it: should pass with service type LoadBalancer, with HTTPS port and addMetalLBAnnotations/Traefik true
|
||||
set:
|
||||
|
||||
@@ -28,12 +28,15 @@ metadata:
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.workload.cronjobSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | nindent 10 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | fromYaml)) -}}
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 12 }}
|
||||
|
||||
@@ -30,13 +30,13 @@ spec:
|
||||
{{- include "ix.v1.common.lib.workload.daemonsetSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | fromYaml)) -}}
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 8 }}
|
||||
|
||||
@@ -30,13 +30,13 @@ spec:
|
||||
{{- include "ix.v1.common.lib.workload.deploymentSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | fromYaml)) -}}
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 8 }}
|
||||
|
||||
@@ -28,12 +28,15 @@ metadata:
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "ix.v1.common.lib.workload.jobSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | fromYaml)) -}}
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 8 }}
|
||||
|
||||
@@ -56,7 +56,8 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ $objectData.name }}
|
||||
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -}}
|
||||
{{- $labels := (mustMerge ($objectData.labels | default dict) (include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "service" "objectName" $objectData.name) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 4 }}
|
||||
@@ -90,7 +91,7 @@ spec:
|
||||
{{- end -}}
|
||||
{{- if not (mustHas $svcType $specialTypes) }}
|
||||
selector:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $podValues.shortName) | trim | nindent 4 -}}
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $podValues.shortName) | trim | nindent 4 -}}
|
||||
{{- end -}}
|
||||
{{- if eq $svcType "ExternalIP" -}}
|
||||
{{- include "ix.v1.common.class.endpointSlice" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim | nindent 0 }}
|
||||
|
||||
@@ -30,13 +30,13 @@ spec:
|
||||
{{- include "ix.v1.common.lib.workload.statefulsetSpec" (dict "rootCtx" $rootCtx "objectData" $objectData) | nindent 2 }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | nindent 6 }}
|
||||
{{- include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- $labels := (mustMerge ($objectData.podSpec.labels | default dict)
|
||||
(include "ix.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.podLabels" $rootCtx | fromYaml)
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "podName" $objectData.shortName) | fromYaml)) -}}
|
||||
(include "ix.v1.common.lib.metadata.selectorLabels" (dict "rootCtx" $rootCtx "objectType" "pod" "objectName" $objectData.shortName) | fromYaml)) -}}
|
||||
{{- with (include "ix.v1.common.lib.metadata.render" (dict "rootCtx" $rootCtx "labels" $labels) | trim) }}
|
||||
labels:
|
||||
{{- . | nindent 8 }}
|
||||
|
||||
@@ -5,8 +5,10 @@ podName is the "shortName" of the pod. The one you define in the .Values.workloa
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.metadata.selectorLabels" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $podName := .podName -}}
|
||||
pod.name: {{ $podName }}
|
||||
{{- $objectType := .objectType -}}
|
||||
{{- $objectName := .objectName }}
|
||||
|
||||
{{ printf "%s.name" $objectType }}: {{ $objectName }}
|
||||
app.kubernetes.io/name: {{ include "ix.v1.common.lib.chart.names.name" $rootCtx }}
|
||||
app.kubernetes.io/instance: {{ $rootCtx.Release.Name }}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user