From 1822d4ad20a81ea20a817087b3c5ecf096216bbc Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 12:00:41 +0530 Subject: [PATCH 01/11] fix helper tempate Signed-off-by: Ashwani Singh --- charts/microservice/templates/_helpers.tpl | 60 +++++++++++++++++++ charts/microservice/templates/deployment.yaml | 8 +-- charts/microservice/templates/service.yaml | 6 +- charts/microservice/values.yaml | 2 + 4 files changed, 69 insertions(+), 7 deletions(-) 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..f825ae67 --- /dev/null +++ b/charts/microservice/templates/_helpers.tpl @@ -0,0 +1,60 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* +Create a defautl fully qualified app name +It will use the release name to give the app name +*/}} + +{{- define "app.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 60 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "app.tempname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 60 | 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 }} + +{{- define "app.fullname" -}} +{{- printf "%s-%s" ( include "app.tempname" . ) "app" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "app.labels" -}} +app: {{ include "app.tempname" . }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "app.selectorLabels" -}} +app: {{ include "app.tempname" . }} +{{- end }}% + +{{/* +service name +*/}} +{{- define "app.servicename" -}} +{{- printf "%s-%s" ( include "app.tempname" . ) "svc" | trunc 63 | trimSuffix "-" }} +{{- end }}% + +{{/* +configmap name +*/}} +{{- define "app.configmapname" -}} +{{- printf "%s-%s" ( include "app.tempname" . ) "cm" | trunc 63 | trimSuffix "-" }} +{{- end }}% diff --git a/charts/microservice/templates/deployment.yaml b/charts/microservice/templates/deployment.yaml index 13f013f7..4292f925 100644 --- a/charts/microservice/templates/deployment.yaml +++ b/charts/microservice/templates/deployment.yaml @@ -1,18 +1,18 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "microservice.fullname" . }} + name: {{ include "app.fullname" . }} labels: - {{- include "microservice.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "microservice.selectorLabels" . | nindent 6 }} + {{- include "app.selectorLabels" . | nindent 6 }} template: metadata: labels: - {{- include "microservice.selectorLabels" . | nindent 8 }} + {{- include "app.selectorLabels" . | nindent 8 }} spec: containers: - name: {{ .Chart.Name }} diff --git a/charts/microservice/templates/service.yaml b/charts/microservice/templates/service.yaml index 1ace41b7..78d58947 100644 --- a/charts/microservice/templates/service.yaml +++ b/charts/microservice/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "microservice.fullname" . }} + name: {{ include "app.servicename" . }} labels: - {{- include "microservice.labels" . | nindent 4 }} + {{- include "app.labels" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: http selector: - {{- include "microservice.selectorLabels" . | nindent 4 }} + {{- include "app.selectorLabels" . | nindent 4 }} diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 67e2ed03..4ab82078 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -1,5 +1,7 @@ replicaCount: 1 +fullnameOverride: "nginx" +nameOverride: "" image: repository: nginx # your microservice image name pullPolicy: IfNotPresent From e928649e6ed5c4852adfddf59055b64f3d5c4b82 Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 12:01:00 +0530 Subject: [PATCH 02/11] fix parameters Signed-off-by: Ashwani Singh --- charts/microservice/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index 4ab82078..eaff2d46 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -3,9 +3,9 @@ replicaCount: 1 fullnameOverride: "nginx" nameOverride: "" image: - repository: nginx # your microservice image name + repository: nginx pullPolicy: IfNotPresent - tag: "latest" # your microservice image tag + tag: "latest" service: type: ClusterIP From 6f23fab56691b36b21c45afd42a821f5471176d5 Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 12:16:19 +0530 Subject: [PATCH 03/11] fix helm chart version Signed-off-by: Ashwani Singh --- 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..ae5e7d0f 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -3,5 +3,5 @@ name: microservice description: A Helm chart for a microservice in Kubernetes type: application -version: 0.1.0 +version: 0.1.1 appVersion: "1.0" From 8dd4b7d325b0a51e43262bb7af9ca5c1c0004273 Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 13:59:49 +0530 Subject: [PATCH 04/11] remove trailing spaces Signed-off-by: Ashwani Singh --- charts/microservice/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/values.yaml b/charts/microservice/values.yaml index eaff2d46..70374108 100644 --- a/charts/microservice/values.yaml +++ b/charts/microservice/values.yaml @@ -3,7 +3,7 @@ replicaCount: 1 fullnameOverride: "nginx" nameOverride: "" image: - repository: nginx + repository: nginx pullPolicy: IfNotPresent tag: "latest" From a30775cc73d3fdf3bdf61c5adce3ae27e5d201ef Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 16:27:09 +0530 Subject: [PATCH 05/11] remove trailing spaces Signed-off-by: Ashwani Singh --- 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 ae5e7d0f..2cc655a7 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -3,5 +3,5 @@ name: microservice description: A Helm chart for a microservice in Kubernetes type: application -version: 0.1.1 +version: 0.1.2 appVersion: "1.0" From eee0afb4fb32d69a01ff5e6a290245ea42d7bddb Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 16:32:42 +0530 Subject: [PATCH 06/11] add helm chart maintainers Signed-off-by: Ashwani Singh --- charts/microservice/Chart.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 2cc655a7..f0b047b0 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -1,7 +1,9 @@ apiVersion: v2 name: microservice description: A Helm chart for a microservice in Kubernetes - type: application -version: 0.1.2 +version: 0.1.1 appVersion: "1.0" +maintainers: + - name: Ashwani Singh + email: ashwani.singh@opstree.com From 4660f0e7b247e69aae8c4b3efb8f6a997e6e378c Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 16:35:57 +0530 Subject: [PATCH 07/11] add helm chart maintainers Signed-off-by: Ashwani Singh --- charts/microservice/Chart.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index f0b047b0..48989965 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -3,7 +3,6 @@ name: microservice description: A Helm chart for a microservice in Kubernetes type: application version: 0.1.1 -appVersion: "1.0" +appVersion: "0.1.1" maintainers: - - name: Ashwani Singh - email: ashwani.singh@opstree.com + - name: Opstree Solutions From 8195e90ce6629072db8ea63017a9b85b1a6cd4bf Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Tue, 2 Jul 2024 16:54:55 +0530 Subject: [PATCH 08/11] add helm chart maintainers Signed-off-by: Ashwani Singh --- charts/microservice/Chart.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/charts/microservice/Chart.yaml b/charts/microservice/Chart.yaml index 48989965..7be8a3b0 100644 --- a/charts/microservice/Chart.yaml +++ b/charts/microservice/Chart.yaml @@ -1,8 +1,9 @@ +--- apiVersion: v2 name: microservice description: A Helm chart for a microservice in Kubernetes type: application -version: 0.1.1 -appVersion: "0.1.1" +version: 0.1.2 +appVersion: "0.1.2" maintainers: - name: Opstree Solutions From 7f14587498e0c92deb4cd101d0069c1259d05354 Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Wed, 3 Jul 2024 16:02:59 +0530 Subject: [PATCH 09/11] todo list for ot microservices helm chart Signed-off-by: Ashwani Singh --- charts/microservice/README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/charts/microservice/README.md b/charts/microservice/README.md index ddcf4c67..63813bfd 100644 --- a/charts/microservice/README.md +++ b/charts/microservice/README.md @@ -21,4 +21,19 @@ The Helm chart is specifically for deploying a microservice with a Kubernetes se ```bash helm install my-release microservice/ -``` \ No newline at end of file +``` + +### TODO + +- [ ] Application Health Probes +- [ ] Service +- [ ] Horizontal Pod Autoscaler +- [ ] ConfigMap +- [ ] RBAC + - [ ] Service Account + - [ ] Role Binding + - [ ] Role +- [ ] Rolling Deployment Manupulation +- [ ] Environment Parmaters +- [ ] Container Port Mapping +- [ ] Application Secrets \ No newline at end of file From 05bacde3eb535a2f936592fa1b3436018ad15e40 Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Wed, 3 Jul 2024 16:09:44 +0530 Subject: [PATCH 10/11] fix typo Signed-off-by: Ashwani Singh --- charts/microservice/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/README.md b/charts/microservice/README.md index 63813bfd..c9c5b786 100644 --- a/charts/microservice/README.md +++ b/charts/microservice/README.md @@ -33,7 +33,7 @@ helm install my-release microservice/ - [ ] Service Account - [ ] Role Binding - [ ] Role -- [ ] Rolling Deployment Manupulation +- [ ] Rolling Deployment Manipulation - [ ] Environment Parmaters - [ ] Container Port Mapping - [ ] Application Secrets \ No newline at end of file From 640b1b1059b3d32e9b39d123da8ece62d51f559c Mon Sep 17 00:00:00 2001 From: Ashwani Singh Date: Wed, 3 Jul 2024 16:10:31 +0530 Subject: [PATCH 11/11] fix the heading Signed-off-by: Ashwani Singh --- charts/microservice/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/microservice/README.md b/charts/microservice/README.md index c9c5b786..cfe8f6e0 100644 --- a/charts/microservice/README.md +++ b/charts/microservice/README.md @@ -23,7 +23,7 @@ The Helm chart is specifically for deploying a microservice with a Kubernetes se helm install my-release microservice/ ``` -### TODO +## TODO - [ ] Application Health Probes - [ ] Service