Monday, April 26, 2021

How to create Azure Resources using Terraform in Azure Cloud | Automate Infrastructure setup using Terraform in Azure Cloud | Create Azure WebApp using Terraform

WebApp is an App service provided by Azure Cloud for hosting your application. It supports .NET, .NET core, Java, PHP,  Python, Ruby and NodeJS. It is a fully managed Platform as a Serice (PaaS) where developers can deploy mobile or web applications in Azure Cloud in matter of seconds.

With App Service, you pay for the Azure compute resources you use. The compute resources you use are determined by the App Service plan that you run your apps on. We will provision WebApp in Azure cloud using Terraform.

Hashicorp's Terraform is an open-source tool for provisioning and managing cloud infrastructure. Terraform can provision resources on any cloud platform. 

Terraform allows you to create infrastructure in configuration files(tf files) that describe the topology of cloud resources. These resources include virtual machines, storage accounts, and networking interfaces. The Terraform CLI provides a simple mechanism to deploy and version the configuration files to Azure.

Watch the steps in YouTube:

Advantages of using Terraform:

  • Reduce manual human errors while deploying and managing infrastructure.
  • Deploys the same template multiple times to create identical development, test, and production environments.
  • Reduces the cost of development and test environments by creating them on-demand.

How to Authenticate with Azure?

Terraform can authenticate with Azure in many ways, in this example we will use Azure CLI to authenticate with Azure and then we will create resources using Terraform.


Azure CLI needs to be installed.

Terraform needs to be installed.

Logging into the Azure CLI

Login to the Azure CLI using:

az login

The above command will open the browser and will ask your Microsoft account details. Once you logged in, you can see the account info by executing below command:

az account list

Now create a directory to store Terraform files.

mkdir azure-terraform

cd azure-terraform

Let's create a terraform file to use azure provider. To configure Terraform to use the Default Subscription defined in the Azure CLI, use the below cod.

sudo vi

terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.38.0"

