From e2c02b8950be84a8a0ebaa5a7c74ad4e3b5863d6 Mon Sep 17 00:00:00 2001 From: rustam810 Date: Fri, 14 Jul 2023 19:59:06 +0400 Subject: [PATCH 01/31] simple_app 1.0.0 * Service port equals container port * Delete `Values.probe`. `livenessProbe` and `readinessProbe` import from values file --- charts/simple-app/CHANGELOG.md | 7 ++++ charts/simple-app/Chart.yaml | 2 +- charts/simple-app/templates/deployment.yaml | 44 +++------------------ charts/simple-app/templates/ingress.yaml | 2 +- charts/simple-app/templates/service.yaml | 4 +- charts/simple-app/values.yaml | 29 +++++--------- 6 files changed, 25 insertions(+), 63 deletions(-) diff --git a/charts/simple-app/CHANGELOG.md b/charts/simple-app/CHANGELOG.md index 175bf66..848b5dd 100644 --- a/charts/simple-app/CHANGELOG.md +++ b/charts/simple-app/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.0.0 + +* Service port equals container port +* Delete `Values.probe`. `livenessProbe` and `readinessProbe` import from values file + +## Backwards incompatibility + # 0.9.1 * Add support for `.initialDelaySeconds` in `livenessProbe` and `readinessProbe` diff --git a/charts/simple-app/Chart.yaml b/charts/simple-app/Chart.yaml index 0ad3402..f95d96f 100644 --- a/charts/simple-app/Chart.yaml +++ b/charts/simple-app/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: "0.9.1" +version: "1.0.0" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/simple-app/templates/deployment.yaml b/charts/simple-app/templates/deployment.yaml index f0291fe..efd0308 100644 --- a/charts/simple-app/templates/deployment.yaml +++ b/charts/simple-app/templates/deployment.yaml @@ -68,53 +68,19 @@ spec: - name: http containerPort: {{ .Values.port }} protocol: TCP - {{- range .Values.servicePorts }} + {{- range .Values.extraPorts }} - name: {{ .name }} containerPort: {{ .port }} protocol: {{ .protocol | default "TCP" }} {{- end }} - {{- if .Values.livenessProbe.enabled }} livenessProbe: - httpGet: - path: {{ .Values.probe.httpGet.path }} - port: http - {{- if .Values.livenessProbe.initialDelaySeconds }} - initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + {{- with .Values.livenessProbe }} + {{- toYaml . | nindent 12 }} {{- end }} - {{- if .Values.livenessProbe.timeoutSeconds }} - timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} - {{- end }} - {{- if .Values.livenessProbe.periodSeconds }} - periodSeconds: {{ .Values.livenessProbe.periodSeconds }} - {{- end }} - {{- if .Values.livenessProbe.successThreshold }} - successThreshold: {{ .Values.livenessProbe.successThreshold }} - {{- end }} - {{- if .Values.livenessProbe.failureThreshold }} - failureThreshold: {{ .Values.livenessProbe.failureThreshold }} - {{- end }} - {{- end }} - {{- if .Values.readinessProbe.enabled }} readinessProbe: - httpGet: - path: {{ .Values.probe.httpGet.path }} - port: http - {{- if .Values.livenessProbe.initialDelaySeconds }} - initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} - {{- end }} - {{- if .Values.readinessProbe.timeoutSeconds }} - timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} - {{- end }} - {{- if .Values.readinessProbe.periodSeconds }} - periodSeconds: {{ .Values.readinessProbe.periodSeconds }} - {{- end }} - {{- if .Values.readinessProbe.successThreshold }} - successThreshold: {{ .Values.readinessProbe.successThreshold }} - {{- end }} - {{- if .Values.readinessProbe.failureThreshold }} - failureThreshold: {{ .Values.readinessProbe.failureThreshold }} + {{- with .Values.readinessProbe }} + {{- toYaml . | nindent 12 }} {{- end }} - {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: diff --git a/charts/simple-app/templates/ingress.yaml b/charts/simple-app/templates/ingress.yaml index e0392df..f74e072 100644 --- a/charts/simple-app/templates/ingress.yaml +++ b/charts/simple-app/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "simple-app.fullname" . -}} -{{- $svcPort := .Values.service.port -}} +{{- $svcPort := .Values.port -}} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} diff --git a/charts/simple-app/templates/service.yaml b/charts/simple-app/templates/service.yaml index 661a387..3522969 100644 --- a/charts/simple-app/templates/service.yaml +++ b/charts/simple-app/templates/service.yaml @@ -7,11 +7,11 @@ metadata: spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.service.port }} + - port: {{ .Values.port }} targetPort: http protocol: TCP name: http - {{- range .Values.servicePorts}} + {{- range .Values.extraPorts}} - port: {{ .port }} targetPort: {{ .name }} protocol: {{ .protocol | default "TCP" }} diff --git a/charts/simple-app/values.yaml b/charts/simple-app/values.yaml index fe1fe2d..78a302e 100644 --- a/charts/simple-app/values.yaml +++ b/charts/simple-app/values.yaml @@ -15,14 +15,15 @@ image: imagePullSecrets: [] -# Port that container is using port: 80 -# Ports to be exposed on the service -servicePorts: [] - # - name: grpc - # port: 50051 # both containerPort and service port - # protocol: TCP +extraPorts: [] +# - name: grpc +# port: 50051 +# protocol: TCP + +service: + type: ClusterIP # Environment variables for container env: {} @@ -50,13 +51,7 @@ configs: [] # } # } -# Default args for health probe -probe: - httpGet: - path: / - -livenessProbe: - enabled: true +livenessProbe: {} # httpGet: # path: / # port: http @@ -67,8 +62,7 @@ livenessProbe: # successThreshold: 1 # failureThreshold: 3 -readinessProbe: - enabled: true +readinessProbe: {} # httpGet: # path: / # port: http @@ -103,16 +97,11 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 -service: - type: ClusterIP - port: 80 - ingress: enabled: false # True if target ingress is Nginx (alters path definition and annotation) nginx: false - className: "" annotations: {} From d5331c3f44759fd4990c8d09f0e3c46901f60c87 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:05:44 +0400 Subject: [PATCH 02/31] add ability to override service port --- charts/simple-app/templates/service.yaml | 4 ++-- charts/simple-app/values.yaml | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/charts/simple-app/templates/service.yaml b/charts/simple-app/templates/service.yaml index 3522969..4271c07 100644 --- a/charts/simple-app/templates/service.yaml +++ b/charts/simple-app/templates/service.yaml @@ -7,12 +7,12 @@ metadata: spec: type: {{ .Values.service.type }} ports: - - port: {{ .Values.port }} + - port: {{ .Values.servicePort | default .Values.port }} targetPort: http protocol: TCP name: http {{- range .Values.extraPorts}} - - port: {{ .port }} + - port: {{ .servicePort | default .port }} targetPort: {{ .name }} protocol: {{ .protocol | default "TCP" }} name: {{ .name }} diff --git a/charts/simple-app/values.yaml b/charts/simple-app/values.yaml index 78a302e..83038b0 100644 --- a/charts/simple-app/values.yaml +++ b/charts/simple-app/values.yaml @@ -1,3 +1,5 @@ +# yaml-language-server: $schema=values.schema.json + # Default values for simple-app. # This is a YAML-formatted file. # Declare variables to be passed into your templates. @@ -16,10 +18,12 @@ image: imagePullSecrets: [] port: 80 +servicePort: "" extraPorts: [] # - name: grpc # port: 50051 +# servicePort: 80 # protocol: TCP service: From c130c6a06e3811c5262380f4ed5bbdbedeed223d Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:05:57 +0400 Subject: [PATCH 03/31] add tests --- .github/workflows/test.yaml | 29 +++ charts/simple-app/Makefile | 4 + charts/simple-app/tests/multiport-values.yaml | 15 ++ charts/simple-app/tests/multiport_test.yaml | 42 ++++ charts/simple-app/tests/simple-values.yaml | 8 + charts/simple-app/tests/simple_test.yaml | 42 ++++ charts/simple-app/values.schema.json | 191 ++++++++++++++++++ 7 files changed, 331 insertions(+) create mode 100644 .github/workflows/test.yaml create mode 100644 charts/simple-app/Makefile create mode 100644 charts/simple-app/tests/multiport-values.yaml create mode 100644 charts/simple-app/tests/multiport_test.yaml create mode 100644 charts/simple-app/tests/simple-values.yaml create mode 100644 charts/simple-app/tests/simple_test.yaml create mode 100644 charts/simple-app/values.schema.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1799577 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,29 @@ +name: Run tests + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Install Helm + uses: azure/setup-helm@v1 + with: + version: v3.4.0 + + - name: Install helm-unittest + run: | + helm plugin install https://github.com/helm-unittest/helm-unittest.git + + - name: Run tests + run: | + set -e + for chart in charts/*; do + helm unittest $chart + done diff --git a/charts/simple-app/Makefile b/charts/simple-app/Makefile new file mode 100644 index 0000000..5a62a8a --- /dev/null +++ b/charts/simple-app/Makefile @@ -0,0 +1,4 @@ +# helm plugin install https://github.com/helm-unittest/helm-unittest.git + +test: + helm unittest . diff --git a/charts/simple-app/tests/multiport-values.yaml b/charts/simple-app/tests/multiport-values.yaml new file mode 100644 index 0000000..a4fc6aa --- /dev/null +++ b/charts/simple-app/tests/multiport-values.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=../values.schema.json + +image: + repository: test + tag: 1.1.1 + +port: 9000 + +extraPorts: + - name: port1 + port: 1 + protocol: TCP + - name: port2 + port: 2 + servicePort: 22022 diff --git a/charts/simple-app/tests/multiport_test.yaml b/charts/simple-app/tests/multiport_test.yaml new file mode 100644 index 0000000..1dacd73 --- /dev/null +++ b/charts/simple-app/tests/multiport_test.yaml @@ -0,0 +1,42 @@ +suite: multiport +values: + - multiport-values.yaml +tests: + - it: Multiple port specification for deployment + template: deployment.yaml + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].ports + value: + - containerPort: 9000 + name: http + protocol: TCP + - containerPort: 1 + name: port1 + protocol: TCP + - containerPort: 2 + name: port2 + protocol: TCP + + - it: Multiple port specification for service + template: service.yaml + asserts: + - isKind: + of: Service + - equal: + path: spec.ports + value: + - name: http + port: 9000 + protocol: TCP + targetPort: http + - name: port1 + port: 1 + protocol: TCP + targetPort: port1 + - name: port2 + port: 22022 + protocol: TCP + targetPort: port2 diff --git a/charts/simple-app/tests/simple-values.yaml b/charts/simple-app/tests/simple-values.yaml new file mode 100644 index 0000000..d7e9137 --- /dev/null +++ b/charts/simple-app/tests/simple-values.yaml @@ -0,0 +1,8 @@ +# yaml-language-server: $schema=../values.schema.json + +image: + repository: test + tag: 1.1.1 + +port: 9000 +servicePort: 80 \ No newline at end of file diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml new file mode 100644 index 0000000..796ce0c --- /dev/null +++ b/charts/simple-app/tests/simple_test.yaml @@ -0,0 +1,42 @@ +suite: simple +values: + - simple-values.yaml +tests: + - it: Image tag should be set correctly + template: deployment.yaml + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].image + value: test:1.1.1 + + - it: Simple port specification for deployment + template: deployment.yaml + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].ports[0].containerPort + value: 9000 + - equal: + path: spec.template.spec.containers[0].ports[0].protocol + value: TCP + - lengthEqual: + path: spec.template.spec.containers[0].ports + count: 1 + + - it: Simple port specification for service + template: service.yaml + asserts: + - isKind: + of: Service + - equal: + path: spec.ports[0].port + value: 80 + - equal: + path: spec.ports[0].protocol + value: TCP + - lengthEqual: + path: spec.ports + count: 1 diff --git a/charts/simple-app/values.schema.json b/charts/simple-app/values.schema.json new file mode 100644 index 0000000..f2bff5e --- /dev/null +++ b/charts/simple-app/values.schema.json @@ -0,0 +1,191 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "simple-app values schema", + "type": "object", + "properties": { + "nameOverride": { + "type": "string" + }, + "fullnameOverride": { + "type": "string" + }, + "image": { + "type": "object", + "properties": { + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "imagePullSecrets": { + "type": "array", + "items": { + "type": "object" + } + }, + "domain": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "servicePort": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + }, + "extraPorts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "port": { + "type": "integer" + }, + "servicePort": { + "oneOf": [ + { + "type": "integer" + }, + { + "type": "string" + } + ] + }, + "protocol": { + "type": "string" + } + } + } + }, + "service": { + "type": "object", + "properties": { + "type": { + "type": "string" + } + } + }, + "env": { + "type": "object" + }, + "command": { + "type": "array", + "items": { + "type": "string" + } + }, + "shmSize": { + "type": "string" + }, + "volumes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "mountPath": { + "type": "string" + }, + "size": { + "type": "string" + } + } + } + }, + "configs": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + }, + "livenessProbe": { + "type": "object" + }, + "readinessProbe": { + "type": "object" + }, + "replicaCount": { + "type": "integer" + }, + "serviceAccount": { + "type": "object", + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "annotations": { + "type": "object" + } + } + }, + "podAnnotations": { + "type": "object" + }, + "podSecurityContext": { + "type": "object" + }, + "securityContext": { + "type": "object" + }, + "ingress": { + "type": "object" + }, + "resources": { + "type": "object" + }, + "autoscaling": { + "type": "object" + }, + "nodeSelector": { + "type": "object" + }, + "tolerations": { + "type": "array", + "items": { + "type": "object" + } + }, + "affinity": { + "type": "object" + }, + "gke": { + "type": "object", + "properties": { + "managedCertificate": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean" + } + } + } + } + } + }, + "additionalProperties": false +} \ No newline at end of file From f299d7d3f9557cc2c99fd860ff38ed01bb071ea2 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:07:16 +0400 Subject: [PATCH 04/31] simplify test run --- .github/workflows/test.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1799577..f63f4cf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,4 @@ jobs: - name: Run tests run: | - set -e - for chart in charts/*; do - helm unittest $chart - done + helm unittest charts/* From 19e7d3f9838418d7e57d17a487a9f95b77fed2de Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:12:33 +0400 Subject: [PATCH 05/31] update to actions/checkout@v3 --- .github/workflows/release.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1a87c89..b725951 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f63f4cf..79d34bb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 From 0d59536e6a0fbb4e3ce45cd93c4b1d85a8092e17 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:14:42 +0400 Subject: [PATCH 06/31] update to azure/setup-helm@v3 --- .github/workflows/release.yaml | 5 +++-- .github/workflows/test.yaml | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b725951..396aaa8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,10 +18,11 @@ jobs: run: | git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Install Helm - uses: azure/setup-helm@v1 + uses: azure/setup-helm@v3 with: - version: v3.4.0 + version: v3.11.0 - name: Run chart-releaser uses: helm/chart-releaser-action@v1.1.0 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 79d34bb..514af3f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,9 +13,9 @@ jobs: fetch-depth: 0 - name: Install Helm - uses: azure/setup-helm@v1 + uses: azure/setup-helm@v3 with: - version: v3.4.0 + version: v3.11.0 - name: Install helm-unittest run: | From a92ca136f2ccc24df8d71cff05b7dfc4b1ba08de Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:24:09 +0400 Subject: [PATCH 07/31] try report maker --- .github/workflows/test.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 514af3f..4fa5301 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,4 +23,13 @@ jobs: - name: Run tests run: | - helm unittest charts/* + helm unittest charts/* -o test-result.xml + + - name: Test report + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + artifact: test-results + name: helm unittest + path: "test-result.xml" + reporter: dotnet-trx From 116a8515bf686ee7a6221ce87d1718a9fedc853c Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:25:16 +0400 Subject: [PATCH 08/31] * --- .github/workflows/test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4fa5301..694f44d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,7 +29,6 @@ jobs: uses: dorny/test-reporter@v1 if: success() || failure() with: - artifact: test-results name: helm unittest path: "test-result.xml" reporter: dotnet-trx From 592c7a82626919dc61dc3ab98412d13da8f4d6d6 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:27:29 +0400 Subject: [PATCH 09/31] * --- .github/workflows/test.yaml | 4 ++-- testresult.xml | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 testresult.xml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 694f44d..6893da3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,5 +30,5 @@ jobs: if: success() || failure() with: name: helm unittest - path: "test-result.xml" - reporter: dotnet-trx + path: test-result.xml + reporter: java-junit diff --git a/testresult.xml b/testresult.xml new file mode 100644 index 0000000..662ea49 --- /dev/null +++ b/testresult.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + From 734c55c4038397e53063adeb517fa3ee3bb11b90 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:41:24 +0400 Subject: [PATCH 10/31] * --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6893da3..37b490f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,7 +23,7 @@ jobs: - name: Run tests run: | - helm unittest charts/* -o test-result.xml + helm unittest charts/* -o test-result.xml -t junit - name: Test report uses: dorny/test-reporter@v1 From cb1cf1ff1a562256e3d7ab0551c7dbb1b95c4e2b Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:42:52 +0400 Subject: [PATCH 11/31] * --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 37b490f..fe9b5db 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,6 +29,6 @@ jobs: uses: dorny/test-reporter@v1 if: success() || failure() with: - name: helm unittest + name: test path: test-result.xml reporter: java-junit From 22592f763929f8f23c96b6fc77ba587f2d763529 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:45:29 +0400 Subject: [PATCH 12/31] * --- .github/workflows/test.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index fe9b5db..d20c09a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -23,12 +23,12 @@ jobs: - name: Run tests run: | - helm unittest charts/* -o test-result.xml -t junit + helm unittest charts/* -o test-report.xml -t junit - - name: Test report + - name: test report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: test - path: test-result.xml + name: Test Report + path: test-report.xml reporter: java-junit From 963468796ac3fe7522b4fc0e267c8cda6e2ea499 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 20:56:23 +0400 Subject: [PATCH 13/31] * --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d20c09a..e41d1aa 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,10 +25,10 @@ jobs: run: | helm unittest charts/* -o test-report.xml -t junit - - name: test report + - name: Test report uses: dorny/test-reporter@v1 if: success() || failure() with: - name: Test Report + name: test report path: test-report.xml reporter: java-junit From 219b316d3248fc361e68413646b2c0b79cfac81d Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 22:01:40 +0400 Subject: [PATCH 14/31] add servicePort=80 by default; serviceType instead of service.type --- charts/simple-app/templates/service.yaml | 2 +- charts/simple-app/tests/multiport_test.yaml | 2 +- charts/simple-app/values.schema.json | 11 +++-------- charts/simple-app/values.yaml | 11 +++++------ 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/charts/simple-app/templates/service.yaml b/charts/simple-app/templates/service.yaml index 4271c07..3b3b0c1 100644 --- a/charts/simple-app/templates/service.yaml +++ b/charts/simple-app/templates/service.yaml @@ -5,7 +5,7 @@ metadata: labels: {{- include "simple-app.labels" . | nindent 4 }} spec: - type: {{ .Values.service.type }} + type: {{ .Values.serviceType }} ports: - port: {{ .Values.servicePort | default .Values.port }} targetPort: http diff --git a/charts/simple-app/tests/multiport_test.yaml b/charts/simple-app/tests/multiport_test.yaml index 1dacd73..2fcb800 100644 --- a/charts/simple-app/tests/multiport_test.yaml +++ b/charts/simple-app/tests/multiport_test.yaml @@ -29,7 +29,7 @@ tests: path: spec.ports value: - name: http - port: 9000 + port: 80 protocol: TCP targetPort: http - name: port1 diff --git a/charts/simple-app/values.schema.json b/charts/simple-app/values.schema.json index f2bff5e..14b9336 100644 --- a/charts/simple-app/values.schema.json +++ b/charts/simple-app/values.schema.json @@ -42,6 +42,9 @@ } ] }, + "serviceType": { + "type": "string" + }, "extraPorts": { "type": "array", "items": { @@ -69,14 +72,6 @@ } } }, - "service": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - } - }, "env": { "type": "object" }, diff --git a/charts/simple-app/values.yaml b/charts/simple-app/values.yaml index 83038b0..c8195c1 100644 --- a/charts/simple-app/values.yaml +++ b/charts/simple-app/values.yaml @@ -17,18 +17,17 @@ image: imagePullSecrets: [] -port: 80 -servicePort: "" +port: 8000 + +servicePort: 80 +serviceType: ClusterIP extraPorts: [] # - name: grpc # port: 50051 -# servicePort: 80 +# servicePort: "" # protocol: TCP -service: - type: ClusterIP - # Environment variables for container env: {} From 48f01aebb795a4d3789fbb490a752d8cd6423ebd Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 22:02:16 +0400 Subject: [PATCH 15/31] simplify simple-app.fullname --- charts/simple-app/templates/_helpers.tpl | 5 ----- charts/simple-app/tests/simple_test.yaml | 23 ++++++++++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/charts/simple-app/templates/_helpers.tpl b/charts/simple-app/templates/_helpers.tpl index f4677b2..c4aca7a 100644 --- a/charts/simple-app/templates/_helpers.tpl +++ b/charts/simple-app/templates/_helpers.tpl @@ -14,12 +14,7 @@ If release name contains chart name it will be used as a full name. {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} -{{- $name := default .Chart.Name .Values.nameOverride }} -{{- if contains $name .Release.Name }} {{- .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} {{- end }} {{- end }} diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 796ce0c..e7ce300 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -1,8 +1,20 @@ suite: simple values: - simple-values.yaml +release: + name: simple + namespace: default tests: - - it: Image tag should be set correctly + - it: Deployment should be named as release + template: deployment.yaml + asserts: + - isKind: + of: Deployment + - equal: + path: metadata.name + value: simple + + - it: Deployment image tag should be set correctly template: deployment.yaml asserts: - isKind: @@ -26,6 +38,15 @@ tests: path: spec.template.spec.containers[0].ports count: 1 + - it: Service should be named as release + template: service.yaml + asserts: + - isKind: + of: Service + - equal: + path: metadata.name + value: simple + - it: Simple port specification for service template: service.yaml asserts: From b2fe945174c40ce5e19fc29de56626b9cdb262b7 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 22:03:00 +0400 Subject: [PATCH 16/31] * --- testresult.xml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 testresult.xml diff --git a/testresult.xml b/testresult.xml deleted file mode 100644 index 662ea49..0000000 --- a/testresult.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - From 4bcd1dc80898aa350f14dff292c171b7acf8beee Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 22:10:05 +0400 Subject: [PATCH 17/31] rename tests --- charts/simple-app/tests/multiport_test.yaml | 8 ++++-- charts/simple-app/tests/simple-values.yaml | 1 - charts/simple-app/tests/simple_test.yaml | 32 ++++++++++----------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/charts/simple-app/tests/multiport_test.yaml b/charts/simple-app/tests/multiport_test.yaml index 2fcb800..31c6ed9 100644 --- a/charts/simple-app/tests/multiport_test.yaml +++ b/charts/simple-app/tests/multiport_test.yaml @@ -1,8 +1,10 @@ -suite: multiport +suite: simple-app multiport case + values: - multiport-values.yaml + tests: - - it: Multiple port specification for deployment + - it: Deployment multiple port specification should work correctly template: deployment.yaml asserts: - isKind: @@ -20,7 +22,7 @@ tests: name: port2 protocol: TCP - - it: Multiple port specification for service + - it: Service multiple port specification should work correctly template: service.yaml asserts: - isKind: diff --git a/charts/simple-app/tests/simple-values.yaml b/charts/simple-app/tests/simple-values.yaml index d7e9137..31c8167 100644 --- a/charts/simple-app/tests/simple-values.yaml +++ b/charts/simple-app/tests/simple-values.yaml @@ -5,4 +5,3 @@ image: tag: 1.1.1 port: 9000 -servicePort: 80 \ No newline at end of file diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index e7ce300..26b5770 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -1,9 +1,12 @@ -suite: simple +suite: simple-app simple case + values: - simple-values.yaml + release: name: simple namespace: default + tests: - it: Deployment should be named as release template: deployment.yaml @@ -23,20 +26,17 @@ tests: path: spec.template.spec.containers[0].image value: test:1.1.1 - - it: Simple port specification for deployment + - it: Deployment simple port specification should work correctly template: deployment.yaml asserts: - isKind: of: Deployment - equal: - path: spec.template.spec.containers[0].ports[0].containerPort - value: 9000 - - equal: - path: spec.template.spec.containers[0].ports[0].protocol - value: TCP - - lengthEqual: path: spec.template.spec.containers[0].ports - count: 1 + value: + - containerPort: 9000 + name: http + protocol: TCP - it: Service should be named as release template: service.yaml @@ -47,17 +47,15 @@ tests: path: metadata.name value: simple - - it: Simple port specification for service + - it: Service simple port specification should work correctly template: service.yaml asserts: - isKind: of: Service - equal: - path: spec.ports[0].port - value: 80 - - equal: - path: spec.ports[0].protocol - value: TCP - - lengthEqual: path: spec.ports - count: 1 + value: + - name: http + port: 80 + protocol: TCP + targetPort: http From 1137aacc3956bfca098f41eb34340bd5680f7149 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 22:55:28 +0400 Subject: [PATCH 18/31] add sensible defaults for liveness and readiness probe --- charts/simple-app/templates/deployment.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/charts/simple-app/templates/deployment.yaml b/charts/simple-app/templates/deployment.yaml index efd0308..9b15866 100644 --- a/charts/simple-app/templates/deployment.yaml +++ b/charts/simple-app/templates/deployment.yaml @@ -74,13 +74,25 @@ spec: protocol: {{ .protocol | default "TCP" }} {{- end }} livenessProbe: + {{- if .Values.livenessProbe }} {{- with .Values.livenessProbe }} {{- toYaml . | nindent 12 }} {{- end }} + {{- else }} + httpGet: + path: / + port: http + {{- end }} readinessProbe: + {{- if .Values.readinessProbe }} {{- with .Values.readinessProbe }} {{- toYaml . | nindent 12 }} {{- end }} + {{- else }} + httpGet: + path: / + port: http + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: From 90124c6c06696b912f67ef60331ee1c371773fee Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sat, 15 Jul 2023 22:56:21 +0400 Subject: [PATCH 19/31] add snapshot tests --- .../tests/__snapshot__/simple_test.yaml.snap | 102 ++++++++++++++++++ charts/simple-app/tests/multiport-values.yaml | 1 + charts/simple-app/tests/multiport_test.yaml | 2 +- charts/simple-app/tests/simple-values.yaml | 5 + charts/simple-app/tests/simple_test.yaml | 43 ++++++++ 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 charts/simple-app/tests/__snapshot__/simple_test.yaml.snap diff --git a/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap b/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap new file mode 100644 index 0000000..cc7d4e2 --- /dev/null +++ b/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap @@ -0,0 +1,102 @@ +All manifests should match snapshot: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: simple + app.kubernetes.io/name: simple-app + template: + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/name: simple-app + spec: + containers: + - image: test:1.1.1 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: / + port: http + name: simple-app + ports: + - containerPort: 9000 + name: http + protocol: TCP + readinessProbe: + httpGet: + path: / + port: http + resources: {} + securityContext: {} + volumeMounts: null + securityContext: {} + serviceAccountName: simple + volumes: null + 2: | + apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + annotations: null + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple + spec: + rules: + - host: test.epoch8.co + http: + paths: + - backend: + service: + name: simple + port: + number: 9000 + path: /* + pathType: ImplementationSpecific + 3: | + apiVersion: v1 + kind: Service + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple + spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http + selector: + app.kubernetes.io/instance: simple + app.kubernetes.io/name: simple-app + type: ClusterIP + 4: | + apiVersion: v1 + kind: ServiceAccount + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple diff --git a/charts/simple-app/tests/multiport-values.yaml b/charts/simple-app/tests/multiport-values.yaml index a4fc6aa..242f0e2 100644 --- a/charts/simple-app/tests/multiport-values.yaml +++ b/charts/simple-app/tests/multiport-values.yaml @@ -5,6 +5,7 @@ image: tag: 1.1.1 port: 9000 +servicePort: 9000 extraPorts: - name: port1 diff --git a/charts/simple-app/tests/multiport_test.yaml b/charts/simple-app/tests/multiport_test.yaml index 31c6ed9..df9a9df 100644 --- a/charts/simple-app/tests/multiport_test.yaml +++ b/charts/simple-app/tests/multiport_test.yaml @@ -31,7 +31,7 @@ tests: path: spec.ports value: - name: http - port: 80 + port: 9000 protocol: TCP targetPort: http - name: port1 diff --git a/charts/simple-app/tests/simple-values.yaml b/charts/simple-app/tests/simple-values.yaml index 31c8167..57449ab 100644 --- a/charts/simple-app/tests/simple-values.yaml +++ b/charts/simple-app/tests/simple-values.yaml @@ -5,3 +5,8 @@ image: tag: 1.1.1 port: 9000 + +domain: test.epoch8.co + +ingress: + enabled: true diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 26b5770..2d39d57 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -8,6 +8,15 @@ release: namespace: default tests: + - it: All manifests should match snapshot + templates: + - deployment.yaml + - service.yaml + - ingress.yaml + - serviceaccount.yaml + asserts: + - matchSnapshot: {} + - it: Deployment should be named as release template: deployment.yaml asserts: @@ -38,6 +47,28 @@ tests: name: http protocol: TCP + - it: Deployment should have readinessProbe set correctly by default + template: deployment.yaml + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].readinessProbe.httpGet + value: + path: / + port: http + + - it: Deployment should have livenessProbe set correctly by default + template: deployment.yaml + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].livenessProbe.httpGet + value: + path: / + port: http + - it: Service should be named as release template: service.yaml asserts: @@ -59,3 +90,15 @@ tests: port: 80 protocol: TCP targetPort: http + + - it: Ingress should be named as release + template: ingress.yaml + set: + domain: example.com + ingress.enabled: true + asserts: + - isKind: + of: Ingress + - equal: + path: metadata.name + value: simple From 74e27ad2ed2602b2e60afe42691f047b792afaa0 Mon Sep 17 00:00:00 2001 From: rustam810 Date: Sat, 15 Jul 2023 23:50:30 +0400 Subject: [PATCH 20/31] add Ingress test --- charts/simple-app/tests/simple_test.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 2d39d57..5df449a 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -102,3 +102,14 @@ tests: - equal: path: metadata.name value: simple + + - it: Ingress should use service port + template: ingress.yaml + set: + servicePort: 80 + asserts: + - isKind: + of: Ingress + - equal: + path: spec.rules[0].http.paths[0].backend.service.port.number + value: 80 From f9f8055c9be40c5079720f79a3f410bbdd54966c Mon Sep 17 00:00:00 2001 From: rustam810 Date: Sat, 15 Jul 2023 23:53:28 +0400 Subject: [PATCH 21/31] add Ingress test --- charts/simple-app/tests/simple_test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 5df449a..67e4479 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -106,6 +106,8 @@ tests: - it: Ingress should use service port template: ingress.yaml set: + domain: example.com + ingress.enabled: true servicePort: 80 asserts: - isKind: From d6284379f6a60990ad9dc7c4f8675285865a98cf Mon Sep 17 00:00:00 2001 From: rustam810 Date: Sat, 15 Jul 2023 23:56:21 +0400 Subject: [PATCH 22/31] add Ingress test --- charts/simple-app/tests/simple_test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 67e4479..9334cd6 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -103,11 +103,9 @@ tests: path: metadata.name value: simple - - it: Ingress should use service port + - it: Ingress should be used service port template: ingress.yaml set: - domain: example.com - ingress.enabled: true servicePort: 80 asserts: - isKind: From c2612e96c78e23435c51d6c7edec774fff0ebd9a Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sun, 16 Jul 2023 00:23:24 +0400 Subject: [PATCH 23/31] fix and add more tests for ingress port --- charts/simple-app/templates/ingress.yaml | 2 +- .../tests/__snapshot__/simple_test.yaml.snap | 2 +- charts/simple-app/tests/simple_test.yaml | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/charts/simple-app/templates/ingress.yaml b/charts/simple-app/templates/ingress.yaml index f74e072..5af669c 100644 --- a/charts/simple-app/templates/ingress.yaml +++ b/charts/simple-app/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "simple-app.fullname" . -}} -{{- $svcPort := .Values.port -}} +{{- $svcPort := .Values.servicePort | default .Values.port -}} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} diff --git a/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap b/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap index cc7d4e2..5d44afd 100644 --- a/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap +++ b/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap @@ -65,7 +65,7 @@ All manifests should match snapshot: service: name: simple port: - number: 9000 + number: 80 path: /* pathType: ImplementationSpecific 3: | diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 9334cd6..ee582aa 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -103,13 +103,22 @@ tests: path: metadata.name value: simple - - it: Ingress should be used service port + - it: Ingress should use default service port if not specified template: ingress.yaml - set: - servicePort: 80 asserts: - isKind: of: Ingress - equal: path: spec.rules[0].http.paths[0].backend.service.port.number value: 80 + + - it: Ingress should use custom service port + template: ingress.yaml + set: + servicePort: 7000 + asserts: + - isKind: + of: Ingress + - equal: + path: spec.rules[0].http.paths[0].backend.service.port.number + value: 7000 From ffa147b45e837c3ef9a4bda8a9f6aa61bcbf8b7b Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sun, 16 Jul 2023 00:26:05 +0400 Subject: [PATCH 24/31] add test for custom port in service --- charts/simple-app/tests/simple_test.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index ee582aa..397aecd 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -91,6 +91,17 @@ tests: protocol: TCP targetPort: http + - it: Service should use custom port + template: service.yaml + set: + servicePort: 7000 + asserts: + - isKind: + of: Service + - equal: + path: spec.ports[0].port + value: 7000 + - it: Ingress should be named as release template: ingress.yaml set: From 6ab6648363f165a2aaf896f8db05ef543ed394cd Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sun, 16 Jul 2023 00:35:54 +0400 Subject: [PATCH 25/31] add manifest matching test for multiport case --- .../__snapshot__/multiport_test.yaml.snap | 116 ++++++++++++++++++ charts/simple-app/tests/multiport-values.yaml | 5 + charts/simple-app/tests/multiport_test.yaml | 13 ++ 3 files changed, 134 insertions(+) create mode 100644 charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap diff --git a/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap b/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap new file mode 100644 index 0000000..da1f3d8 --- /dev/null +++ b/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap @@ -0,0 +1,116 @@ +All manifests should match snapshot: + 1: | + apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple + spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: simple + app.kubernetes.io/name: simple-app + template: + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/name: simple-app + spec: + containers: + - image: test:1.1.1 + imagePullPolicy: IfNotPresent + livenessProbe: + httpGet: + path: / + port: http + name: simple-app + ports: + - containerPort: 9000 + name: http + protocol: TCP + - containerPort: 1 + name: port1 + protocol: TCP + - containerPort: 2 + name: port2 + protocol: TCP + readinessProbe: + httpGet: + path: / + port: http + resources: {} + securityContext: {} + volumeMounts: null + securityContext: {} + serviceAccountName: simple + volumes: null + 2: | + apiVersion: networking.k8s.io/v1 + kind: Ingress + metadata: + annotations: null + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple + spec: + rules: + - host: test.epoch8.co + http: + paths: + - backend: + service: + name: simple + port: + number: 9000 + path: /* + pathType: ImplementationSpecific + 3: | + apiVersion: v1 + kind: Service + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple + spec: + ports: + - name: http + port: 9000 + protocol: TCP + targetPort: http + - name: port1 + port: 1 + protocol: TCP + targetPort: port1 + - name: port2 + port: 22022 + protocol: TCP + targetPort: port2 + selector: + app.kubernetes.io/instance: simple + app.kubernetes.io/name: simple-app + type: ClusterIP + 4: | + apiVersion: v1 + kind: ServiceAccount + metadata: + labels: + app.kubernetes.io/instance: simple + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/version: 1.16.0 + helm.sh/chart: simple-app-1.0.0 + name: simple diff --git a/charts/simple-app/tests/multiport-values.yaml b/charts/simple-app/tests/multiport-values.yaml index 242f0e2..3c50d4c 100644 --- a/charts/simple-app/tests/multiport-values.yaml +++ b/charts/simple-app/tests/multiport-values.yaml @@ -14,3 +14,8 @@ extraPorts: - name: port2 port: 2 servicePort: 22022 + +domain: test.epoch8.co + +ingress: + enabled: true diff --git a/charts/simple-app/tests/multiport_test.yaml b/charts/simple-app/tests/multiport_test.yaml index df9a9df..4576dbe 100644 --- a/charts/simple-app/tests/multiport_test.yaml +++ b/charts/simple-app/tests/multiport_test.yaml @@ -1,9 +1,22 @@ suite: simple-app multiport case +release: + name: simple + namespace: default + values: - multiport-values.yaml tests: + - it: All manifests should match snapshot + templates: + - deployment.yaml + - service.yaml + - ingress.yaml + - serviceaccount.yaml + asserts: + - matchSnapshot: {} + - it: Deployment multiple port specification should work correctly template: deployment.yaml asserts: From 224b33e659d9c0c014c025ddd15ebdfff2049411 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sun, 16 Jul 2023 00:57:45 +0400 Subject: [PATCH 26/31] add more tests --- charts/simple-app/tests/simple_test.yaml | 33 ++++++++++++++++++++++++ charts/simple-app/values.schema.json | 7 ++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/charts/simple-app/tests/simple_test.yaml b/charts/simple-app/tests/simple_test.yaml index 397aecd..297ac6c 100644 --- a/charts/simple-app/tests/simple_test.yaml +++ b/charts/simple-app/tests/simple_test.yaml @@ -69,6 +69,39 @@ tests: path: / port: http + - it: Deployment should use imagePullSecrets if specified + template: deployment.yaml + set: + imagePullSecrets: + - name: test + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.imagePullSecrets + value: + - name: test + + - it: Deployment should mount shared memory volume if shmMem specified + template: deployment.yaml + set: + shmSize: 1Gi + asserts: + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].volumeMounts + value: + - mountPath: /dev/shm + name: shared-memory + - equal: + path: spec.template.spec.volumes + value: + - emptyDir: + medium: Memory + sizeLimit: 1Gi + name: shared-memory + - it: Service should be named as release template: service.yaml asserts: diff --git a/charts/simple-app/values.schema.json b/charts/simple-app/values.schema.json index 14b9336..76cc0be 100644 --- a/charts/simple-app/values.schema.json +++ b/charts/simple-app/values.schema.json @@ -23,7 +23,12 @@ "imagePullSecrets": { "type": "array", "items": { - "type": "object" + "type": "object", + "properties": { + "name": { + "type": "string" + } + } } }, "domain": { From 5a4a83e4a812f43f420b80a192ed2501590902d1 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Sun, 16 Jul 2023 01:04:27 +0400 Subject: [PATCH 27/31] add ingress test for multiport case --- charts/simple-app/tests/multiport_test.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/charts/simple-app/tests/multiport_test.yaml b/charts/simple-app/tests/multiport_test.yaml index 4576dbe..389d520 100644 --- a/charts/simple-app/tests/multiport_test.yaml +++ b/charts/simple-app/tests/multiport_test.yaml @@ -55,3 +55,12 @@ tests: port: 22022 protocol: TCP targetPort: port2 + + - it: Ingress multiple port specification should work correctly + template: ingress.yaml + asserts: + - isKind: + of: Ingress + - equal: + path: spec.rules[0].http.paths[0].backend.service.port.number + value: 9000 From 25c1f3cef4a4f2fcd280b5e4407f804d3627095c Mon Sep 17 00:00:00 2001 From: rustam810 Date: Mon, 17 Jul 2023 11:06:13 +0400 Subject: [PATCH 28/31] fix default values for service port --- charts/simple-app/templates/ingress.yaml | 2 +- charts/simple-app/templates/service.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/simple-app/templates/ingress.yaml b/charts/simple-app/templates/ingress.yaml index 5af669c..34ac64b 100644 --- a/charts/simple-app/templates/ingress.yaml +++ b/charts/simple-app/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "simple-app.fullname" . -}} -{{- $svcPort := .Values.servicePort | default .Values.port -}} +{{- $svcPort := .Values.servicePort -}} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1 {{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} diff --git a/charts/simple-app/templates/service.yaml b/charts/simple-app/templates/service.yaml index 3b3b0c1..bdeae70 100644 --- a/charts/simple-app/templates/service.yaml +++ b/charts/simple-app/templates/service.yaml @@ -7,7 +7,7 @@ metadata: spec: type: {{ .Values.serviceType }} ports: - - port: {{ .Values.servicePort | default .Values.port }} + - port: {{ .Values.servicePort }} targetPort: http protocol: TCP name: http From 2c2ad131c21b5aab99c122b96c7c4a2f999444f3 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Fri, 21 Jul 2023 14:17:30 +0400 Subject: [PATCH 29/31] add values.yaml docs and CHANGELOG --- charts/simple-app/CHANGELOG.md | 6 +++--- charts/simple-app/Chart.yaml | 2 +- charts/simple-app/values.yaml | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/charts/simple-app/CHANGELOG.md b/charts/simple-app/CHANGELOG.md index 848b5dd..c0370f3 100644 --- a/charts/simple-app/CHANGELOG.md +++ b/charts/simple-app/CHANGELOG.md @@ -1,10 +1,10 @@ # 1.0.0 -* Service port equals container port -* Delete `Values.probe`. `livenessProbe` and `readinessProbe` import from values file - ## Backwards incompatibility +* Default names for all resources equal to release name +* Delete `Values.probe`. `livenessProbe` and `readinessProbe` import from values file + # 0.9.1 * Add support for `.initialDelaySeconds` in `livenessProbe` and `readinessProbe` diff --git a/charts/simple-app/Chart.yaml b/charts/simple-app/Chart.yaml index f95d96f..3f19335 100644 --- a/charts/simple-app/Chart.yaml +++ b/charts/simple-app/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: "1.0.0" +version: "0.10.0" # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/simple-app/values.yaml b/charts/simple-app/values.yaml index c8195c1..11e61c1 100644 --- a/charts/simple-app/values.yaml +++ b/charts/simple-app/values.yaml @@ -17,11 +17,14 @@ image: imagePullSecrets: [] +# Port that container listens on port: 8000 +# Port that service should listen on servicePort: 80 -serviceType: ClusterIP +serviceType: ClusterIP # Service type +# Extra ports to expose from the container on the service extraPorts: [] # - name: grpc # port: 50051 From 85c2a192d07272d75ff867d7fa27775d09ace58d Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Fri, 21 Jul 2023 14:22:32 +0400 Subject: [PATCH 30/31] update changelog --- charts/simple-app/CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/charts/simple-app/CHANGELOG.md b/charts/simple-app/CHANGELOG.md index c0370f3..cb9e3b2 100644 --- a/charts/simple-app/CHANGELOG.md +++ b/charts/simple-app/CHANGELOG.md @@ -1,9 +1,13 @@ -# 1.0.0 +# 0.10.0 ## Backwards incompatibility * Default names for all resources equal to release name * Delete `Values.probe`. `livenessProbe` and `readinessProbe` import from values file +* Rename `.service.port` -> `.servicePort`, `.service.type` -> `.serviceType` +* Rename `.servicePorts` -> `.extraPorts` +* Add `.extraPorts[*].servicePort` config + # 0.9.1 From ec824ae9294fe03ac6b65b187a5226bdcb3e0741 Mon Sep 17 00:00:00 2001 From: Andrey Tatarinov Date: Fri, 21 Jul 2023 14:24:02 +0400 Subject: [PATCH 31/31] update test snapshot --- .../tests/__snapshot__/multiport_test.yaml.snap | 8 ++++---- .../simple-app/tests/__snapshot__/simple_test.yaml.snap | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap b/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap index da1f3d8..f6aeea4 100644 --- a/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap +++ b/charts/simple-app/tests/__snapshot__/multiport_test.yaml.snap @@ -8,7 +8,7 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple spec: replicas: 1 @@ -60,7 +60,7 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple spec: rules: @@ -83,7 +83,7 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple spec: ports: @@ -112,5 +112,5 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple diff --git a/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap b/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap index 5d44afd..9da4e0e 100644 --- a/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap +++ b/charts/simple-app/tests/__snapshot__/simple_test.yaml.snap @@ -8,7 +8,7 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple spec: replicas: 1 @@ -54,7 +54,7 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple spec: rules: @@ -77,7 +77,7 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple spec: ports: @@ -98,5 +98,5 @@ All manifests should match snapshot: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app app.kubernetes.io/version: 1.16.0 - helm.sh/chart: simple-app-1.0.0 + helm.sh/chart: simple-app-0.10.0 name: simple