mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
feat(common): Release library 3.7.0 (#377)
Signed-off-by: solidDoWant <fred.heinecke@yahoo.com> Co-authored-by: Patrick Collins <Patricol@users.noreply.github.com> Co-authored-by: Patrick Collins <patrick.collins@gainbridge.io> Co-authored-by: Lawrence Gil <larrywtf609@gmail.com> Co-authored-by: solidDoWant <fred.heinecke@yahoo.com>
This commit is contained in:
parent
aee0d999ba
commit
8b33237e27
32 changed files with 793 additions and 655 deletions
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
@ -1,2 +0,0 @@
|
|||
test:
|
||||
test: "{{ .Values.configMapsFromFolderBasePath }}"
|
|
@ -0,0 +1,2 @@
|
|||
test:
|
||||
test: "{{ .Values.global.random.nonExistentKey }}"
|
|
@ -15,7 +15,7 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 1
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
|
@ -43,7 +43,7 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 1
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
|
@ -79,7 +79,7 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 1
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
|
@ -99,17 +99,39 @@ tests:
|
|||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: default configuration from folder with binary files should fail
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "There was an error loading ConfigMap: test_2. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`"
|
||||
|
||||
- it: default metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolderBasePath: ci/configMapsFolder
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 1
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
|
@ -123,7 +145,7 @@ tests:
|
|||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
- documentIndex: &SecondConfigmapDocument 2
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
|
@ -137,7 +159,7 @@ tests:
|
|||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
- documentIndex: &ThirdConfigmapDocument 3
|
||||
- documentIndex: &ThirdConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
|
@ -151,3 +173,66 @@ tests:
|
|||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
|
||||
- it: custom metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
labels:
|
||||
test: test_label
|
||||
annotations:
|
||||
test: test_annotation
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
- documentIndex: &ThirdConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test: test_label
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test: test_annotation
|
||||
|
|
|
@ -42,13 +42,13 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 3
|
||||
- documentIndex: &FirstConfigmapDocument 1
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
isNotNullOrEmpty:
|
||||
path: metadata.name
|
||||
- documentIndex: &SecondConfigmapDocument 2
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
|
@ -64,7 +64,7 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 1
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
|
@ -82,7 +82,7 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 1
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
|
@ -100,7 +100,7 @@ tests:
|
|||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ConfigmapDocument 1
|
||||
- documentIndex: &ConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ConfigmapDocument
|
||||
|
@ -115,28 +115,82 @@ tests:
|
|||
data:
|
||||
test: test
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
configMapsFromFolderBasePath: ci/configMapsFolder
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 1
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: &SecondConfigmapDocument 2
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test_1
|
||||
- documentIndex: &ThirdConfigmapDocument 3
|
||||
- documentIndex: &ThirdConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test_2
|
||||
|
||||
- it: with templated nameOverride and from folder with forceRename should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
data:
|
||||
test: test
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_1:
|
||||
forceRename: &newName1 newName1
|
||||
test_2:
|
||||
forceRename: &newName2 newName2
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: &FirstConfigmapDocument 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *FirstConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: &SecondConfigmapDocument 1
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *SecondConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: *newName1
|
||||
- documentIndex: &ThirdConfigmapDocument 2
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: *ThirdConfigmapDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: *newName2
|
||||
|
|
|
@ -25,7 +25,7 @@ tests:
|
|||
data:
|
||||
test: value 1
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 0
|
||||
- documentIndex: &ControllerDoc 3
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
|
@ -33,3 +33,41 @@ tests:
|
|||
path: spec.template.metadata.annotations
|
||||
value:
|
||||
checksum/configMaps: 66d23d7a53c4e2a523ba85a969696b4ebb78ec5d79ab9c12c210c1569f48511b
|
||||
|
||||
- it: default metadata from folder should pass
|
||||
set:
|
||||
configMaps:
|
||||
config:
|
||||
enabled: true
|
||||
data:
|
||||
test: value 1
|
||||
test_default_enabled:
|
||||
data:
|
||||
test: value 1
|
||||
test_not_in_checksum:
|
||||
includeInChecksum: false
|
||||
data:
|
||||
test: value 1
|
||||
test_disabled:
|
||||
enabled: false
|
||||
data:
|
||||
test: value 1
|
||||
configMapsFromFolder:
|
||||
enabled: true
|
||||
basePath: ci/configMapsFolder
|
||||
configMapsOverrides:
|
||||
test_2:
|
||||
fileAttributeOverrides:
|
||||
helm.jpg:
|
||||
binary: true
|
||||
test_2.yaml:
|
||||
escaped: true
|
||||
asserts:
|
||||
- documentIndex: &ControllerDoc 5
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *ControllerDoc
|
||||
equal:
|
||||
path: spec.template.metadata.annotations
|
||||
value:
|
||||
checksum/configMaps: e83a24569d0b4f2ccc44aec36d4e9a1c44a29bcc92eefdffe14fb1ce81dff054
|
||||
|
|
|
@ -108,7 +108,7 @@ tests:
|
|||
data:
|
||||
test: test
|
||||
asserts:
|
||||
- documentIndex: &DeploymentDoc 0
|
||||
- documentIndex: &DeploymentDoc 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *DeploymentDoc
|
||||
|
|
|
@ -5,119 +5,91 @@ templates:
|
|||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
controllers.main.containers.main.probes.liveness.enabled: true
|
||||
controllers.main.containers.main.probes.readiness.enabled: true
|
||||
controllers.main.containers.main.probes.startup.enabled: true
|
||||
|
||||
tests:
|
||||
- it: default should pass
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
enabled: true
|
||||
port: &port 80
|
||||
- it: default probes
|
||||
documentSelector: &DeploymentSelector
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: 8081
|
||||
timeoutSeconds: 1
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: 8081
|
||||
timeoutSeconds: 1
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].startupProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: 8081
|
||||
timeoutSeconds: 1
|
||||
|
||||
- it: custom primary port should pass
|
||||
- it: custom primary port gets picked up by probes
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
enabled: true
|
||||
port: 80
|
||||
test:
|
||||
service.main.ports.test:
|
||||
enabled: true
|
||||
primary: true
|
||||
port: &port 8080
|
||||
port: 8080
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: 8080
|
||||
timeoutSeconds: 1
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: 8080
|
||||
timeoutSeconds: 1
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].startupProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: 8080
|
||||
timeoutSeconds: 1
|
||||
|
||||
- it: default with string Service port should pass
|
||||
- it: probes with string Service port
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
enabled: true
|
||||
port: "80"
|
||||
service.main.ports.http.port: "80"
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
|
@ -126,8 +98,7 @@ tests:
|
|||
tcpSocket:
|
||||
port: 80
|
||||
timeoutSeconds: 1
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
|
@ -136,8 +107,7 @@ tests:
|
|||
tcpSocket:
|
||||
port: 80
|
||||
timeoutSeconds: 1
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].startupProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
|
@ -147,7 +117,7 @@ tests:
|
|||
port: 80
|
||||
timeoutSeconds: 1
|
||||
|
||||
- it: multiple services should pass
|
||||
- it: multiple services are handled correctly
|
||||
set:
|
||||
controllers:
|
||||
other:
|
||||
|
@ -170,81 +140,69 @@ tests:
|
|||
ports:
|
||||
http:
|
||||
enabled: true
|
||||
port: &secondDeploymentPort 8080
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
enabled: true
|
||||
port: &firstDeploymentPort 80
|
||||
port: 8080
|
||||
asserts:
|
||||
- documentIndex: &firstDeploymentDocument 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *firstDeploymentDocument
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe.tcpSocket.port
|
||||
value: *firstDeploymentPort
|
||||
- documentIndex: *firstDeploymentDocument
|
||||
value: 8081
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port
|
||||
value: *firstDeploymentPort
|
||||
- documentIndex: *firstDeploymentDocument
|
||||
value: 8081
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].startupProbe.tcpSocket.port
|
||||
value: *firstDeploymentPort
|
||||
- documentIndex: &secondDeploymentDocument 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *secondDeploymentDocument
|
||||
value: 8081
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME-other
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe.tcpSocket.port
|
||||
value: *secondDeploymentPort
|
||||
- documentIndex: *secondDeploymentDocument
|
||||
value: 8080
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME-other
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe.tcpSocket.port
|
||||
value: *secondDeploymentPort
|
||||
- documentIndex: *secondDeploymentDocument
|
||||
value: 8080
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME-other
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].startupProbe.tcpSocket.port
|
||||
value: *secondDeploymentPort
|
||||
value: 8080
|
||||
|
||||
- it: disabled service should pass
|
||||
- it: no probes are defined when services are disabled
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
enabled: false
|
||||
controller: main
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
- notExists:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
- notExists:
|
||||
path: spec.template.spec.containers[0].readinessProbe
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
- notExists:
|
||||
path: spec.template.spec.containers[0].startupProbe
|
||||
|
||||
- it: AUTO type probe should pass
|
||||
- it: AUTO type probe can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
protocol: HTTP
|
||||
port: &port 80
|
||||
|
||||
service.main.ports.http.protocol: HTTP
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
type: AUTO
|
||||
path: /api/version
|
||||
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
|
@ -255,86 +213,95 @@ tests:
|
|||
value:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: HTTP type probe should pass
|
||||
- it: HTTP type probe can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
type: HTTP
|
||||
path: /api/version
|
||||
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: HTTPS type probe should pass
|
||||
- it: HTTPS type probe can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
type: HTTPS
|
||||
path: /api/version
|
||||
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
scheme: HTTPS
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: custom liveness probe should pass
|
||||
- it: GRPC type probe can be configured without service
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
type: GRPC
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
grpc:
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: GRPC type probe can be configured with service
|
||||
set:
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
type: GRPC
|
||||
service: test
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
grpc:
|
||||
port: 8081
|
||||
service: test
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: custom liveness probe can be configured
|
||||
set:
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
|
@ -342,36 +309,26 @@ tests:
|
|||
spec:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: custom readiness probe should pass
|
||||
- it: custom readiness probe can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
readiness:
|
||||
enabled: true
|
||||
|
@ -379,36 +336,26 @@ tests:
|
|||
spec:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe
|
||||
value:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: custom startup probe should pass
|
||||
- it: custom startup probe can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
startup:
|
||||
enabled: true
|
||||
|
@ -416,45 +363,32 @@ tests:
|
|||
spec:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].startupProbe
|
||||
value:
|
||||
httpGet:
|
||||
path: /api/version
|
||||
port: *port
|
||||
port: 8081
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 1
|
||||
failureThreshold: 3
|
||||
|
||||
- it: User-defined liveness probe port should pass
|
||||
- it: User-defined liveness probe port can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
port: &port http
|
||||
|
||||
port: http
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
|
@ -463,92 +397,41 @@ tests:
|
|||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: http
|
||||
timeoutSeconds: 1
|
||||
|
||||
- it: User-defined liveness probe port should pass
|
||||
- it: User-defined readiness probe port can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
liveness:
|
||||
enabled: true
|
||||
port: &port http
|
||||
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
path: spec.template.spec.containers[0].livenessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
timeoutSeconds: 1
|
||||
|
||||
- it: User-defined readiness probe port should pass
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
readiness:
|
||||
enabled: true
|
||||
port: &port http
|
||||
|
||||
port: http
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].readinessProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: http
|
||||
timeoutSeconds: 1
|
||||
|
||||
- it: User-defined startup probe port should pass
|
||||
- it: User-defined startup probe port can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: &port 80
|
||||
|
||||
controllers.main.containers.main.probes:
|
||||
startup:
|
||||
enabled: true
|
||||
port: &port http
|
||||
|
||||
port: http
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].startupProbe
|
||||
value:
|
||||
failureThreshold: 3
|
||||
initialDelaySeconds: 0
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: *port
|
||||
port: http
|
||||
timeoutSeconds: 1
|
||||
|
|
|
@ -54,9 +54,12 @@ tests:
|
|||
identifier: mySettings
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: ConfigMap
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
- documentIndex: 1
|
||||
equal:
|
||||
path: spec.template.spec.volumes[0]
|
||||
value:
|
||||
|
|
|
@ -6,16 +6,15 @@ templates:
|
|||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
- it: affinity is not present by default
|
||||
documentSelector: &DeploymentSelector
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
notExists:
|
||||
- notExists:
|
||||
path: spec.template.spec.affinity
|
||||
|
||||
- it: defaultPodOption should pass
|
||||
- it: affinity can be set with defaultPodOption
|
||||
set:
|
||||
defaultPodOptions:
|
||||
affinity:
|
||||
|
@ -28,12 +27,9 @@ tests:
|
|||
values:
|
||||
- antarctica-east1
|
||||
- antarctica-west1
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.affinity
|
||||
value:
|
||||
nodeAffinity:
|
||||
|
@ -46,7 +42,7 @@ tests:
|
|||
- antarctica-east1
|
||||
- antarctica-west1
|
||||
|
||||
- it: defaultPodOption with pod override should pass
|
||||
- it: affinity can be set with defaultPodOption and overridden on pod level
|
||||
set:
|
||||
defaultPodOptions:
|
||||
affinity:
|
||||
|
@ -72,12 +68,9 @@ tests:
|
|||
values:
|
||||
- asia-east1
|
||||
- asia-west1
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- documentIndex: 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: 0
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.template.spec.affinity
|
||||
value:
|
||||
nodeAffinity:
|
||||
|
@ -89,3 +82,33 @@ tests:
|
|||
values:
|
||||
- asia-east1
|
||||
- asia-west1
|
||||
|
||||
- it: affinity can be configured with templated valued
|
||||
set:
|
||||
controllers:
|
||||
main:
|
||||
pod:
|
||||
affinity:
|
||||
podAntiAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- "{{ .Release.Name }}"
|
||||
topologyKey: kubernetes.io/hostname
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.affinity
|
||||
value:
|
||||
podAntiAffinity:
|
||||
requiredDuringSchedulingIgnoredDuringExecution:
|
||||
- labelSelector:
|
||||
matchExpressions:
|
||||
- key: app
|
||||
operator: In
|
||||
values:
|
||||
- RELEASE-NAME
|
||||
topologyKey: kubernetes.io/hostname
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
# 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
|
||||
tests:
|
||||
- it: shareProcessNamespace should not be present by default
|
||||
documentSelector: &DeploymentSelector
|
||||
path: $[?(@.kind == "Deployment")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- notExists:
|
||||
path: spec.template.spec.shareProcessNamespace
|
||||
|
||||
- it: shareProcessNamespace disabled should pass
|
||||
set:
|
||||
defaultPodOptions:
|
||||
shareProcessNamespace: false
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.shareProcessNamespace
|
||||
value: false
|
||||
|
||||
- it: shareProcessNamespace enabled should pass
|
||||
set:
|
||||
defaultPodOptions:
|
||||
shareProcessNamespace: true
|
||||
documentSelector: *DeploymentSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.shareProcessNamespace
|
||||
value: true
|
|
@ -13,18 +13,14 @@ set:
|
|||
spec:
|
||||
test: test
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
- it: default metadata should be present
|
||||
documentSelector: &EndpointSelector
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME-config
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
notExists:
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
@ -32,7 +28,7 @@ tests:
|
|||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
|
||||
- it: custom metadata should pass
|
||||
- it: custom metadata can be configured
|
||||
set:
|
||||
rawResources:
|
||||
config:
|
||||
|
@ -40,19 +36,13 @@ tests:
|
|||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
documentSelector: *EndpointSelector
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
@ -61,7 +51,7 @@ tests:
|
|||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
- it: global metadata can be configured with local overrides
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
|
@ -74,20 +64,14 @@ tests:
|
|||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
documentSelector: *EndpointSelector
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
|
|
@ -19,28 +19,24 @@ set:
|
|||
port: 443
|
||||
protocol: TCP
|
||||
tests:
|
||||
- it: default should pass
|
||||
- it: raw resources can be configured
|
||||
documentSelector: &EndpointSelector
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME-endpoint
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: subsets[0].addresses[0].ip
|
||||
value: 127.0.0.1
|
||||
|
||||
- it: nameOverride should pass
|
||||
- it: nameOverride can be configured
|
||||
set:
|
||||
rawResources.endpoint:
|
||||
nameOverride: test
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
asserts:
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
|
@ -48,16 +44,15 @@ tests:
|
|||
set:
|
||||
rawResources.endpoint:
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Endpoint")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: spec with template should pass
|
||||
- it: spec can render Helm template
|
||||
set:
|
||||
rawResources.endpoint:
|
||||
spec:
|
||||
|
@ -68,11 +63,8 @@ tests:
|
|||
- name: "{{ .Release.Name }}"
|
||||
port: 443
|
||||
protocol: TCP
|
||||
documentSelector: *EndpointSelector
|
||||
asserts:
|
||||
- documentIndex: &rawResourceDocument 1
|
||||
isKind:
|
||||
of: Endpoint
|
||||
- documentIndex: *rawResourceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: subsets[0].ports[0].name
|
||||
value: RELEASE-NAME
|
||||
|
|
|
@ -6,18 +6,16 @@ templates:
|
|||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
- it: default metadata
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
documentSelector: &ServiceSelector
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
notExists:
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
@ -26,7 +24,7 @@ tests:
|
|||
app.kubernetes.io/service: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
|
||||
- it: custom metadata should pass
|
||||
- it: custom metadata
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -36,17 +34,13 @@ tests:
|
|||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
@ -56,7 +50,7 @@ tests:
|
|||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
- it: custom metadata with global metadata
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -71,18 +65,14 @@ tests:
|
|||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
|
|
@ -6,49 +6,42 @@ templates:
|
|||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
- it: default name
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: custom name suffix should pass
|
||||
- it: custom name suffix
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.nameOverride: http
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME-http
|
||||
asserts:
|
||||
- exists:
|
||||
path: metadata.name
|
||||
|
||||
- it: custom name suffix with template should pass
|
||||
- it: custom name suffix with template
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.nameOverride: "{{ .Release.Name }}"
|
||||
service.main.nameOverride: "{{ .Chart.Name }}"
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME-common-test
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- exists:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: multiple should pass
|
||||
- it: multiple services
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -59,19 +52,13 @@ tests:
|
|||
ui:
|
||||
port: 8082
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 3
|
||||
- documentIndex: &ServiceDocumentFirst 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocumentFirst
|
||||
equal:
|
||||
path: metadata.name
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
- documentIndex: &ServiceDocumentSecond 2
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocumentSecond
|
||||
equal:
|
||||
exists:
|
||||
path: metadata.name
|
||||
- documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME-second
|
||||
exists:
|
||||
path: metadata.name
|
||||
|
|
|
@ -6,89 +6,91 @@ templates:
|
|||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
- it: default should render
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
documentSelector: &ServiceSelector
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0].protocol
|
||||
value: TCP
|
||||
|
||||
- it: explicit TCP should pass
|
||||
- it: explicit TCP should render
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.ports.http.protocol: TCP
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0].protocol
|
||||
value: TCP
|
||||
|
||||
- it: explicit UDP should pass
|
||||
- it: explicit UDP should render
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.ports.http.protocol: UDP
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0].protocol
|
||||
value: UDP
|
||||
|
||||
- it: explicit HTTP should pass
|
||||
- it: explicit HTTP should render
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.ports.http.protocol: HTTP
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0].protocol
|
||||
value: TCP
|
||||
- documentIndex: *ServiceDocument
|
||||
notExists:
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
|
||||
- it: explicit HTTPS should pass
|
||||
- it: explicit HTTPS should render
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.ports.http.protocol: HTTPS
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0].protocol
|
||||
value: TCP
|
||||
|
||||
- it: explicit appProtocol should pass
|
||||
- it: explicit appProtocol should render
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.ports.http.appProtocol: kubernetes.io/h2c
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0].appProtocol
|
||||
value: kubernetes.io/h2c
|
||||
|
||||
- it: mixed protocols can be configured on the same port number
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service.main.ports.udptest:
|
||||
port: 8081
|
||||
protocol: UDP
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.ports
|
||||
value:
|
||||
- name: http
|
||||
port: 8081
|
||||
protocol: TCP
|
||||
targetPort: 8081
|
||||
- name: udptest
|
||||
port: 8081
|
||||
protocol: UDP
|
||||
targetPort: 8081
|
||||
|
|
|
@ -9,14 +9,11 @@ tests:
|
|||
- it: default should pass
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
documentSelector: &ServiceSelector
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0]
|
||||
value:
|
||||
name: http
|
||||
|
@ -36,12 +33,9 @@ tests:
|
|||
server:
|
||||
enabled: true
|
||||
port: 8080
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0]
|
||||
value:
|
||||
name: server
|
||||
|
@ -59,12 +53,9 @@ tests:
|
|||
http:
|
||||
enabled: true
|
||||
targetPort: 80
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.ports[0]
|
||||
value:
|
||||
name: http
|
||||
|
|
|
@ -15,17 +15,16 @@ tests:
|
|||
ports:
|
||||
first:
|
||||
port: 80
|
||||
documentSelector: &ServiceSelector
|
||||
path: kind
|
||||
value: Service
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &FirstServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *FirstServiceDocument
|
||||
notExists:
|
||||
path: spec.allocateLoadBalancerNodePorts
|
||||
- containsDocument:
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
name: RELEASE-NAME
|
||||
|
||||
- it: services can be disabled
|
||||
- it: service not present when disabled
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -33,13 +32,13 @@ tests:
|
|||
main:
|
||||
enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: &DeploymentDocument 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- not: true
|
||||
containsDocument:
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
name: RELEASE-NAME
|
||||
|
||||
- it: externalTrafficPolicy should pass for NodePort service
|
||||
- it: externalTrafficPolicy can be configured for NodePort service
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -47,32 +46,26 @@ tests:
|
|||
main:
|
||||
type: NodePort
|
||||
externalTrafficPolicy: Local
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.externalTrafficPolicy
|
||||
value: Local
|
||||
|
||||
- it: internalTrafficPolicy should pass
|
||||
- it: internalTrafficPolicy can be configured
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
internalTrafficPolicy: Local
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.internalTrafficPolicy
|
||||
value: Local
|
||||
|
||||
- it: externalTrafficPolicy should pass for LoadBalancer service
|
||||
- it: externalTrafficPolicy can be configured for LoadBalancer service
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -80,12 +73,9 @@ tests:
|
|||
main:
|
||||
type: LoadBalancer
|
||||
externalTrafficPolicy: Local
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.externalTrafficPolicy
|
||||
value: Local
|
||||
|
||||
|
@ -97,12 +87,9 @@ tests:
|
|||
main:
|
||||
type: LoadBalancer
|
||||
allocateLoadBalancerNodePorts: true
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.allocateLoadBalancerNodePorts
|
||||
value: true
|
||||
|
||||
|
@ -114,16 +101,13 @@ tests:
|
|||
main:
|
||||
type: LoadBalancer
|
||||
allocateLoadBalancerNodePorts: false
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.allocateLoadBalancerNodePorts
|
||||
value: false
|
||||
|
||||
- it: externalName should pass for ExternalName service
|
||||
- it: externalName can be configured for ExternalName service
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
|
@ -131,11 +115,8 @@ tests:
|
|||
main:
|
||||
type: ExternalName
|
||||
externalName: my.database.example.com
|
||||
documentSelector: *ServiceSelector
|
||||
asserts:
|
||||
- documentIndex: &ServiceDocument 1
|
||||
isKind:
|
||||
of: Service
|
||||
- documentIndex: *ServiceDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.externalName
|
||||
value: my.database.example.com
|
||||
|
|
|
@ -8,12 +8,11 @@ values:
|
|||
tests:
|
||||
- it: a serviceMonitor is not created by default
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- not: true
|
||||
containsDocument:
|
||||
kind: ServiceMonitor
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
name: RELEASE-NAME
|
||||
|
||||
- it: a serviceMonitor is not created when disabled
|
||||
set:
|
||||
|
@ -22,14 +21,13 @@ tests:
|
|||
enabled: false
|
||||
serviceName: "{{ .Release.Name }}"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- not: true
|
||||
containsDocument:
|
||||
kind: ServiceMonitor
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
name: RELEASE-NAME
|
||||
|
||||
- it: a serviceMonitor is created
|
||||
- it: a serviceMonitor can be configured
|
||||
set:
|
||||
serviceMonitor:
|
||||
main:
|
||||
|
@ -42,35 +40,25 @@ tests:
|
|||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceMonitorDocument 1
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
documentSelector: &ServiceMonitorSelector
|
||||
path: $[?(@.kind == "ServiceMonitor")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.namespaceSelector
|
||||
value:
|
||||
matchNames:
|
||||
- NAMESPACE
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.jobLabel
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
app.kubernetes.io/service: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.endpoints
|
||||
value:
|
||||
- port: http
|
||||
|
@ -78,8 +66,7 @@ tests:
|
|||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
|
@ -88,7 +75,7 @@ tests:
|
|||
helm.sh/chart: common-test-1.0.0
|
||||
test.label: testvalue
|
||||
|
||||
- it: a serviceMonitor is created with nameOverride
|
||||
- it: a serviceMonitor can be created with a nameOverride
|
||||
set:
|
||||
serviceMonitor:
|
||||
main:
|
||||
|
@ -100,25 +87,18 @@ tests:
|
|||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceMonitorDocument 1
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "ServiceMonitor")].metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
app.kubernetes.io/service: RELEASE-NAME
|
||||
|
||||
- it: a serviceMonitor is created with a templated service
|
||||
- it: a templated service can be configured
|
||||
set:
|
||||
serviceMonitor:
|
||||
main:
|
||||
|
@ -129,25 +109,16 @@ tests:
|
|||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
documentSelector: *ServiceMonitorSelector
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceMonitorDocument 1
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
app.kubernetes.io/service: RELEASE-NAME
|
||||
|
||||
- it: a serviceMonitor is created with a custom selector
|
||||
- it: a custom selector can be configured
|
||||
set:
|
||||
serviceMonitor:
|
||||
main:
|
||||
|
@ -160,25 +131,16 @@ tests:
|
|||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
documentSelector: *ServiceMonitorSelector
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceMonitorDocument 1
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.selector
|
||||
value:
|
||||
matchExpressions:
|
||||
- key: k8s-app
|
||||
operator: Exists
|
||||
|
||||
- it: a serviceMonitor is created with targetLabels
|
||||
- it: targetLabels can be configured
|
||||
set:
|
||||
serviceMonitor:
|
||||
main:
|
||||
|
@ -193,25 +155,15 @@ tests:
|
|||
targetLabels:
|
||||
- testlabel1
|
||||
- testlabel2
|
||||
documentSelector: *ServiceMonitorSelector
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: &ServiceMonitorDocument 1
|
||||
isKind:
|
||||
of: ServiceMonitor
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.selector.matchLabels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
app.kubernetes.io/service: RELEASE-NAME
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.endpoints
|
||||
value:
|
||||
- port: http
|
||||
|
@ -219,9 +171,48 @@ tests:
|
|||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
- documentIndex: *ServiceMonitorDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.targetLabels
|
||||
value:
|
||||
- testlabel1
|
||||
- testlabel2
|
||||
|
||||
- it: a serviceMonitor can be configured with templated endpoints
|
||||
set:
|
||||
serviceMonitor:
|
||||
main:
|
||||
labels:
|
||||
test.label: testvalue
|
||||
serviceName: "{{ .Release.Name }}"
|
||||
endpoints:
|
||||
- port: http
|
||||
scheme: http
|
||||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
basicAuth:
|
||||
username:
|
||||
name: "{{.Release.Name}}-secret"
|
||||
key: USERNAME
|
||||
password:
|
||||
name: "{{.Release.Name}}-secret"
|
||||
key: PASSWORD
|
||||
documentSelector: &ServiceMonitorSelector
|
||||
path: $[?(@.kind == "ServiceMonitor")].metadata.name
|
||||
value: RELEASE-NAME
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.endpoints
|
||||
value:
|
||||
- port: http
|
||||
scheme: http
|
||||
path: /metrics
|
||||
interval: 1m
|
||||
scrapeTimeout: 10s
|
||||
basicAuth:
|
||||
username:
|
||||
name: RELEASE-NAME-secret
|
||||
key: USERNAME
|
||||
password:
|
||||
name: RELEASE-NAME-secret
|
||||
key: PASSWORD
|
||||
|
|
|
@ -3,7 +3,7 @@ apiVersion: v2
|
|||
name: common
|
||||
description: Function library for Helm charts
|
||||
type: library
|
||||
version: 3.6.1
|
||||
version: 3.7.0
|
||||
kubeVersion: ">=1.22.0-0"
|
||||
keywords:
|
||||
- common
|
||||
|
@ -16,10 +16,22 @@ annotations:
|
|||
artifacthub.io/changes: |-
|
||||
- kind: fixed
|
||||
description: |-
|
||||
Only add hostUsers when explicitly configured
|
||||
- kind: fixed
|
||||
Raw resources with `forceRename` fields are no longer flagged as invalid
|
||||
- kind: added
|
||||
description: |-
|
||||
`hosts` should be an optional field for Ingress resources
|
||||
- kind: fixed
|
||||
Allow setting pullPolicy to Never
|
||||
- kind: added
|
||||
description: |-
|
||||
`defaultBackend` should be an object for Ingress resources
|
||||
Revamped configMap.fromFiles into configMap.fromFolder
|
||||
- kind: added
|
||||
description: |-
|
||||
Add support for setting shareProcessNamespace on Pods
|
||||
- kind: added
|
||||
description: |-
|
||||
Add support for templating ServiceMonitor endpoints
|
||||
- kind: added
|
||||
description: |-
|
||||
Add support for templating Pod affinity
|
||||
- kind: added
|
||||
description: |-
|
||||
Add support for configuring gRPC probes
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# common
|
||||
|
||||
 