# Configure the Microsoft Azure Provider
provider "azurerm" {
  features {}

Now initialize the working directory

Perform the below command:

terraform init

Once directory is initialized, you can start writing code for setting up the infrastructure. 

Create WebApp(App Service) using Terraform script

sudo vi

# Create a resource group
resource "azurerm_resource_group" "dev-rg" {
  name     = "dev-environment-rg"
  location = "South Central US"

# Create app service plan
resource "azurerm_app_service_plan" "service-plan" {
  name = "simple-service-plan"
  location =
  resource_group_name =
  kind = "Linux"
  reserved = true
  sku {
    tier = "Standard"
    size = "S1"
  tags = {
    environment = "dev"

# Create JAVA app service
resource "azurerm_app_service" "app-service" {
  name = "my-awesome-app-svc"
  location =
  resource_group_name =
  app_service_plan_id =

site_config {
    linux_fx_version = "TOMCAT|8.5-java11"
tags = {
    environment = "dev"

Now Perform the below command to validate terraform files.

terraform validate

perform plan command to see how many resources will be created.

terraform plan

terraform apply

Do you want to perform these actions?

type yes 

Now Login into Azure Cloud to see all the resources created.

Install Azure CLI in Ubuntu 18.0.4 | How to setup Azure CLI in Ubuntu 18.0.4 | How to Install Azure CLI in Ubuntu

The Azure command-line interface (Azure CLI) is a set of commands used to create and manage Azure resources. The Azure CLI is available across Azure services and is designed to get you working quickly with Azure, with an emphasis on automation. Azure CLI is Microsoft's cross-platform command-line experience for managing Azure resources.

Azure CLI can be installed by following below steps:

Run the update first
sudo apt-get update

sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg -y

curl -sL |
    gpg --dearmor |
    sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] $AZ_REPO main" |
    sudo tee /etc/apt/sources.list.d/azure-cli.list

sudo apt-get update
sudo apt-get install azure-cli

Check the version of Azure CLI
az version

Run the Azure CLI with the az command. To sign in, use the az login command.

az login

Saturday, April 24, 2021

DevOps BootCamp by Coach AK on AWS and Azure Cloud Computing Online Classes | July/Aug 2023 Schedule

Did you loose your job? Are you really want to learn IT or any hot skills during Covid-19 Lock down period?

Are you in IT already but tired of your work? Are you not able to make a good progress in your career? 
Are you not having a job? Looking for a break in IT? No Worries.. 

Do learn DevOps and Cloud automation - DevOps is One of the top and hot IT skills right now in US. Currently almost all the employers are struggling to get a right resource in their teams who can do the DevOps and automation work..You could be that person by attending my coaching program.

DevOps Coaching Classes schedules for July/Aug 2023(currently $100 off promotion is going on)
July 27th6:00 to 8:00 PM CSTWeekdaysTuesdays/Thursdays    
Aug 5th11:35 AM CST to 01:30 PM on Saturdays
02:00 PM CST to 04:00 PM CST on Sundays    

DevOps Training highlights:

- Comprehensive hands on knowledge on Git, Jenkins, TeamCity, Maven, SonarQube, Nexus, Slack, Terraform, Ansible, Docker, Kubernetes on AWS and Azure.

- 23+ yrs IT experience, 8+ Yrs in DevOps/Cloud/Automation.

- Many students already placed in reputed companies from my coaching program successfully.

- Working as a Sr.DevOps Coach/Architect in a one of the top IT services companies in USA.

- Unique program...less theory, more hands on lab Person class room training

Resume preparation will be done with candidates personally.

One-to-one Interview coaching.

- Coaching is purely hands on with 101% job relevant.

100% Job assistance.

- Coached about 1500+ people successfully for past five years and many of my students got placed with many large enterprises in DFW, Chicago, Florida, Seattle, Bay area, Ohio and NY areas..

To join coaching classes, please contact coach below through email or phone number:

Contact no #: +1(469)733-5248
Email id:
Contact: Coach AK

Click here to learn more about the Coaching program

Saturday, April 17, 2021

How to setup Kubernetes Cluster in Ubuntu using Kubeadm | Install Kubernetes Cluster in Ubuntu | Setup Master Node and worker Node in Ubuntu EC2

Kubernetes  is an open source container platform that eliminates many of the manual processes involved in deploying and scaling containerized applications. We will learn how to setup Kubernetes Cluster in Ubuntu 18.0.4. You can setup Kubernetes Cluster in many ways. One of the ways is to use Kubeadm.

Kubeadm is a tool built to provide kubeadm init and kubeadm join as best-practice “fast paths” for creating Kubernetes clusters.

Watch the steps in YouTube video:


1. Ubuntu instance with 4 GB RAM - Master Node - (with ports open to all traffic)
2. Ubuntu instance with at least 2 GB RAM - Worker Node - (with ports open to all traffic)

Kubernetes Setup using Kubeadm

###Start - Execute the below commands in both Master/worker nodes##########

Login to both instances execute the below commands:
sudo apt-get update -y  && sudo apt-get install apt-transport-https -y

Change to root user
sudo su -
sudo curl -s | apt-key add -

cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main

sudo apt-get update

#Disable swap memory for better performance
swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

Enable IP tables
#We need to enable IT tables for pod to pod communication.
modprobe br_netfilter
sysctl -p
sudo sysctl net.bridge.bridge-nf-call-iptables=1

Install Docker on both Master and Worker nodes
apt-get install -y

Add ubuntu user to Docker group
usermod -aG docker ubuntu
systemctl restart docker
systemctl enable docker.service

Type exit to come out of root user.
Install Kubernetes Modules
sudo apt-get install -y kubelet kubeadm kubectl kubernetes-cni

sudo systemctl daemon-reload
sudo systemctl start kubelet
sudo systemctl enable kubelet.service
sudo systemctl status docker

#End - Execute the above commands in both Master/worker nodes##########

Initialize Kubeadm on Master Node(only on Master Node)

#Execute the below command as root user to initialize Kubernetes Master node.
sudo su -
kubeadm init

Make sure you see the above message to confirm master node is up.

#Now type exit to exit from root user and execute below commands as normal user

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Installing the Weave Net Add-On
kubectl apply -f "$(kubectl version | base64 | tr -d '\n')"
It make take a few mins to execute the above command and show show the below message.

Now execute the below command to see the pods.

kubectl get pods  --all-namespaces

Now login to Worker Node

Join worker node to Master Node
The below command will join worker node to master node, execute this a normal user by putting sudo before:

sudo kubeadm join <master_node_ip>:6443 --token xrvked.s0n9771cd9x8a9oc \
    --discovery-token-ca-cert-hash sha256:288084720b5aad132787665cb73b9c530763cd1cba10e12574b4e97452137b4a

Go to Master and type the below command
kubectl get nodes
the above command should display both Master and worker nodes.

It means Kubernetes Cluster - both Master and worker nodes are setup successfully and up and running!!!

Deploy Nginx on a Kubernetes Cluster
Let us run some apps to make sure they are deployed to Kuberneter cluster. We will do this in master node. The below command will create deployment:

kubectl create deployment nginx --image=nginx

View Deployments
kubectl get deployments

Create as a service 
kubectl create service nodeport nginx --tcp=80:80

kubectl get svc
run the above command to see a summary of the service and the ports exposed.

Now go Master or worker node, enter public dns and access it with port exposed
You should see the welcome page!

Thursday, April 15, 2021

ERROR: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException | Kubernetes Deployment Error

Kubernetes Deployment Error from Jenkins to EKS Cluster. When ever you deploy to Kubernetes from Jenkins, you may have the below error.

ERROR: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException: hudson.remoting.ProxyException: java.lang.RuntimeException: io.kubernetes.client.openapi.ApiException:

Fix - Set a clusterrole as cluster-admin

By default, clusterrolebinding has system:anonymous set which blocks the cluster access. Execute the following command to set a clusterrole as cluster-admin which will give you the required access.

kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=cluster-admin --user=system:anonymous

Thursday, April 1, 2021

How to enable webhooks for multibranch pipeline in Jenkins | Create webhooks for multibranch pipeline in Jenkins

How to kick start multibranch pipeline in Jenkins pipeline automatically every time you make a code change in your SCM?


We need to install multibranch scan webhook trigger plug-in

Go to Jenkins, Manage Jenkins. Manage plug-ins.

search by  multibranch scan

Once plug-in is installed, let's create a hook.

Please watch the above steps in YouTube channel:


Go to Jenkins, click on your existing multibranch pipeline job. Click on configure.

After installing the plug-ins, click on scan multibranch pipeline trigger section. click on scan by webhook. and enter token info.

Copy Jenkins url for configuring webhooks. click on ?

Now create a webhook in GitHub

Go to your git repo, click on settings, Webhooks.enter jenkins url


Click on update webhook. make sure it has configured correctly.

Now if you make a code change, it should trigger multi branch pipeline job.

How to create another branch from Main branch using command line

 Go to your EC2 instance or where ever your code exists in local repository. login to your instance and go to your repo.

cd reponame

Now let's create a new branch called develop from main branch.

git checkout -b develop

Now you can see how many branches are created locally.

git branch

git push --set-upstream origin develop

That is how you create a new branch from command line and push that branch into Remote repo.

How to create Multibranch pipeline in Jenkins | Multibranch pipeline tutorial

Let us learn how to create multi branch pipeline using Jenkins.

What is Multi-branch pipeline?

 - Automatically create new pipelines for every Git branch in source version control.

- Enables different pipeline implementation for every branch. for e.g let us say you want to have CICD pipeline for master branch and only CI pipeline for develop branch.

- an automatically discover new branches in the source control (GitHub or any SCM) and automatically create a pipeline for that branch.

Watch the steps in YouTube:

Create Jenkinsfile first

Please follow the link above to understand how to create Declarative pipeline - Jenkinsfile.

How to create multibranch pipeline?

 Go to Jenkins. Create a new Item. give a name like myMultiBranchPipelineJob

Click ok

Click branch source,  Add source, Add git.

Give your repo URL which has Jenkinsfile already.

Give your Git repo url, credentials. select credentials from the drop down.

Click apply and Save.

Now the pipeline job will automatically scan and creates pipeline per branch.

Azure DevOps Pipeline Optimization Best Practices | Optimizing Azure DevOps pipelines

Optimizing Azure DevOps pipelines is crucial for achieving faster and more efficient software delivery. Here are some best practices and str...