Helm
⚙ Introducing Helm: Sailing Smoothly Through Kubernetes Deployments 🚀
Are you diving into the world of Kubernetes deployments and feeling a bit lost at sea? Don't worry, Helm is here to rescue you! Let's sail through Helm and make your Kubernetes journey smoother.
🤔 What is Helm?¶
Helm is a package manager for Kubernetes applications, designed to simplify the process of deploying, managing, and scaling containerized applications. Think of it as your go-to tool for streamlining the management of complex Kubernetes resources.
🏗️ Helm Structure:¶
The Helm structure consists of:
- Charts: Bundles of pre-configured Kubernetes resources that define the structure of an application.
- Templates: Dynamic YAML files within charts, allowing parameterization and customization.
- Values: Configuration options that can be customized during deployment.
- Charts Repository: A centralized location for sharing and discovering Helm charts.
🧩 Components in a Helm Chart:¶
When you crack open a Helm chart, you'll find several key components:
my-chart/
├── charts/
├── templates/
│ ├── NOTES.txt
│ ├── deployment.yaml
│ ├── service.yaml
│ └── ... (other k8s manifest files)
├── Chart.yaml
├── values.yaml
└── README.md
- Chart.yaml: Metadata about the chart, including name, version, and dependencies.
- Templates: Kubernetes manifest files with placeholders for dynamic values.
- Values.yaml: Default configuration values for the chart.
- Charts: Subcharts or dependencies required by the main chart.
- README.md: Documentation providing instructions and guidance on using the chart.
- NOTES.txt: Helpful information and post-installation notes for users.
⚙️ Helm Basic Commands:¶
Getting started with Helm is a breeze thanks to its intuitive command-line interface. Here are some essential commands:
helm create <chart_name>
: Create a new chart.helm install <release_name> <chart_name>
: Install a chart.helm upgrade <release_name> <chart_name>
: Upgrade a deployed release.helm list
: List deployed releases.helm uninstall <release_name>
: Uninstall a release.
🚀 Sample Helm Project Files:¶
Now, let's dive into a sample Helm project to see how these concepts come together:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.deploymentname }} # 🚀 Name of the Deployment
spec:
replicas: 1 # 🚶 Number of desired replicas
selector:
matchLabels:
app: {{ .Values.appname }} # 🏷️ Selector to match pods with the label "app: wavecafe"
template:
metadata:
labels:
app: {{ .Values.appname }} # 🏷️ Labels applied to pods created by this template
spec:
containers:
- name: my-app-container # 📦 Name of the container
image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" # 🐳 Docker image to use
ports:
- name: cafe-port # 🌐 Name of the port
containerPort: 80 # 🚪 Port that the container listens on
apiVersion: v1
kind: Service
metadata:
name: wave-cafe # ☕ Name of the Service
spec:
selector:
app: {{ .Values.appname }} # 🏷️ Select pods with the label "app: wavecafe"
ports:
- protocol: TCP # 🌐 Protocol for the port
port: 80 # 🚪 Port on the Service
targetPort: cafe-port # 🚀 Port on the pods to forward traffic to
type: LoadBalancer
apiVersion: v2
name: wavecafe
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "1.16.0"
appname: wavecafe
deploymentname: wavecafe
servicename: wave-cafe
image:
name: saitejairrinki/wavecafe
tag: v1
Additional Features
In this Helm repository, I have added Horizontal Pod Autoscaling (HPA) and Kubernetes probes to ensure high availability and improved reliability.
Step-by-Step Guide:¶
-
Create a Chart: Start by creating a Helm chart named
wavecafe
using the command:helm create wavecafe
-
Delete Templates: Next, delete all the files in the
templates
folder created by Helm:rm wavecafe/templates/*
-
Update YAML Files: Update the
deployment.yaml
andservice.yaml
files with the above provided content in templates folder. wrtvalues.yaml
file. -
Install the Chart: Deploy your application using Helm with the following command:
helm install my-release wavecafe/ --values wavecafe/values.yaml
-
Upgrade (Optional): Make changes to your application and upgrade the release:
helm upgrade my-release wavecafe/ --values wavecafe/values.yaml
-
Uninstall: When you're done, uninstall the release:
helm uninstall my-release
Wrapping Up:¶
With Helm as your guiding star, Kubernetes deployments become smoother and more manageable than ever before. Bon voyage on your Kubernetes journey!
Happy Helming! ⚓🌟