|
||||
 
|
||||
|
||||
Function library for Helm charts
|
||||
|
||||
|
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
|
|||
# Chart.yaml
|
||||
dependencies:
|
||||
- name: common
|
||||
version: 3.6.1
|
||||
version: 3.7.0
|
||||
repository: https://bjw-s.github.io/helm-charts/
|
||||
```
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@
|
|||
"properties": {
|
||||
"pullPolicy": {
|
||||
"type": "string",
|
||||
"enum": ["Always", "IfNotPresent"]
|
||||
"enum": ["Always", "IfNotPresent", "Never"]
|
||||
},
|
||||
"repository": {
|
||||
"type": "string"
|
||||
|
@ -206,12 +206,15 @@
|
|||
"port": {
|
||||
"type": ["number", "string"]
|
||||
},
|
||||
"service": {
|
||||
"type": "string"
|
||||
},
|
||||
"spec": {
|
||||
"$ref": "k8s-api.json#/core.v1.Probe"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["TCP", "HTTP", "HTTPS", "AUTO"]
|
||||
"enum": ["TCP", "HTTP", "HTTPS", "GRPC", "AUTO"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,10 @@
|
|||
"securityContext": {
|
||||
"$ref": "k8s-api.json#/core.v1.PodSecurityContext"
|
||||
},
|
||||
"shareProcessNamespace": {
|
||||
"type": ["boolean", "null"],
|
||||
"default": false
|
||||
},
|
||||
"terminationGracePeriodSeconds": {
|
||||
"type": ["integer", "null"]
|
||||
},
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
"nameOverride": {
|
||||
"type": "string"
|
||||
},
|
||||
"forceRename": {
|
||||
"type": "string"
|
||||
},
|
||||
"spec": {}
|
||||
},
|
||||
"required": ["apiVersion", "kind", "spec"]
|
||||
|
|
|
@ -39,7 +39,7 @@ spec:
|
|||
app.kubernetes.io/service: {{ tpl $serviceMonitorObject.serviceName $rootContext }}
|
||||
{{- include "bjw-s.common.lib.metadata.selectorLabels" $rootContext | nindent 6 }}
|
||||
{{- end }}
|
||||
endpoints: {{- toYaml $serviceMonitorObject.endpoints | nindent 4 }}
|
||||
endpoints: {{- tpl (toYaml $serviceMonitorObject.endpoints) $rootContext | nindent 4 }}
|
||||
{{- if not (empty $serviceMonitorObject.targetLabels )}}
|
||||
targetLabels:
|
||||
{{- toYaml $serviceMonitorObject.targetLabels | nindent 4 }}
|
||||
|
|
|
@ -4,8 +4,28 @@ Validate configMap values
|
|||
{{- define "bjw-s.common.lib.configMap.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $configMapValues := .object -}}
|
||||
{{- $identifier := .id -}}
|
||||
|
||||
{{- if empty $configMapValues -}}
|
||||
{{- fail (printf "There was an error loading ConfigMap: %s. If it was automatically generated from a folder verify that files are properly flagged as `binary` or `escaped`" $identifier) -}}
|
||||
{{- end -}}
|
||||
{{- if and (empty (get $configMapValues "data")) (empty (get $configMapValues "binaryData")) -}}
|
||||
{{- fail (printf "No data or binaryData specified for configMap. (configMap: %s)" $configMapValues.identifier) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Validate configMap from folder values
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.configMap.fromFolder.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $basePath := required "If you're using `configMapsFromFolder` you need to specify a `basePath` key" .basePath -}}
|
||||
{{ $topLevelFolders := dict}}
|
||||
{{- range $path, $_ := $rootContext.Files.Glob (printf "%s/*/*" $basePath) -}}
|
||||
{{- $_ := set $topLevelFolders (dir $path) "" -}}
|
||||
{{- end -}}
|
||||
{{- $topLevelFoldersList := keys $topLevelFolders | sortAlpha -}}
|
||||
{{- if empty $topLevelFoldersList -}}
|
||||
{{- fail (printf "No configMaps found in the folder %s" $basePath) }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -54,7 +54,13 @@ Probes used by the container.
|
|||
"scheme" $probeType
|
||||
)
|
||||
-}}
|
||||
{{- else }}
|
||||
{{- else if (eq $probeType "GRPC") -}}
|
||||
{{- $probeHeader = "grpc" -}}
|
||||
{{- $_ := set $probeDefinition $probeHeader dict -}}
|
||||
{{- if $probeValues.service -}}
|
||||
{{- $_ := set (index $probeDefinition $probeHeader) "service" $probeValues.service -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $probeHeader = "tcpSocket" -}}
|
||||
{{- $_ := set $probeDefinition $probeHeader dict -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -31,6 +31,9 @@ hostPID: {{ include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "
|
|||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "hostUsers")) }}
|
||||
hostUsers: {{ . | trim }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "shareProcessNamespace")) }}
|
||||
shareProcessNamespace: {{ . | trim }}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
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")) }}
|
||||
|
@ -52,7 +55,7 @@ restartPolicy: {{ . | trim }}
|
|||
nodeSelector: {{ . | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "affinity")) }}
|
||||
affinity: {{ . | nindent 2 }}
|
||||
affinity: {{- tpl . $rootContext | nindent 2 }}
|
||||
{{- end -}}
|
||||
{{- with (include "bjw-s.common.lib.pod.getOption" (dict "ctx" $ctx "option" "topologySpreadConstraints")) }}
|
||||
topologySpreadConstraints: {{ . | nindent 2 }}
|
||||
|
|
|
@ -8,13 +8,13 @@ Secondary entrypoint and primary loader for the common chart
|
|||
{{- /* Build the templates */ -}}
|
||||
{{- include "bjw-s.common.render.pvcs" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceAccount" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps.fromFolder" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.controllers" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.services" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.ingresses" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.serviceMonitors" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.routes" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps.fromFiles" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.configMaps" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.secrets" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.networkpolicies" . | nindent 0 -}}
|
||||
{{- include "bjw-s.common.render.rawResources" . | nindent 0 -}}
|
||||
|
|
|
@ -17,9 +17,8 @@ Renders the configMap objects required by the chart.
|
|||
|
||||
{{- /* Create object from the raw configMap values */ -}}
|
||||
{{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $key "values" $configMapValues)) | fromYaml -}}
|
||||
|
||||
{{- /* Perform validations on the configMap before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $ "object" $configMapObject) -}}
|
||||
{{- include "bjw-s.common.lib.configMap.validate" (dict "rootContext" $ "object" $configMapObject "id" $key) -}}
|
||||
|
||||
{{/* Include the configMap class */}}
|
||||
{{- include "bjw-s.common.class.configMap" (dict "rootContext" $ "object" $configMapObject) | nindent 0 -}}
|
||||
|
@ -30,36 +29,57 @@ Renders the configMap objects required by the chart.
|
|||
{{/*
|
||||
Renders configMap objects required by the chart from a folder in the repo's path.
|
||||
*/}}
|
||||
{{- define "bjw-s.common.render.configMaps.fromFiles" -}}
|
||||
{{- $rootValues := .Values -}}
|
||||
{{- define "bjw-s.common.render.configMaps.fromFolder" -}}
|
||||
|
||||
{{- $valuesCopy := .Values -}}
|
||||
{{- $configMapsFromFolder := .Values.configMapsFromFolder | default dict -}}
|
||||
{{- $configMapsFromFolderEnabled := dig "enabled" false $configMapsFromFolder -}}
|
||||
|
||||
{{- if $configMapsFromFolderEnabled -}}
|
||||
{{- /* Perform validations before rendering */ -}}
|
||||
{{- include "bjw-s.common.lib.configMap.fromFolder.validate" (dict "rootContext" $ "basePath" $configMapsFromFolder.basePath) -}}
|
||||
{{- $basePath := $configMapsFromFolder.basePath -}}
|
||||
{{/* Generate a list of unique top level folders */}}
|
||||
{{ $topLevelFolders := dict}}
|
||||
{{- range $path, $_ := .Files.Glob (printf "%s/*/*" .Values.configMapsFromFolderBasePath) -}}
|
||||
{{- range $path, $_ := .Files.Glob (printf "%s/*/*" $basePath) -}}
|
||||
{{- $_ := set $topLevelFolders (dir $path) "" -}}
|
||||
{{- end -}}
|
||||
{{- $top_level_folder_list := keys $topLevelFolders | sortAlpha -}}
|
||||
{{/* Iterate over the top level folders */}}
|
||||
{{ range $path := $top_level_folder_list }}
|
||||
{{- $filesContentNoFormat := ($.Files.Glob (printf "%s/*" $path)) -}}
|
||||
{{- $filesContent := dict -}}
|
||||
{{- $binaryFilesContent := dict -}}
|
||||
{{- range $file_name, $content := $filesContentNoFormat -}}
|
||||
{{- $key := base $file_name -}}
|
||||
{{- if contains ".escape" $key -}}
|
||||
{{- $key := $key | replace ".escape" "" -}}
|
||||
{{- $filesContent = merge $filesContent (dict $key (($.Files.Get $file_name) | replace "{{" "{{ `{{` }}")) -}}
|
||||
{{- else if contains ".binary" $key -}}
|
||||
{{- $key := $key | replace ".binary" "" -}}
|
||||
{{- $binaryFilesContent = merge $binaryFilesContent (dict $key ($.Files.Get $file_name | b64enc )) -}}
|
||||
{{- $folder := base $path -}}
|
||||
{{- $configMapData := dict -}}
|
||||
{{- $configMapBinaryData := dict -}}
|
||||
{{- $allFilesContent := ($.Files.Glob (printf "%s/*" $path)) -}}
|
||||
|
||||
{{- $configMapAnnotations := dig "configMapsOverrides" $folder "annotations" dict $configMapsFromFolder -}}
|
||||
{{- $configMapLabels := dig "configMapsOverrides" $folder "labels" dict $configMapsFromFolder -}}
|
||||
{{- $configMapForceRename := dig "configMapsOverrides" $folder "forceRename" nil $configMapsFromFolder -}}
|
||||
{{- range $file_name, $content := $allFilesContent -}}
|
||||
{{- $file := base $file_name -}}
|
||||
{{- $fileOverride := dig "configMapsOverrides" $folder "fileAttributeOverrides" $file nil $configMapsFromFolder -}}
|
||||
{{- $fileContent := $.Files.Get $file_name -}}
|
||||
{{- if not $fileOverride.exclude -}}
|
||||
{{- if $fileOverride.binary -}}
|
||||
{{- $fileContent = $fileContent | b64enc -}}
|
||||
{{- $configMapBinaryData = merge $configMapBinaryData (dict $file $fileContent) -}}
|
||||
{{- else if $fileOverride.escaped -}}
|
||||
{{- $fileContent = $fileContent | replace "{{" "{{ `{{` }}" -}}
|
||||
{{- $configMapData = merge $configMapData (dict $file $fileContent) -}}
|
||||
{{- else -}}
|
||||
{{- $filesContent = merge $filesContent (dict $key ($.Files.Get $file_name)) -}}
|
||||
{{- $configMapData = merge $configMapData (dict $file $fileContent) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $configMapValues := dict "enabled" true "labels" dict "annotations" dict "data" $filesContent "binaryData" $binaryFilesContent -}}
|
||||
{{- $existingConfigMaps := (get $rootValues "configMaps"| default dict) -}}
|
||||
{{ end }}
|
||||
|
||||
{{- $configMapValues := dict "enabled" true "forceRename" $configMapForceRename "labels" $configMapLabels "annotations" $configMapAnnotations "data" $configMapData "binaryData" $configMapBinaryData -}}
|
||||
{{- $configMapObject := (include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $ "id" $folder "values" $configMapValues)) | fromYaml -}}
|
||||
{{/* Append it to .Values.configMaps so it can be created by "bjw-s.common.render.configMaps" and fetched by identifier */}}
|
||||
{{- $existingConfigMaps := (get $valuesCopy "configMaps"| default dict) -}}
|
||||
{{- $mergedConfigMaps := deepCopy $existingConfigMaps | merge (dict (base $path) $configMapValues) -}}
|
||||
{{- $rootValues := merge $rootValues (dict "configMaps" $mergedConfigMaps) -}}
|
||||
{{- $valuesCopy := merge $valuesCopy (dict "configMaps" $mergedConfigMaps) -}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.6.1/charts/library/common/values.schema.json",
|
||||
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.7.0/charts/library/common/values.schema.json",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"global": {
|
||||
|
|
|
@ -14,7 +14,7 @@ global:
|
|||
# -- Set default options for all controllers / pods here
|
||||
# Each of these options can be overridden on a Controller level
|
||||
defaultPodOptions:
|
||||
# -- Defines affinity constraint rules.
|
||||
# -- Defines affinity constraint rules. Helm templates can be used.
|
||||
# [[ref]](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
|
||||
affinity: {}
|
||||
|
||||
|
@ -79,6 +79,10 @@ defaultPodOptions:
|
|||
# -- Configure the Security Context for the Pod
|
||||
securityContext: {}
|
||||
|
||||
# -- Allows sharing process namespace between containers in a Pod
|
||||
# -- [[ref](https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/)]
|
||||
shareProcessNamespace:
|
||||
|
||||
# -- Duration in seconds the pod needs to terminate gracefully
|
||||
# -- [[ref](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)]
|
||||
terminationGracePeriodSeconds:
|
||||
|
@ -471,19 +475,43 @@ configMaps:
|
|||
# data:
|
||||
# foo: bar
|
||||
|
||||
# -- A path in your parent's chart filesystem where you can add files to be converted into individual ConfigMaps.
|
||||
# -- Generate ConfigMaps from a folder in the Helm chart's filesystem
|
||||
# Your files will need to be two levels deep from the base path.
|
||||
# For example, if you set this to `files/`, and you have this file tree
|
||||
# For example, if you set this to `files/`, you should have this file tree
|
||||
# files:
|
||||
# └── configmap1
|
||||
# ├── file1
|
||||
# └── file2
|
||||
# This will generate a ConfigMap named `configmap1` with keys `file1` and `file2`, values being the respective contents of those files.
|
||||
# If your file contains `gotpl` syntax that you don't want templated by Helm, prefix the file extension with `.escape` and it will be treated as a regular string.
|
||||
# For example, `file1.escape.yaml` will be converted to `file1.yaml` in the ConfigMap with the contents of the file not templated.
|
||||
# If your file is a binary file like an image, prefix the file extension with `.binary`
|
||||
# For example, `file1.binary.png` will be converted to `file1.png` in the ConfigMap under binaryData with the contents of the file base64 encoded.
|
||||
configMapsFromFolderBasePath: null
|
||||
# This will generate a ConfigMap named `configmap1` with keys `file1` and `file2`.
|
||||
configMapsFromFolder:
|
||||
enabled: false
|
||||
# #-- The path in your parent's chart filesystem where you can add files to be converted into individual ConfigMaps.
|
||||
# basePath: "files/configMaps"
|
||||
# #-- Define overrides for the generated ConfigMaps, each key is the name of a folder in `basePath`
|
||||
# configMapsOverrides:
|
||||
# test:
|
||||
# # All ConfigMaps support a `forceRename` field, which allows you to rename the ConfigMap
|
||||
# forceRename: null
|
||||
# annotations:
|
||||
# test: test
|
||||
# labels:
|
||||
# test: test
|
||||
# # Configure how the individual files are added to the ConfigMap
|
||||
# fileAttributeOverrides:
|
||||
# # The key is the name of the file inside the ConfigMap's folder
|
||||
# test.tpl:
|
||||
# # If true the file won't be added to the ConfigMap
|
||||
# exclude: false
|
||||
# # If your file is a binary file like an image, set this to true. Takes precedence over `escaped`
|
||||
# binary: false
|
||||
# # If your file contains `gotpl` syntax that you don't want templated by Helm, set this to true
|
||||
# escaped: true
|
||||
# test.txt:
|
||||
# exclude: true
|
||||
# test2:
|
||||
# fileAttributeOverrides:
|
||||
# image.png:
|
||||
# binary: true
|
||||
|
||||
# -- Configure the services for the chart here.
|
||||
# Additional services can be added by adding a dictionary key similar to the 'main' service.
|
||||
|
@ -637,7 +665,7 @@ serviceMonitor:
|
|||
# # -- Configures the target Service for the serviceMonitor. Helm templates can be used.
|
||||
# serviceName: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}'
|
||||
|
||||
# # -- Configures the endpoints for the serviceMonitor.
|
||||
# # -- Configures the endpoints for the serviceMonitor. Helm templates can be used.
|
||||
# # @default -- See values.yaml
|
||||
# endpoints:
|
||||
# - port: http
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue