Post on 19-Feb-2021
1 | Copyright © 2018 HCL Technologies | www.hcltech.comCopyright © 2018 HCL Technologies Limited | www.hcltech.com
Application Deployment to AKS using HELM Chart – A POV
23rd August, 2019
2 | Copyright © 2018 HCL Technologies | www.hcltech.com
Application Deployment in Kubernetes
▪ An application in Kubernetes typically consists of at least two resource types:
A Deployment Resource - describes a set of pods to be deployed togetherA Services Resource - defines endpoints for accessing the APIs in those pods.
▪ An application can also include ConfigMaps, Secrets, and Ingress.
▪ For any deployment, we would need several Kubernetes commands (kubectl) to create and configure resources.
▪ A Helm chart helps us create many resources with a set of commands, instead of manually creating each
resource separately.
▪ A default chart has a minimum of a deployment template and a service template.
3 | Copyright © 2018 HCL Technologies | www.hcltech.com
Typical Application Deployment Issues using Kubectl
▪ Deploying and maintaining multiple application to AKS using kubectl command is very difficult
▪ Deploying kubernetes applications including multiple YAML files using kubectl command is not easy
▪ Running multiple applications and maintaining ( Managing , Updating and Scaling ) them is very difficult task
▪ Rollback of kubernetes service application and updates through kubectl command is not easy
▪ Deploying kubernetes applications to multiple Environments ( Dev, QA & PROD ) with kubectl is very tedious job
▪ Using Kubernetes manifest file , we need to put a fixed values like Image name, version in the Kubernetes objects
YAML file for unique identification.
4 | Copyright © 2018 HCL Technologies | www.hcltech.com
Possible Solutions
Using HELM Chart ( Kubernetes Package Manger )
• to create Pods / Services to communicate each pod; Deploy container image to Pod, Persistence volume for configuration data.
Using Terraform ( Infrastructure as Code )
• + Kubectl Command
1 2
Feature HELM Chart Terraform
Package Manager Packaging + Versioning + Storing No Packaging
IAC ( Infrastructure as Code ) Supports application deployments to Kubernetes. No Azure Resource can be createdthrough this.
Creating/Building, changing and versioning infrastructure safely including AKS.
Language Support GO templates JSON/HCL ( Hashi Corp Language) file format
Charts Versioning Every Chart release will have a version. NA
Reusable Components Templates can be reused. Use modules to reuse
Cloud Supported Google Cloud, IBM Cloud , Azure AKS , Amazon EKS
AWS, GCP, MS Azure
5 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Components
Chart (Templates)
Values (Config)
Release (Resources)
HELM
Kubernetes Cluster
•Helm: A command-line interface (CLI) that installs charts into Kubernetes, creating a release for each installation.
•Chart: An application package that contains templates for a set of resources which are necessary to run the application. A template uses variables that are substituted with values when the manifest is created. The chart includes a values file that describes how to configure the resources.
•Release: An instance of a chart that is running in a Kubernetes cluster.
6 | Copyright © 2018 HCL Technologies | www.hcltech.com
Benefits of Using HELM Charts for Deployment
Cons
Pros
• Helps application deployment easy, standardized and reusable• Deploy and manage manifests in a production environment• Complex applications can be packaged together• Rollback or upgrade multiple objects together, • Reduces deployment complexity• Easily change parameters of templates, Allows user to edit the configuration values without
changing manifest files.
• Creating helm charts is rather complex • Helm Charts will install Server component in AKS called Tiller which manages the chart deployment • Two helm charts with same label they interfere with each other and damage the underlying resources.
7 | Copyright © 2018 HCL Technologies | www.hcltech.com
Deployment through HELM Chart – A POC
Deploying a containerized Web App to Azure Kubernetes Cluster through HELM Chart using DevOps CI/CD
Prerequisites
– Web API application Code
– Docker Container Image
– HEML Chart deployment files ( Deployment, Service and so on )
AKS Deployment Architecture
This Deployment uses Helm to Create Pods, Services to communicate each pod, Deploy container image to Pod, Persistence volume for storing configuration data.
Scope
8 | Copyright © 2018 HCL Technologies | www.hcltech.com
Configuration (Prerequisites) & Deployment Steps
Build the Docker Image (with the core appl. Binaries and
dependencies and host OS) and push it to ACR (or any other
registry) along with tags
Create a Docker file in the App code for single container (or create a Docker compose file for multi-
container)
Create ACR in Azure (either manually or through ARM template)
Configuration
Deployment Steps
Create AKS
Cluster
Verify Cluster
Create AKS
Resources
Configure CI Pipeline
Configure CD
Pipeline
Expose resources through External
Endpoints
Do AKS Resource
Health Check
9 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart – Deployment Step #1: Create AKS Cluster
1. Create a AKS Cluster through ARM templates since HELM chart does not create AKS ( Through DevOps CI/CD )
10 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart – Deployment Step #2: Verify Cluster Creation
2. Verify Cluster through AKS Dashboard – Plain Cluster gets created in Azure with additional steps required for application deployment
11 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart – Deployment Step #3: Creation of AKS Resources
▪ Create AKS resources using VS IDE –for each resource (network, deployment, service, loadbalancer, configuration,
persistence volumes, RBAC) respective kubernetes manifest / yaml file have to created.
Decide on type of resources to be created, based on requirement.
▪ Define load balancing technique, service endpoints, networking, security etc. through respective resources.
▪ Make the yaml files configurable through GO language referring to configurable values in values yaml file
▪ Create a HELM Chart template folder (with appropriate sub-folders – leverage standard HELM Chart templates
to have similar folder structure)
▪ All the yaml files have to be put in HELM Chart Templates folder of App code
3. Creation of AKS resources and deploying them in AKS
12 | Copyright © 2018 HCL Technologies | www.hcltech.com
Create AKS Resources – yaml files for different resource types
13 | Copyright © 2018 HCL Technologies | www.hcltech.com
Create AKS Resources – configuration yaml files using values.yaml
Changing Parameter values in Values.yaml file will reflect all the reference yaml files in Chart Folder
14 | Copyright © 2018 HCL Technologies | www.hcltech.com
Create AKS Resources – Leverage HELM Chart Templates
15 | Copyright © 2018 HCL Technologies | www.hcltech.com
Create AKS Resources – Chart Template Folder
Each Application will have a Chart folder to manage Release Version and can store in ACR
16 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart Deployment Steps - Step#4: CI Pipeline
• Create or reuse ACR Resource (reuse manually created ACR through above steps)
• Build Task to build and push Docker image to ACR
• Create a HELM task in CI pipeline to make a HELM Package (for better rollback process we can push this to ACR as a repository)
• Copy the ARM template files to CD pipeline (build configuration folder) for creation of Azure resources AKS and ACR
17 | Copyright © 2018 HCL Technologies | www.hcltech.com
CI Pipeline – List of Chart Files in Repositories (ACR)
18 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart Deployment Steps - Step#5: CD Pipeline
• Create AKS cluster or reuse existing cluster
• Install HELM Tiller into AKS• Pull the docker container
image from ACR• HELM upgrade – refer to
the HELM package created in CI pipeline
Once HELM package is run, respective appl. Binaries/dependencies will be deployed to respective clusters as defined through deployment/service/ loadbalancer/ network yamlfiles.(required set of pods per node of a cluster will be created dynamically through this deployment and these pods will run the appl. instances)
19 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart Deployment Step#6: Services Exposed via External Endpoints
• Get external IP of the service endpoints through kubectl commands
• Access the required resources through these endpoints
20 | Copyright © 2018 HCL Technologies | www.hcltech.com
HELM Chart Deployment Step#7: Health Check using AKS Dashboards
Do health checks through Azure AKS dashboard – to verify Deployments, PODs, Replica sets
21 | Copyright © 2018 HCL Technologies | www.hcltech.com
POC - Learning
# Issue Workaround Solution
1.Two helm charts cannot have same label which can impact underlying resources
While putting the label , ensure that it is not duplicated.
2. Timeout in helm upgrade task Increased timeout number (but didn’t solve for all cases)
3. Unable to access service outside cluster Get the service LB IP through kubectl command
4.Improper Indentation of Helm File will createrendering issue
Make sure User need to validate the helm files before deploying
22 | Copyright © 2018 HCL Technologies | www.hcltech.com
References
1. https://helm.sh/docs/developing_charts/#charts
3. https://boxboat.com/2018/09/19/helm-and-kubernetes-deployments/
4. https://developer.epages.com/blog/tech-stories/kubernetes-deployments-with-helm/
2. https://kubernetes.io/docs/concepts/
5. https://helm.sh/docs/chart_template_guide/
https://helm.sh/docs/developing_charts/#chartshttps://boxboat.com/2018/09/19/helm-and-kubernetes-deployments/https://developer.epages.com/blog/tech-stories/kubernetes-deployments-with-helm/https://kubernetes.io/docs/concepts/https://helm.sh/docs/chart_template_guide/
23 | Copyright © 2018 HCL Technologies | www.hcltech.comCopyright © 2018 HCL Technologies Limited | www.hcltech.com
Thank You!!!
Write to us at ADvantage Azure
mailto:advaz@hcl.com
$7.3 BILLION ENTERPRISE | 119,000 IDEAPRENEURS | 32 COUNTRIES
https://www.youtube.com/watch?v=JzfmzTcVUJg