Deployment with Helm
Helm is a package manager for Kubernetes same as yum/rpm for RHEL.
Helm has below capabilities :-
- Install software.
- Automatically install software dependencies.
- Upgrade software.
- Configure software deployments.
- Fetch software packages from repositories.
Download for https://github.com/helm/helm/releases
It has two binary : helm and tiller
- HELM is client which can create Helm chart as well install them.
- TILLER is server which runs inside the k8s cluster as pod.
TILLER
Tiller is server which runs as pod and mange helm installation
Installation
Create new project (Or use existing ) for tiller project.
Download below YAML
https://github.com/openshift/origin/raw/master/examples/helm/tiller-template.yaml
Set TILLER_NAMESPACE to project name and install tiller as below command.
oc process -f tiller-template.yaml -p TILLER_NAMESPACE="${TILLER_NAMESPACE}" -p HELM_VERSION=v2.14.2| oc create -f –
Add permission for deployment ( Tiller service account in Tiller installation must have the cluser-admin role)
oc policy add-role-to-user edit "system:serviceaccount:${TILLER_NAMESPACE}:tiller"
To validate command is :-
oc get sa
TILLER Repo
Tiller repo is location where all Helm packages are present.
Few well known opensource example
- ChartMuseum https://chartmuseum.com/
- JFrog Artifactory https://www.jfrog.com/confluence/display/RTF/Helm+Chart+Repositories
- Git hub
Apart from repo can be set by using any local web server like apache web server / nginx
Configuration
For sample below we setup AHS
Run helm as client only (No Internet access then use --skip-refresh and remove stable)
helm init --client-only --skip-refresh
helm repo remove stable
# this will remove repo coming from https://kubernetes-charts.storage.googleapis.com.
Install Apache and add the URL to HELM repo by below command.
helm repo add gaurav http://gauravw:8080/
validate it as below
helm repo list
Creating Helm Chart
Helm usage Charts as packaging formatFor creating chart run below command
helm create microserivce
This will create directory structure like below
Chart.yaml
This file contains basic details for helm charts like chart name and version.
apiVersion: v1 #
Its always v1 (default same as yaml)
appVersion: "1.0“ # [Optional] for applicaton
version
description: A Helm chart for Kubernetes # Description of application
name: microservice # Name of
Chart.
version: 0.1.0 # Version of
Chart.
templates/ : Directory contain templates for all deployables.
It should be delete and created based on
need.
rm -f templates/*
By default it contains below files and
should be deleted before creating own application
deployment.yaml : Deplyments
template with image and other details
_helpers.tpl : for partial module
ingress.yaml : Ingress template
NOTES.txt :
Notes
serviceaccount.yaml : Create service account
service.yaml : Create serviceBelow is sample yaml file which can create tomcat pod while running command
On OpenShift :
oc create -f tomcat-pod.yaml
On vanila Kuberenetes
kubectl apply -f tomcat-pod.yaml
Values.yaml
This file makes helm charts dynamic. On this file we set values for variables which can be used in templates.
Below is sample where we replace values with variables.
as example we define .Values.image.name in values.yaml file as tomcat which replace while installation.
Packaging Helm Chart
To package run command
helm package <Chart>
Validation commands:
helm lint <Chart>
helm inspect <Chart>
helm install --dry-run --debug <Chart>
Adding package to Helm Repo
Once package created simply copy file to repo
For apache its under apache home (/var/www/html)
And reindex the repo by running below command.
helm repo index /var/www/html --url http://gauravw:8080/
And refresh repo to use them
helm repo update
Installing Helm Chart.
Once package added to repo it can be installed by below command.
helm install microservice
This will install microsevice on K8s / openshift.
No comments:
Post a Comment