From 5bb33da9f70753d7222bbaa71647382047e974b3 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:47:15 +0530 Subject: [PATCH 01/14] Update values.yaml --- charts/microservice/values.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 67e2ed03..0a38cb2d 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,9 +1,16 @@ -replicaCount: 1 +replicaCount: 3 image: - repository: nginx # your microservice image name + repository: nginx # Replace with your microservice image name pullPolicy: IfNotPresent - tag: "latest" # your microservice image tag + tags: + - "latest" + - "stable" + - "alpine" # Replace with your microservice image tag +env: + microservice: + selectorLabels: "micro" + fullname: "k8s" service: type: ClusterIP From e8431290fb2102b07ae10c747e99904c92780d52 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:48:41 +0530 Subject: [PATCH 02/14] Update deployment.yaml --- charts/microservice/templates/deployment.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 13f013f7..2686ce52 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -8,7 +8,7 @@ spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "microservice.selectorLabels" . | nindent 6 }} + {{- include "microservice.matchLabels" . | nindent 6 }} template: metadata: labels: @@ -18,7 +18,10 @@ spec: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: - name: http containerPort: 80 protocol: TCP + + From 56ecb969f37262a4e5eacc6f9df9092067a29e2a Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:49:47 +0530 Subject: [PATCH 03/14] Update service.yaml From 3fec83f16780d4c53b6e1a3db642699257c3ed44 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:52:00 +0530 Subject: [PATCH 04/14] Create _helpers.tpl --- charts/microservice/templates/_helpers.tpl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 charts/microservice/templates/_helpers.tpl diff --git a/charts/microservice/templates/_helpers.tpl b/charts/microservice/templates/_helpers.tpl new file mode 100644 index 00000000..95015ad0 --- /dev/null +++ b/charts/microservice/templates/_helpers.tpl @@ -0,0 +1,19 @@ +{{- define "microservice.fullname" -}} +{{- printf "%s-%s" (default .Chart.Name .Values.env.microservice.fullname) .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end -}} + +{{- define "microservice.labels" -}} +app.kubernetes.io/name: {{ .Chart.Name | quote }} +helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | replace ":" "-" | quote }} +app.kubernetes.io/instance: {{ .Release.Name | quote }} +app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" | replace ":" "-" | quote }} +app.kubernetes.io/managed-by: {{ .Release.Service | quote }} +{{- end -}} + +{{- define "microservice.selectorLabels" -}} +app: {{ default .Values.env.microservice.selectorLabels .Chart.Name | quote }} +{{- end -}} + +{{- define "microservice.matchLabels" -}} +app: {{ default .Values.env.microservice.selectorLabels .Chart.Name | quote }} +{{- end -}} From 401930dee45ebfa11b4b27235ac23e16e1801128 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 16:57:19 +0530 Subject: [PATCH 05/14] Update values.yaml --- charts/microservice/values.yaml | 50 ++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 0a38cb2d..9e492039 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,17 +1,41 @@ -replicaCount: 3 +#replicaCount: 3 + +#image: + # repository: nginx # Replace with your microservice image name + #pullPolicy: IfNotPresent + #tags: + # - "latest" + #- "stable" + #- "alpine" # Replace with your microservice image tag +#env: + # microservice: + # selectorLabels: "micro" + # fullname: "k8s" + +#service: + #type: ClusterIP + #port: 80 + + app: + name: my-microservice + +deployment: + replicas: 2 # Example number of replicas for your deployment image: - repository: nginx # Replace with your microservice image name - pullPolicy: IfNotPresent - tags: - - "latest" - - "stable" - - "alpine" # Replace with your microservice image tag -env: - microservice: - selectorLabels: "micro" - fullname: "k8s" + repository: nginx # Replace with your Docker image repository URL/name + tag: latest # Replace with your Docker image tag service: - type: ClusterIP - port: 80 + port: 80 # Example service port + targetPort: 8080 # Example target port + +configMap: + name: my-microservice-config + key: configKey + +secret: + name: my-microservice-secret + key: secretKey + value: my-secret-value + From a57b9470c9b4f7ed3efbf88627e7546d5a85a415 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:00:40 +0530 Subject: [PATCH 06/14] Update _helpers.tpl --- charts/microservice/templates/_helpers.tpl | 60 ++++++++++++++++++---- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/charts/microservice/templates/_helpers.tpl b/charts/microservice/templates/_helpers.tpl index 95015ad0..851405d4 100644 --- a/charts/microservice/templates/_helpers.tpl +++ b/charts/microservice/templates/_helpers.tpl @@ -1,19 +1,57 @@ +#{{- define "microservice.fullname" -}} +#{{- printf "%s-%s" (default .Chart.Name .Values.env.microservice.fullname) .Release.Name | trunc 63 | trimSuffix "-" }} +#{{- end -}} + +#{{- define "microservice.labels" -}} +#app.kubernetes.io/name: {{ .Chart.Name | quote }} +#helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | replace ":" "-" | quote }} +#app.kubernetes.io/instance: {{ .Release.Name | quote }} +#app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" | replace ":" "-" | quote }} +#app.kubernetes.io/managed-by: {{ .Release.Service | quote }} +#{{- end -}} + +#{{- define "microservice.selectorLabels" -}} +#app: {{ default .Values.env.microservice.selectorLabels .Chart.Name | quote }} +#{{- end -}} + +#{{- define "microservice.matchLabels" -}} +#app: {{ default .Values.env.microservice.selectorLabels .Chart.Name | quote }} +#{{- end -}} + +{{/* Define the "microservice.fullname" template */}} {{- define "microservice.fullname" -}} -{{- printf "%s-%s" (default .Chart.Name .Values.env.microservice.fullname) .Release.Name | trunc 63 | trimSuffix "-" }} +{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{- define "microservice.labels" -}} -app.kubernetes.io/name: {{ .Chart.Name | quote }} -helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | replace ":" "-" | quote }} -app.kubernetes.io/instance: {{ .Release.Name | quote }} -app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "_" | replace ":" "-" | quote }} -app.kubernetes.io/managed-by: {{ .Release.Service | quote }} +{{/* Define the "microservice.name" template (if needed) */}} +{{- define "microservice.name" -}} +{{- .Chart.Name | trunc 63 | trimSuffix "-" -}} {{- end -}} -{{- define "microservice.selectorLabels" -}} -app: {{ default .Values.env.microservice.selectorLabels .Chart.Name | quote }} +{{/* Define the "microservice.chart" template (if needed) */}} +{{- define "microservice.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* Define other templates as necessary */}} +{{/* Define the "microservice.labels" template */}} +{{- define "microservice.labels" -}} +{{- with .Values.labels }} +{{- toYaml . | nindent 4 }} +{{- end }} +{{- end }} + +{{/* Define the "microservice.matchLabels" template */}} {{- define "microservice.matchLabels" -}} -app: {{ default .Values.env.microservice.selectorLabels .Chart.Name | quote }} -{{- end -}} +{{- with .Values.app.name }} + app: {{ . }} +{{- end }} +{{- end }} + +{{/* Define the "microservice.selectorLabels" template */}} +{{- define "microservice.selectorLabels" -}} +{{- with .Values.app.name }} + app: {{ . }} +{{- end }} +{{- end }} + From d2399e4da3cffa9e7ff09ab08d67b7d6f742c4a9 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:11:22 +0530 Subject: [PATCH 07/14] Update deployment.yaml --- charts/microservice/templates/deployment.yaml | 55 +++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 2686ce52..21708a0d 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -1,27 +1,62 @@ +#apiVersion: apps/v1 +#kind: Deployment +#metadata: + # name: {{ include "microservice.fullname" . }} + #labels: + # {{- include "microservice.labels" . | nindent 4 }} +#spec: + # replicas: {{ .Values.replicaCount }} + #selector: + # matchLabels: + # {{- include "microservice.matchLabels" . | nindent 6 }} + #template: + # metadata: + # labels: + # {{- include "microservice.selectorLabels" . | nindent 8 }} + #spec: + # containers: + # - name: {{ .Chart.Name }} + # image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + # imagePullPolicy: {{ .Values.image.pullPolicy }} + + # ports: + # - name: http + # containerPort: 80 + # protocol: TCP + apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "microservice.fullname" . }} + namespace: {{ .Release.Namespace }} labels: - {{- include "microservice.labels" . | nindent 4 }} + app: {{ .Values.app.name }} spec: - replicas: {{ .Values.replicaCount }} + replicas: {{ .Values.deployment.replicas }} selector: matchLabels: - {{- include "microservice.matchLabels" . | nindent 6 }} + app: {{ .Values.app.name }} template: metadata: labels: - {{- include "microservice.selectorLabels" . | nindent 8 }} + app: {{ .Values.app.name }} spec: + serviceAccountName: {{ include "microservice.fullname" . }} containers: - - name: {{ .Chart.Name }} + - name: {{ .Values.app.name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - + - containerPort: {{ .Values.service.targetPort }} + env: + - name: CONFIG_FILE + valueFrom: + configMapKeyRef: + name: {{ include "microservice.fullname" . }} + key: {{ .Values.configMap.key }} + - name: SECRET_KEY + valueFrom: + secretKeyRef: + name: {{ include "microservice.fullname" . }} + key: {{ .Values.secret.key }} From d5148caea42ffee1b19ef3281f09f9de38592b5f Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:13:18 +0530 Subject: [PATCH 08/14] Update service.yaml --- charts/microservice/templates/service.yaml | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/charts/microservice/templates/service.yaml b/charts/microservice/templates/service.yaml index 1ace41b7..4e511027 100644 --- a/charts/microservice/templates/service.yaml +++ b/charts/microservice/templates/service.yaml @@ -1,15 +1,30 @@ -apiVersion: v1 +#apiVersion: v1 +#kind: Service +#metadata: + # name: {{ include "microservice.fullname" . }} + #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 }} + + apiVersion: v1 kind: Service metadata: name: {{ include "microservice.fullname" . }} + namespace: {{ .Release.Namespace }} labels: - {{- include "microservice.labels" . | nindent 4 }} + {{ include "microservice.labels" . }} # Include microservice.labels template spec: - type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http + targetPort: {{ .Values.service.targetPort }} selector: - {{- include "microservice.selectorLabels" . | nindent 4 }} + app: {{ .Values.app.name }} + From 4646b8f7f32613ab5aa210566c45ca084d612e84 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:15:23 +0530 Subject: [PATCH 09/14] Create service-account.yaml --- charts/microservice/templates/service-account.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 charts/microservice/templates/service-account.yaml diff --git a/charts/microservice/templates/service-account.yaml b/charts/microservice/templates/service-account.yaml new file mode 100644 index 00000000..89355096 --- /dev/null +++ b/charts/microservice/templates/service-account.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "microservice.fullname" . }} + labels: + app: {{ include "microservice.name" . }} From f096760fc239b0caa548c7b6d57098d879939bfb Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:16:33 +0530 Subject: [PATCH 10/14] Create config-map.yaml --- charts/microservice/templates/config-map.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 charts/microservice/templates/config-map.yaml diff --git a/charts/microservice/templates/config-map.yaml b/charts/microservice/templates/config-map.yaml new file mode 100644 index 00000000..1869cff5 --- /dev/null +++ b/charts/microservice/templates/config-map.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "microservice.fullname" . }} + namespace: {{ .Release.Namespace }} +data: + {{- range $key, $value := .Values.configMap.data }} + {{ $key }}: {{ $value | quote }} + {{- end }} From e66dcf6b187f1642477db5216bc2288f100fbbbf Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:17:37 +0530 Subject: [PATCH 11/14] Create secret-manager.yaml --- charts/microservice/templates/secret-manager.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 charts/microservice/templates/secret-manager.yaml diff --git a/charts/microservice/templates/secret-manager.yaml b/charts/microservice/templates/secret-manager.yaml new file mode 100644 index 00000000..5288f40c --- /dev/null +++ b/charts/microservice/templates/secret-manager.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "microservice.fullname" . }} + namespace: {{ .Release.Namespace }} +type: Opaque +data: + {{ .Values.secret.key }}: {{ .Values.secret.value | b64enc }} From 33e0865ce9cecd4ec85557ba787c44e96a9e13b1 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:05:18 +0530 Subject: [PATCH 12/14] Update deployment.yaml --- charts/microservice/templates/deployment.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 21708a0d..7a6f9632 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -23,8 +23,8 @@ # - name: http # containerPort: 80 # protocol: TCP - -apiVersion: apps/v1 + + apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "microservice.fullname" . }} @@ -60,3 +60,10 @@ spec: name: {{ include "microservice.fullname" . }} key: {{ .Values.secret.key }} + - name: PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.secret.name }} + key: {{ .Values.secret.passwordKey }} + + From 9c2e7efcbd8f0b0954ffed5f7193c417dee2cf25 Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:06:40 +0530 Subject: [PATCH 13/14] Update secret-manager.yaml --- charts/microservice/templates/secret-manager.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/microservice/templates/secret-manager.yaml b/charts/microservice/templates/secret-manager.yaml index 5288f40c..46d9fa15 100644 --- a/charts/microservice/templates/secret-manager.yaml +++ b/charts/microservice/templates/secret-manager.yaml @@ -2,6 +2,7 @@ apiVersion: v1 kind: Secret metadata: name: {{ include "microservice.fullname" . }} + name: {{ .Values.secret.name }} namespace: {{ .Release.Namespace }} type: Opaque data: From 883a3879032e3ab7040a5ad88a5d23601f206bee Mon Sep 17 00:00:00 2001 From: tripathishikha1 <156056746+tripathishikha1@users.noreply.github.com> Date: Wed, 19 Jun 2024 19:07:52 +0530 Subject: [PATCH 14/14] Update values.yaml --- charts/microservice/values.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 9e492039..2b948abb 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -16,6 +16,9 @@ #type: ClusterIP #port: 80 + + + app: name: my-microservice @@ -35,7 +38,9 @@ configMap: key: configKey secret: - name: my-microservice-secret + name: new-microservice-secret key: secretKey value: my-secret-value + passwordKey: password +password: my-secret-password