Part 4 : Deploy and Run applications in Kubernetes


Using Helm (The package manager for kubernetes) to deploy applications.  Run applications in Kubernetes cluster built using the Azure Container Service.


Running Kubernetes cluster and basic knowledge on Helm

Azure container registry (Private) is used as image repository


Installing Helm (Client) and Tiller (Server)

brew install kubernetes-helm

# Install Tiller on the kubernetes cluster and associated configuration on the local machine.

helm init

Now Check the version

helm version

# Run below command only if Tiller version is different

helm init --upgrade

Make sure the output versions are same for both client and server. If versions are different please update the version as required.

Follow the steps…

Since we are using azure container registry to store the images and pull the images into kubernetes cluster, we need to create the secrets for docker registry to enable the access.

Note: Make sure you are running them in appropriate context.

kubectl create secret docker-registry welcomeappacr --docker-server= --docker-username=<Replace with cluster SPN Object id> --docker-password=<Replace with SPN password>

# Run the below command to confirm the secret is available

kubectl get secret welcomeappacr

Secondly, we going to create the helm scripts. This scripts are basic template please modify as per your needs. If its a simple application then kubectl apply -f deployment.yaml is more sufficient. Helm is more useful for complex applications deployment scenario.

helm create helm-welcomeapp

Following directory structure will be created. Note: If you are in need of tree command please use the below or clear a alias in .zhrc

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
| |____deployment.yaml
| |____NOTES.txt
| |____ingress.yaml
| |____service.yaml
| |_____helpers.tpl

Now, Lets get our hands dirty in changing the following files to get our welcomeapp application deployed

apiVersion: v1
appVersion: "1.0"
description: A Helm chart for deploying welcomeapp
name: helm-welcomeapp
version: 0.1.0
icon :

Under the templates folder open deployment.yaml file, update the container port to whatever you have exposed in the docker file. (Refer to Part 1 : Running nodejs app (welcomeapp) on Docker Containers)

            - name: http
              containerPort: 8080
              protocol: TCP

Update the service.yaml file with correct target port. (Note : Values.service.internalPort this can be passed from the values.yaml)

    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.internalPort }} #8080
      protocol: TCP
      name: http

update the values.yaml with repository, service name, type, port and internalport as shown below.

replicaCount: 1
  tag: v1
  pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""

  name: welcomeapp
  type: LoadBalancer
  port : 80
  internalPort : 8080

  enabled: false
  annotations: {}
  path: /
  tls: []
resources: {}
nodeSelector: {}

tolerations: []

affinity: {}

Now, its time to package and install.

helm lint

helm package helm-welcomeapp --debug --version 0.1.0

helm install helm-welcomeapp --version 0.1.0

#Run the below command and wait for the public IP : Replace the service name with yours
kubectl get svc -w boisterous-tarsier-helm-welcomeapp

#NAME                                 TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
#boisterous-tarsier-helm-welcomeapp   LoadBalancer   <pending>     80:30315/TCP   34s
#boisterous-tarsier-helm-welcomeapp   LoadBalancer   80:30315/TCP   53s

Now you can browse our welcomeapp on the below above ip

# I am the Welcome app, used for the demo

All the helm chart is available under

Thats all for now, next blog is more about making the whole process as part of CI/CD pipeline and do upgrades to the application.
Hope you enjoy and let know if you stuck anywhere.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.