Azure DevOps Helm Deployment π
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:
#Azure Pipeline Code: Helm Upgrade/Install π
- task: HelmDeploy@0
displayName: 'helm upgrade for [Component]'
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: $(KubernetesServiceConnection)
namespace: $(Namespace)
command: upgrade
chartType: FilePath
chartPath: '$(System.DefaultWorkingDirectory)/[PathToChart]'
releaseName: $(ReleaseName)
valueFile: '$(System.DefaultWorkingDirectory)/[PathToValuesFile]'
arguments: '--timeout 30m'
#Deployment Template File
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
#Service Template File
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.servicename }} # β 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
#Values File
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.
Happy Helming! βπ