mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 16:37:04 +02:00
feat(common): Release common library 3.6.0 (#364)
Signed-off-by: solidDoWant <fred.heinecke@yahoo.com> Co-authored-by: solidDoWant <fred.heinecke@yahoo.com>
This commit is contained in:
parent
6d23aa66ca
commit
e68b41ed0a
11 changed files with 240 additions and 9 deletions
|
@ -0,0 +1,58 @@
|
||||||
|
---
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||||
|
suite: pod security
|
||||||
|
templates:
|
||||||
|
- common.yaml
|
||||||
|
values:
|
||||||
|
- ../_values/controllers_main_default_container.yaml
|
||||||
|
capabilities:
|
||||||
|
majorVersion: 1
|
||||||
|
minorVersion: 29
|
||||||
|
tests:
|
||||||
|
- it: default should pass for kubernetes < 1.28
|
||||||
|
capabilities:
|
||||||
|
majorVersion: 1
|
||||||
|
minorVersion: 28
|
||||||
|
asserts:
|
||||||
|
- documentIndex: 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: 0
|
||||||
|
notExists:
|
||||||
|
path: spec.template.spec.hostUsers
|
||||||
|
|
||||||
|
- it: default should pass for kubernetes >= 1.29
|
||||||
|
asserts:
|
||||||
|
- documentIndex: 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: 0
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.hostUsers
|
||||||
|
value: true
|
||||||
|
|
||||||
|
- it: hostUsers disabled should pass
|
||||||
|
set:
|
||||||
|
defaultPodOptions:
|
||||||
|
hostUsers: false
|
||||||
|
asserts:
|
||||||
|
- documentIndex: 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: 0
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.hostUsers
|
||||||
|
value: false
|
||||||
|
|
||||||
|
- it: hostUsers enabled should pass
|
||||||
|
set:
|
||||||
|
defaultPodOptions:
|
||||||
|
hostUsers: true
|
||||||
|
asserts:
|
||||||
|
- documentIndex: 0
|
||||||
|
isKind:
|
||||||
|
of: Deployment
|
||||||
|
- documentIndex: 0
|
||||||
|
equal:
|
||||||
|
path: spec.template.spec.hostUsers
|
||||||
|
value: true
|
|
@ -0,0 +1,66 @@
|
||||||
|
---
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||||
|
suite: "pod metadata: annotations"
|
||||||
|
templates:
|
||||||
|
- common.yaml
|
||||||
|
values:
|
||||||
|
- ../_values/controllers_main_default_container.yaml
|
||||||
|
tests:
|
||||||
|
- it: default pod annotations
|
||||||
|
documentSelector: &DeploymentSelector
|
||||||
|
path: $[?(@.kind == "Deployment")].metadata.name
|
||||||
|
value: RELEASE-NAME
|
||||||
|
asserts:
|
||||||
|
- notExists:
|
||||||
|
path: spec.template.metadata.annotations
|
||||||
|
|
||||||
|
- it: pod annotations from defaultPodOptions should be included
|
||||||
|
set:
|
||||||
|
defaultPodOptions:
|
||||||
|
annotations:
|
||||||
|
defaultPodOptionsAnnotation: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isSubset:
|
||||||
|
path: spec.template.metadata.annotations
|
||||||
|
content:
|
||||||
|
defaultPodOptionsAnnotation: test
|
||||||
|
|
||||||
|
- it: pod annotations from pod options should be included
|
||||||
|
set:
|
||||||
|
controllers:
|
||||||
|
main:
|
||||||
|
pod:
|
||||||
|
annotations:
|
||||||
|
podOptionsAnnotation: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isSubset:
|
||||||
|
path: spec.template.metadata.annotations
|
||||||
|
content:
|
||||||
|
podOptionsAnnotation: test
|
||||||
|
|
||||||
|
- it: pod annotations from global annotations should not be included by default
|
||||||
|
set:
|
||||||
|
global:
|
||||||
|
annotations:
|
||||||
|
globalAnnotation: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isNotSubset:
|
||||||
|
path: spec.template.metadata.annotations
|
||||||
|
content:
|
||||||
|
globalAnnotation: test
|
||||||
|
|
||||||
|
- it: pod annotations from global annotations should be included when requested
|
||||||
|
set:
|
||||||
|
global:
|
||||||
|
propagateGlobalMetadataToPods: true
|
||||||
|
annotations:
|
||||||
|
globalAnnotation: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isSubset:
|
||||||
|
path: spec.template.metadata.annotations
|
||||||
|
content:
|
||||||
|
globalAnnotation: test
|
|
@ -0,0 +1,70 @@
|
||||||
|
---
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||||
|
suite: "pod metadata: labels"
|
||||||
|
templates:
|
||||||
|
- common.yaml
|
||||||
|
values:
|
||||||
|
- ../_values/controllers_main_default_container.yaml
|
||||||
|
tests:
|
||||||
|
- it: default pod labels
|
||||||
|
documentSelector: &DeploymentSelector
|
||||||
|
path: $[?(@.kind == "Deployment")].metadata.name
|
||||||
|
value: RELEASE-NAME
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.template.metadata.labels
|
||||||
|
value:
|
||||||
|
app.kubernetes.io/component: main
|
||||||
|
app.kubernetes.io/instance: RELEASE-NAME
|
||||||
|
app.kubernetes.io/name: RELEASE-NAME
|
||||||
|
|
||||||
|
- it: pod labels from defaultPodOptions should be included
|
||||||
|
set:
|
||||||
|
defaultPodOptions:
|
||||||
|
labels:
|
||||||
|
defaultPodOptionsLabel: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isSubset:
|
||||||
|
path: spec.template.metadata.labels
|
||||||
|
content:
|
||||||
|
defaultPodOptionsLabel: test
|
||||||
|
|
||||||
|
- it: pod labels from pod options should be included
|
||||||
|
set:
|
||||||
|
controllers:
|
||||||
|
main:
|
||||||
|
pod:
|
||||||
|
labels:
|
||||||
|
podOptionsLabel: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isSubset:
|
||||||
|
path: spec.template.metadata.labels
|
||||||
|
content:
|
||||||
|
podOptionsLabel: test
|
||||||
|
|
||||||
|
- it: pod labels from global labels should not be included by default
|
||||||
|
set:
|
||||||
|
global:
|
||||||
|
labels:
|
||||||
|
globalLabel: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isNotSubset:
|
||||||
|
path: spec.template.metadata.labels
|
||||||
|
content:
|
||||||
|
globalLabel: test
|
||||||
|
|
||||||
|
- it: pod labels from global labels should be included when requested
|
||||||
|
set:
|
||||||
|
global:
|
||||||
|
propagateGlobalMetadataToPods: true
|
||||||
|
labels:
|
||||||
|
globalLabel: test
|
||||||
|
documentSelector: *DeploymentSelector
|
||||||
|
asserts:
|
||||||
|
- isSubset:
|
||||||
|
path: spec.template.metadata.labels
|
||||||
|
content:
|
||||||
|
globalLabel: test
|
|
@ -3,7 +3,7 @@ apiVersion: v2
|
||||||
name: common
|
name: common
|
||||||
description: Function library for Helm charts
|
description: Function library for Helm charts
|
||||||
type: library
|
type: library
|
||||||
version: 3.5.1
|
version: 3.6.0
|
||||||
kubeVersion: ">=1.22.0-0"
|
kubeVersion: ">=1.22.0-0"
|
||||||
keywords:
|
keywords:
|
||||||
- common
|
- common
|
||||||
|
@ -16,4 +16,7 @@ annotations:
|
||||||
artifacthub.io/changes: |-
|
artifacthub.io/changes: |-
|
||||||
- kind: added
|
- kind: added
|
||||||
description: |-
|
description: |-
|
||||||
Add feature flag to override enforcing the creation of a default ServiceAccount
|
Add hostUsers field to pod spec for k8s clusters >= 1.29
|
||||||
|
- kind: added
|
||||||
|
description: |-
|
||||||
|
Allow propagating global labels and annotations to Pod metadata
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# common
|
# common
|
||||||
|
|
||||||
 
|
 
|
||||||
|
|
||||||
Function library for Helm charts
|
Function library for Helm charts
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
|
||||||
# Chart.yaml
|
# Chart.yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
version: 3.5.1
|
version: 3.6.0
|
||||||
repository: https://bjw-s.github.io/helm-charts/
|
repository: https://bjw-s.github.io/helm-charts/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,10 @@
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
|
"hostUsers": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"hostname": {
|
"hostname": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|
|
@ -27,6 +27,9 @@ hostname: {{ . | trim }}
|
||||||
hostIPC: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostIPC" "default" false) }}
|
hostIPC: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostIPC" "default" false) }}
|
||||||
hostNetwork: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostNetwork" "default" false) }}
|
hostNetwork: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostNetwork" "default" false) }}
|
||||||
hostPID: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostPID" "default" false) }}
|
hostPID: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostPID" "default" false) }}
|
||||||
|
{{- if ge ($rootContext.Capabilities.KubeVersion.Minor | int) 29 }}
|
||||||
|
hostUsers: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostUsers" "default" true) }}
|
||||||
|
{{- end }}
|
||||||
dnsPolicy: {{ include "bjw-s.common.lib.pod.field.dnsPolicy" (dict "ctx" $ctx) | trim }}
|
dnsPolicy: {{ include "bjw-s.common.lib.pod.field.dnsPolicy" (dict "ctx" $ctx) | trim }}
|
||||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "dnsConfig")) }}
|
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "dnsConfig")) }}
|
||||||
dnsConfig: {{ . | nindent 2 }}
|
dnsConfig: {{ . | nindent 2 }}
|
||||||
|
|
|
@ -6,7 +6,17 @@ Returns the value for annotations
|
||||||
{{- $controllerObject := .controllerObject -}}
|
{{- $controllerObject := .controllerObject -}}
|
||||||
|
|
||||||
{{- /* Default annotations */ -}}
|
{{- /* Default annotations */ -}}
|
||||||
{{- $annotations := dict -}}
|
{{- $annotations := merge
|
||||||
|
(dict)
|
||||||
|
-}}
|
||||||
|
|
||||||
|
{{- /* Include global annotations if specified */ -}}
|
||||||
|
{{- if $rootContext.Values.global.propagateGlobalMetadataToPods -}}
|
||||||
|
{{- $annotations = merge
|
||||||
|
(include "bjw-s.common.lib.metadata.globalAnnotations" $rootContext | fromYaml)
|
||||||
|
$annotations
|
||||||
|
-}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- /* Set to the default if it is set */ -}}
|
{{- /* Set to the default if it is set */ -}}
|
||||||
{{- $defaultOption := get (default dict $rootContext.Values.defaultPodOptions) "annotations" -}}
|
{{- $defaultOption := get (default dict $rootContext.Values.defaultPodOptions) "annotations" -}}
|
||||||
|
|
|
@ -10,6 +10,14 @@ Returns the value for labels
|
||||||
(dict "app.kubernetes.io/component" $controllerObject.identifier)
|
(dict "app.kubernetes.io/component" $controllerObject.identifier)
|
||||||
-}}
|
-}}
|
||||||
|
|
||||||
|
{{- /* Include global labels if specified */ -}}
|
||||||
|
{{- if $rootContext.Values.global.propagateGlobalMetadataToPods -}}
|
||||||
|
{{- $labels = merge
|
||||||
|
(include "bjw-s.common.lib.metadata.globalLabels" $rootContext | fromYaml)
|
||||||
|
$labels
|
||||||
|
-}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
{{- /* Fetch the Pod selectorLabels */ -}}
|
{{- /* Fetch the Pod selectorLabels */ -}}
|
||||||
{{- $selectorLabels := include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml -}}
|
{{- $selectorLabels := include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | fromYaml -}}
|
||||||
{{- if not (empty $selectorLabels) -}}
|
{{- if not (empty $selectorLabels) -}}
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.5.1/charts/library/common/values.schema.json",
|
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.6.0/charts/library/common/values.schema.json",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"global": {
|
"global": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"annotations": {
|
|
||||||
"$ref": "schemas/definitions.json#/annotations"
|
|
||||||
},
|
|
||||||
"nameOverride": {
|
"nameOverride": {
|
||||||
"type": [
|
"type": [
|
||||||
"string",
|
"string",
|
||||||
|
@ -21,8 +18,15 @@
|
||||||
"null"
|
"null"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"propagateGlobalMetadataToPods": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"$ref": "schemas/definitions.json#/labels"
|
"$ref": "schemas/definitions.json#/labels"
|
||||||
|
},
|
||||||
|
"annotations": {
|
||||||
|
"$ref": "schemas/definitions.json#/annotations"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,6 +4,8 @@ global:
|
||||||
nameOverride:
|
nameOverride:
|
||||||
# -- Set the entire name definition
|
# -- Set the entire name definition
|
||||||
fullnameOverride:
|
fullnameOverride:
|
||||||
|
# -- Propagate global metadata to Pod labels.
|
||||||
|
propagateGlobalMetadataToPods: false
|
||||||
# -- Set additional global labels. Helm templates can be used.
|
# -- Set additional global labels. Helm templates can be used.
|
||||||
labels: {}
|
labels: {}
|
||||||
# -- Set additional global annotations. Helm templates can be used.
|
# -- Set additional global annotations. Helm templates can be used.
|
||||||
|
@ -48,6 +50,9 @@ defaultPodOptions:
|
||||||
# -- Use the host's pid namespace
|
# -- Use the host's pid namespace
|
||||||
hostPID: false
|
hostPID: false
|
||||||
|
|
||||||
|
# -- Use the host's user namespace (requires 1.29 or newer)
|
||||||
|
hostUsers: true
|
||||||
|
|
||||||
# -- Set image pull secrets
|
# -- Set image pull secrets
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue