Getting started with Helm on Kubernetes
Deploying applications to Kubernetes – the powerful and popular
container-orchestration system – can be complex. Setting up a single
application can involve creating multiple interdependent Kubernetes resources –
such as pods, services, deployments, and replicasets – each requiring you to
write a detailed YAML manifest file.
Helm is a package manager for Kubernetes that
allows developers and operators to more easily package, configure, and deploy
applications and services onto Kubernetes clusters.
Helm is the first
application package manager running atop Kubernetes. It allows describing the
application structure through convenient helm-charts and managing it with
simple commands.
Why is Helm important?
Because it’s a huge shift in the way the
server-side applications are defined, stored and managed. Adoption of Helm
might well be the key to mass adoption of microservices, as using this package
manager simplifies their management greatly.
Helm charts are built atop Kubernetes and benefit from its cluster
architecture. The main benefit
of this approach is the ability to consider scalability from the start. The charts of all the images used by Helm are
stored in a registry called Helm Workspace, so the DevOps teams can search them and add to their
projects with ease.
Helm is a tool for managing Kubernetes charts. Charts are packages of pre-configured Kubernetes resources.
Use Helm to:
- Find and use popular software packaged as Helm charts to run in Kubernetes
- Share your own applications as Helm charts
- Create reproducible builds of your Kubernetes applications
- Intelligently manage your Kubernetes manifest files
- Manage releases of Helm packages
Helm is a tool that streamlines installing and managing Kubernetes applications.
- Helm has two parts: a client (helm) and a server (tiller).
- Tiller runs inside of your Kubernetes cluster, and manages releases (installations) of your charts.
- Helm runs on your laptop, CI/CD, or wherever you want it to run.
- Charts are Helm packages that contain at least two things:
- A description of the package (Chart.yml)
- One or more templates, which contain Kubernetes manifest files
- Charts can be stored on disk, or fetched from remote chart repositories (like Debian or RedHat packages)
Charts
Helm packages
are called charts, and they consist of a few YAML configuration
files and some templates that are rendered into Kubernetes manifest files. Here
is the basic directory structure of a chart:
Example chart directory
package-name/
charts/
templates/
Chart.yaml
LICENSE
README.md
requirements.yaml
values.yaml
These
directories and files have the following functions:
- charts/: Manually managed chart dependencies can be placed in this directory, though it is typically better to use requirements.yaml to dynamically link dependencies.
- templates/: This directory contains template files that are combined with configuration values (from values.yaml and the command line) and rendered into Kubernetes manifests. The templates use the Go programming language's template format.
- Chart.yaml: A YAML file with metadata about the chart, such as chart name and version, maintainer information, a relevant website, and search keywords.
- LICENSE: A plaintext license for the chart.
- README.md: A readme file with information for users of the chart.
- requirements.yaml: A YAML file that lists the chart's dependencies.
- values.yaml: A YAML file of default configuration values for
the chart.
The helm command
can install a chart from a local directory, or from a .tar.gz packaged version of this directory structure.
These packaged charts can also be automatically downloaded and installed from
chart repositories or repos.
Pre-requisites
##############
1. Kubernetes Cluster
Installing Helm
Download helm tar file
#####################
master $ wget https://get.helm.sh/helm-v2.14.1-linux-386.tar.gz
Untar zip file
############
master $ tar -xvf helm-v2.14.1-linux-386.tar.gzUntar zip file
############
Move helm binary from extracted directory to /usr/bin/
############################################
master $ mv helm /usr/bin/
Initialize the tiller on kubernetes master
###############################
master $ helm init
Creating helm chart
#######################
master $ helm create hello
Creating hello
Edit values.yml file as below
##########################
Replace repository in image as per your application image and add tag as per your image tag as below:
master $ vim values.yaml
replicaCount: 1
image:
repository: shashanksr/myapp
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
Note: This application service will run on ClusterIP not on NodePort
Install your Hello app
##################
master $ helm install hello/
Check kubernetes pods & service
##############################
master $ kubectl get pods
NAME READY STATUS RESTARTS AGE
lovely-whippet-hello-6568cf6554-5crkv 1/1 Running 0 10m
master $ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 50m
lovely-whippet-hello ClusterIP 10.108.244.226 <none> 80/TCP 11m
Check helm release and status
###############################
master $ helm ls
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
lovely-whippet 1 Tue Jun 11 09:59:48 2019 DEPLOYED hello-0.1.0 1.0 default
master $ helm status lovely-whippet
LAST DEPLOYED: Tue Jun 11 09:59:48 2019
NAMESPACE: default
STATUS: DEPLOYED
Run the necessary commands as given above
########################################
master $ export POD_NAME=$(kubectl get pods --namespace default -l "app=hello,release=
lovely-whippet" -o jsonpath="{.items[0].metadata.name}")
master $ echo $POD_NAME
lovely-whippet-hello-6568cf6554-5crkv
master $ echo "Visit http://127.0.0.1:8080 to use your application"
Visit http://127.0.0.1:8080 to use your application
Forward port as below before curl your application
##########################################
master $ kubectl port-forward $POD_NAME 8080:80
Forwarding from 127.0.0.1:8080 -> 80
Forwarding from [::1]:8080 -> 80
Handling connection for 8080
Curl your website with the local IP in a new terminal
##########################################
master $ curl http://127.0.0.1:8080
Welcome to IBM Cloud DevOps with Docker, Kubernetes and Helm Charts. Lets go use the Continuous Delivery Servicemaster
I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
ReplyDeleteBest PHP Training Institute in Chennai|PHP Course in chennai
Best .Net Training Institute in Chennai
Dotnet Training in Chennai
Dotnet Training in Chennai
Thanks
DeleteVery Interesting Blog!! Thanks for sharing...
ReplyDeleteDocker Online Training
Kubernetes Online Training
ReplyDeleteGood Post! Thank you so much for sharing this pretty post.
DevOps Training
DevOps Online Training