From 5d1418380943cfc7a69e19eef3c885d47d5bbd96 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 13 Aug 2019 11:37:10 +0300 Subject: [PATCH 1/5] Add service account to Helm chart --- charts/podinfo/README.md | 2 ++ charts/podinfo/templates/_helpers.tpl | 11 +++++++++++ charts/podinfo/templates/deployment.yaml | 3 +++ charts/podinfo/templates/serviceaccount.yaml | 11 +++++++++++ charts/podinfo/values.yaml | 7 +++++++ 5 files changed, 34 insertions(+) create mode 100644 charts/podinfo/templates/serviceaccount.yaml diff --git a/charts/podinfo/README.md b/charts/podinfo/README.md index 05e4c3e..1ad3eeb 100644 --- a/charts/podinfo/README.md +++ b/charts/podinfo/README.md @@ -63,6 +63,8 @@ Parameter | Description | Default `service.nodePort` | node port for the service | `31198` `service.type` | type of service | `ClusterIP` `tolerations` | list of node taints to tolerate | `[]` +`serviceAccount.create` | specifies whether a service account should be created | `false` +`serviceAccount.name` | the name of the service account to use, if not set and create is true, a name is generated using the fullname template | None Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/charts/podinfo/templates/_helpers.tpl b/charts/podinfo/templates/_helpers.tpl index ef88d3d..62e6e12 100644 --- a/charts/podinfo/templates/_helpers.tpl +++ b/charts/podinfo/templates/_helpers.tpl @@ -30,3 +30,14 @@ Create chart name and version as used by the chart label. {{- define "podinfo.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "podinfo.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "podinfo.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/podinfo/templates/deployment.yaml b/charts/podinfo/templates/deployment.yaml index f70a728..1d0189f 100644 --- a/charts/podinfo/templates/deployment.yaml +++ b/charts/podinfo/templates/deployment.yaml @@ -26,6 +26,9 @@ spec: prometheus.io/scrape: 'true' spec: terminationGracePeriodSeconds: 30 + {{- if .Values.serviceAccount.create }} + serviceAccountName: {{ template "podinfo.serviceAccountName" . }} + {{- end }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" diff --git a/charts/podinfo/templates/serviceaccount.yaml b/charts/podinfo/templates/serviceaccount.yaml new file mode 100644 index 0000000..7d398bf --- /dev/null +++ b/charts/podinfo/templates/serviceaccount.yaml @@ -0,0 +1,11 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "podinfo.serviceAccountName" . }} + labels: + app: {{ template "podinfo.name" . }} + chart: {{ template "podinfo.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +{{- end -}} diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index 0d1d3b9..ef3fd1c 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -33,6 +33,13 @@ hpa: # average http requests per second per pod (k8s-prometheus-adapter) requests: +serviceAccount: + # Specifies whether a service account should be created + create: false + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + ingress: enabled: false annotations: {} From c759f958c09fa8f2d0e1f3d801bc461856cd06b6 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 13 Aug 2019 11:53:28 +0300 Subject: [PATCH 2/5] e2e: print logs after tests finished --- e2e/test.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/e2e/test.sh b/e2e/test.sh index 3dcb459..6653481 100755 --- a/e2e/test.sh +++ b/e2e/test.sh @@ -5,8 +5,12 @@ set -o errexit REPO_ROOT=$(git rev-parse --show-toplevel) export KUBECONFIG="$(kind get kubeconfig-path --name="kind")" +function finish { + echo '>>> Test logs' + kubectl logs -l app=podinfo +} +trap finish EXIT + echo '>>> Testing' helm test podinfo -echo '>>> Test logs' -kubectl logs -l app=podinfo From 53c6b472de7f7d3a46554b9117e65b79c6f35716 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 13 Aug 2019 12:02:32 +0300 Subject: [PATCH 3/5] Fix ClusterIP creation --- charts/podinfo/templates/service.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/podinfo/templates/service.yaml b/charts/podinfo/templates/service.yaml index f08b40a..f0b175f 100644 --- a/charts/podinfo/templates/service.yaml +++ b/charts/podinfo/templates/service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.hpa.enabled -}} +{{- if .Values.service.enabled -}} apiVersion: v1 kind: Service metadata: From 37b453fbbc5ef978afc5d39a759900de146b0eed Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 13 Aug 2019 12:08:50 +0300 Subject: [PATCH 4/5] Release v2.1.3 --- charts/podinfo/Chart.yaml | 4 ++-- charts/podinfo/values.yaml | 2 +- kustomize/deployment.yaml | 2 +- pkg/version/version.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/charts/podinfo/Chart.yaml b/charts/podinfo/Chart.yaml index 87cdbcd..c1a8164 100644 --- a/charts/podinfo/Chart.yaml +++ b/charts/podinfo/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 -version: 2.1.2 -appVersion: 2.1.2 +version: 2.1.3 +appVersion: 2.1.3 name: podinfo engine: gotpl description: Podinfo Helm chart for Kubernetes diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index ef3fd1c..c299a8c 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -12,7 +12,7 @@ faults: image: repository: stefanprodan/podinfo - tag: 2.1.2 + tag: 2.1.3 pullPolicy: IfNotPresent service: diff --git a/kustomize/deployment.yaml b/kustomize/deployment.yaml index 9aa81ac..1ef3514 100644 --- a/kustomize/deployment.yaml +++ b/kustomize/deployment.yaml @@ -24,7 +24,7 @@ spec: spec: containers: - name: podinfod - image: stefanprodan/podinfo:2.1.2 + image: stefanprodan/podinfo:2.1.3 imagePullPolicy: IfNotPresent ports: - containerPort: 9898 diff --git a/pkg/version/version.go b/pkg/version/version.go index 76e649e..7264675 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -1,4 +1,4 @@ package version -var VERSION = "2.1.2" +var VERSION = "2.1.3" var REVISION = "unknown" From 83842e01f7b660ce1c0667cd52d338228d586cd3 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 13 Aug 2019 12:12:52 +0300 Subject: [PATCH 5/5] Rename service account create to enabled --- charts/podinfo/README.md | 2 +- charts/podinfo/templates/_helpers.tpl | 2 +- charts/podinfo/templates/serviceaccount.yaml | 2 +- charts/podinfo/values.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/podinfo/README.md b/charts/podinfo/README.md index 1ad3eeb..f1fe6be 100644 --- a/charts/podinfo/README.md +++ b/charts/podinfo/README.md @@ -63,7 +63,7 @@ Parameter | Description | Default `service.nodePort` | node port for the service | `31198` `service.type` | type of service | `ClusterIP` `tolerations` | list of node taints to tolerate | `[]` -`serviceAccount.create` | specifies whether a service account should be created | `false` +`serviceAccount.enabled` | specifies whether a service account should be created | `false` `serviceAccount.name` | the name of the service account to use, if not set and create is true, a name is generated using the fullname template | None Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/charts/podinfo/templates/_helpers.tpl b/charts/podinfo/templates/_helpers.tpl index 62e6e12..7991e94 100644 --- a/charts/podinfo/templates/_helpers.tpl +++ b/charts/podinfo/templates/_helpers.tpl @@ -35,7 +35,7 @@ Create chart name and version as used by the chart label. Create the name of the service account to use */}} {{- define "podinfo.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} +{{- if .Values.serviceAccount.enabled -}} {{ default (include "podinfo.fullname" .) .Values.serviceAccount.name }} {{- else -}} {{ default "default" .Values.serviceAccount.name }} diff --git a/charts/podinfo/templates/serviceaccount.yaml b/charts/podinfo/templates/serviceaccount.yaml index 7d398bf..0de8a1c 100644 --- a/charts/podinfo/templates/serviceaccount.yaml +++ b/charts/podinfo/templates/serviceaccount.yaml @@ -1,4 +1,4 @@ -{{- if .Values.serviceAccount.create -}} +{{- if .Values.serviceAccount.enabled -}} apiVersion: v1 kind: ServiceAccount metadata: diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index c299a8c..9910b7c 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -35,7 +35,7 @@ hpa: serviceAccount: # Specifies whether a service account should be created - create: false + enabled: false # The name of the service account to use. # If not set and create is true, a name is generated using the fullname template name: