From b060362c5448a4183c0656a79e99e0231a334105 Mon Sep 17 00:00:00 2001 From: shikha Date: Mon, 24 Jun 2024 06:01:18 +0530 Subject: [PATCH 01/12] microservice/templates/_helpers.tpl --- charts/microservice/templates/_helpers.tpl | 18 ++++++++++++++++++ charts/microservice/templates/deployment.yaml | 15 +++++++++++++-- .../templates/nginx-configmap.yaml | 6 ++++++ .../microservice/templates/nginx-secret.yaml | 7 +++++++ .../templates/nginx-service-account.yaml | 4 ++++ charts/microservice/templates/service.yaml | 11 +++++------ charts/microservice/values.yaml | 16 ++++++++++++---- 7 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 charts/microservice/templates/_helpers.tpl create mode 100644 charts/microservice/templates/nginx-configmap.yaml create mode 100644 charts/microservice/templates/nginx-secret.yaml create mode 100644 charts/microservice/templates/nginx-service-account.yaml diff --git a/charts/microservice/templates/_helpers.tpl b/charts/microservice/templates/_helpers.tpl new file mode 100644 index 00000000..a036ee82 --- /dev/null +++ b/charts/microservice/templates/_helpers.tpl @@ -0,0 +1,18 @@ +{{- define "microservice.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "microservice.fullname" -}} +{{- $name := include "microservice.name" . -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- define "microservice.labels" -}} + app: {{ include "microservice.name" . }} +{{- end -}} +{{- define "microservice.selectorLabels" -}} + app: {{ include "microservice.name" . }} +{{- end -}} diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 13f013f7..dbcc1c6f 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -20,5 +20,16 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: 80 - protocol: TCP + containerPort: {{ .Values.httpPort }} + protocol: {{ .Values.protocol }} + env: + - name: MY_CONFIG_KEY + valueFrom: + configMapKeyRef: + name: {{ include "microservice.fullname" . }}-config + key: my-config-key + - name: MY_SECRET_KEY + valueFrom: + secretKeyRef: + name: {{ include "microservice.fullname" . }}-secret + key: my-secret-key diff --git a/charts/microservice/templates/nginx-configmap.yaml b/charts/microservice/templates/nginx-configmap.yaml new file mode 100644 index 00000000..8669eb67 --- /dev/null +++ b/charts/microservice/templates/nginx-configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "microservice.fullname" . }}-config +data: + my-config-key: my-config-value diff --git a/charts/microservice/templates/nginx-secret.yaml b/charts/microservice/templates/nginx-secret.yaml new file mode 100644 index 00000000..1e1fdfab --- /dev/null +++ b/charts/microservice/templates/nginx-secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "microservice.fullname" . }}-secret +type: Opaque +data: + my-secret-key: {{ "my-secret-value" | b64enc }} diff --git a/charts/microservice/templates/nginx-service-account.yaml b/charts/microservice/templates/nginx-service-account.yaml new file mode 100644 index 00000000..875fc3c1 --- /dev/null +++ b/charts/microservice/templates/nginx-service-account.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "microservice.fullname" . }}-sa diff --git a/charts/microservice/templates/service.yaml b/charts/microservice/templates/service.yaml index 1ace41b7..22406249 100644 --- a/charts/microservice/templates/service.yaml +++ b/charts/microservice/templates/service.yaml @@ -5,11 +5,10 @@ metadata: labels: {{- include "microservice.labels" . | nindent 4 }} spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http selector: {{- include "microservice.selectorLabels" . | nindent 4 }} + ports: + - name: http + protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.httpPort }} diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 67e2ed03..d3164cd9 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,10 +1,18 @@ -replicaCount: 1 +replicaCount: 3 image: - repository: nginx # your microservice image name + repository: nginx + tag: latest pullPolicy: IfNotPresent - tag: "latest" # your microservice image tag + +httpPort: 80 +protocol: TCP service: - type: ClusterIP port: 80 + +configMap: + my-config-key: my-config-value + +secret: + my-secret-key: my-secret-value From d7acad879c9a9e0a0ef632cc55a5b0b76767037b Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 12:31:29 +0530 Subject: [PATCH 02/12] Update values.yaml --- charts/microservice/values.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index d3164cd9..96795e5c 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,3 +1,5 @@ +app: + name: nginx-app replicaCount: 3 image: From e05c9632f223ffcdb64ee195f928b717a1377c2b Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 12:57:33 +0530 Subject: [PATCH 03/12] Update values.yaml --- charts/microservice/values.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 96795e5c..affc0bc4 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,5 +1,11 @@ -app: - name: nginx-app + +labels: + app: microservice + +selectorLabels: + app: microservice + release: stable + replicaCount: 3 image: From 533a1c2c7d07c56d6813d65f45ada9d7140d4e66 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:07:25 +0530 Subject: [PATCH 04/12] Update _helpers.tpl --- charts/microservice/templates/_helpers.tpl | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/charts/microservice/templates/_helpers.tpl b/charts/microservice/templates/_helpers.tpl index a036ee82..545c6a8d 100644 --- a/charts/microservice/templates/_helpers.tpl +++ b/charts/microservice/templates/_helpers.tpl @@ -1,18 +1,15 @@ {{- define "microservice.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- .Chart.Name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "microservice.fullname" -}} -{{- $name := include "microservice.name" . -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" $name .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- printf "%s-%s" (include "microservice.name" .) .Release.Name | trunc 63 | trimSuffix "-" -}} {{- end -}} + {{- define "microservice.labels" -}} - app: {{ include "microservice.name" . }} +app: {{ include "microservice.name" . }} {{- end -}} + {{- define "microservice.selectorLabels" -}} - app: {{ include "microservice.name" . }} +app: {{ include "microservice.name" . }} {{- end -}} From 8ad2e502a0aee102129697a14ec25ed3343810f5 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:24:01 +0530 Subject: [PATCH 05/12] Update _helpers.tpl From 7486f2df334d88913f3bd00ea96502abd24e72e4 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:24:34 +0530 Subject: [PATCH 06/12] Update service.yaml From 06e9f68dfdb91c7cdce4fbfbb6017b9772a6af01 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:26:04 +0530 Subject: [PATCH 07/12] Update values.yaml --- charts/microservice/values.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index affc0bc4..5ec1c105 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,7 +1,6 @@ - labels: app: microservice - + selectorLabels: app: microservice release: stable @@ -20,7 +19,7 @@ service: port: 80 configMap: - my-config-key: my-config-value + my-config-key: nginx-config-value secret: - my-secret-key: my-secret-value + my-secret-key: nginx-secret-value From 42b21408cb302c3be598eaa1e9008a1b15e1f8e2 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 14:26:41 +0530 Subject: [PATCH 08/12] Update values.yaml --- charts/microservice/values.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 5ec1c105..d640b4e4 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,3 +1,5 @@ +microservice: + fullname: NGINX labels: app: microservice From d5b17465adbf57c1007231bd9df3ed7e30719cdd Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:15:08 +0530 Subject: [PATCH 09/12] Update values.yaml --- charts/microservice/values.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index d640b4e4..6bb6f1de 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,5 +1,4 @@ -microservice: - fullname: NGINX + labels: app: microservice From 2112f9ab7e2e2b7912d3f1afe3dc5677940748ae Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:16:50 +0530 Subject: [PATCH 10/12] Update values.yaml --- charts/microservice/values.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 6bb6f1de..1ec9f16d 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,6 +1,6 @@ labels: - app: microservice + app: micro selectorLabels: app: microservice @@ -13,7 +13,6 @@ image: tag: latest pullPolicy: IfNotPresent -httpPort: 80 protocol: TCP service: From ecada0f4cfafff653430c98ecc47d1cf661fe223 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:40:05 +0530 Subject: [PATCH 11/12] Update Chart.yaml --- charts/microservice/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index caad7109..9b46a296 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: microservice +fullname: microservice description: A Helm chart for a microservice in Kubernetes type: application From 5a9382c50dd6095ff161e12a1d9678efb42bfdfe Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 26 Jun 2024 12:23:57 +0530 Subject: [PATCH 12/12] Update Chart.yaml --- charts/microservice/Chart.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 9b46a296..fea9b9cf 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -1,5 +1,6 @@ apiVersion: v2 -fullname: microservice +name: microservice +fullname: microservice-application description: A Helm chart for a microservice in Kubernetes type: application