This repository contains a demo project created as part of my DevOps studies in the TechWorld with Nana – DevOps Bootcamp.
Demo Project: Create Helm Chart for Microservices
Technologies used: Kubernetes, Helm
Project Description:
- Create 1 shared Helm Chart for all microservices, to reuse common Deployment and Service configurations for the services
Before starting, configure a Kubernetes cluster as described in the previous demo project:
See: https://github.com/explicit-logic/kubernetes-module-10.5
helm create microserviceThis generates a boilerplate chart with default templates and values.
- Remove all files from the
templates/directory exceptdeployment.yamlandservice.yaml - Clear the contents of both
deployment.yamlandservice.yaml - Clear the contents of
values.yaml
Start with the base Deployment manifest and replace hardcoded values with Helm template variables ({{ .Values.* }}):
deployment.yaml starting point:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.appName }}
spec:
selector:
matchLabels:
app: {{ .Values.appName }}
template:
metadata:
labels:
app: {{ .Values.appName }}
spec:
containers:
- name: {{ .Values.appName }}
image: {{ .Values.appImage }}
ports:
- containerPort: {{ .Values.containerPort }}service.yaml starting point:
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appName }}
spec:
type: ClusterIP
selector:
app: {{ .Values.appName }}
ports:
- protocol: TCP
port: {{ .Values.servicePort }}
targetPort: {{ .Values.containerPort }}Append an env block inside the container spec to inject per-service configuration:
env:
{{- range .Values.containerEnvVars }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}Populate values.yaml with sensible defaults.
See: values.yaml
Extract the emailservice configuration from config.yaml into a dedicated values file.
Validate and lint the chart before installing:
helm template -f email-service-values.yaml microservice
helm lint -f email-service-values.yaml microserviceInstall the release:
helm install -f email-service-values.yaml emailservice microservice
# Verify the release
helm ls- Create a separate
<service>-values.yamlfor each microservice defined inconfig.yaml(exceptredis, which needs its own chart) - Move all values files into the
values/directory for better organization
Redis requires a different template structure (e.g., no environment variables, volume mounts), so it gets its own chart.
Set up the chart:
mkdir -p charts
mv microservice charts/
cd charts
helm create redisCustomize the Redis chart:
- Remove all generated files from
charts/redis/templates/and clearvalues.yaml - Create
deployment.yamlandservice.yamlbased on the Redis config inconfig.yaml - Templatize the manifests with Helm variables
See: deployment.yaml, service.yaml
Define values and validate:
- Populate
charts/redis/values.yamlwith Redis defaults - Create redis-values.yaml with the override values
helm template -f values/redis-values.yaml charts/redis
helm lint -f values/redis-values.yaml charts/redis
helm install --dry-run -f values/redis-values.yaml redis-cart charts/redis


