Skip to content

explicit-logic/kubernetes-module-10.6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Module 10 - Container Orchestration with Kubernetes

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

Prerequisites

Before starting, configure a Kubernetes cluster as described in the previous demo project:

See: https://github.com/explicit-logic/kubernetes-module-10.5


1. Create a Helm chart scaffold

helm create microservice

This generates a boilerplate chart with default templates and values.

2. Clean up the generated chart

  • Remove all files from the templates/ directory except deployment.yaml and service.yaml
  • Clear the contents of both deployment.yaml and service.yaml
  • Clear the contents of values.yaml

3. Create reusable templates

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 }}

4. Add environment variables to deployment.yaml

Append an env block inside the container spec to inject per-service configuration:

  env:
   {{- range .Values.containerEnvVars }}
   - name: {{ .name }}
     value: {{ .value | quote }}
   {{- end }}

5. Define default values

Populate values.yaml with sensible defaults.

See: values.yaml

6. Create a values override for the Email Service

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 microservice

Helm lint output

Install the release:

helm install -f email-service-values.yaml emailservice microservice

# Verify the release
helm ls

Helm install output

7. Create values files for the remaining microservices

  • Create a separate <service>-values.yaml for each microservice defined in config.yaml (except redis, which needs its own chart)
  • Move all values files into the values/ directory for better organization

8. Create a dedicated chart for Redis

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 redis

Customize the Redis chart:

  • Remove all generated files from charts/redis/templates/ and clear values.yaml
  • Create deployment.yaml and service.yaml based on the Redis config in config.yaml
  • Templatize the manifests with Helm variables

See: deployment.yaml, service.yaml

Define values and validate:

  • Populate charts/redis/values.yaml with 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

Redis lint output

Redis dry-run output

About

Create Helm Chart for Microservices

Topics

Resources

Stars

Watchers

Forks

Contributors