Thursday, May 26, 2022

How to setup monitoring on Kubernetes Cluster using Prometheus and Grafana | Setup monitoring on EKS Cluster using Prometheus and Grafana

What is Prometheus?

  • Prometheus is an open source monitoring tool
  • Provides out-of-the-box monitoring capabilities for the Kubernetes container orchestration platform. It can monitor servers and databases as well.
  • Collects and stores metrics as time-series data, recording information with a timestamp 
  • It is based on pull and collects metrics from targets by scraping metrics HTTP endpoints.

What is Grafana?

  • Grafana is an open source visualization and analytics software. 
  • It allows you to query, visualize, alert on, and explore your metrics no matter where they are stored.

Why System monitoring is critical?

  • Alerting: can give early warning of issues or problems before they become serious, costly or irreversible.
  • Visibility: Monitoring provides real-time insights into the health and performance of your applications and infrastructure.
  • Capacity Planning: By collecting and analyzing data over time, you can make informed decisions about capacity planning, such as when to add or remove nodes, allocate more resources, or scale your applications.

Please Watch this steps in YouTube Channel:

Prometheus Architecture

Key components:

    1. Prometheus server - Processes and stores metrics data
    2. Alert Manager - Sends alerts to any systems/channels
    3. Grafana - Visualize scraped data in UI

Installation Method:

The are are many ways you can setup Prometheus and Grafana. You can install in following ways:

1. Create all configuration files of both Prometheus and Grafana and execute them in right order.

2. Prometheus Operator - to simplify and automate the configuration and management of the Prometheus monitoring stack running on a Kubernetes cluster

3. Helm chart (Recommended) - Using helm to install Prometheus Operator including Grafana

Why to use Helm?

Helm is a package manager for Kubernetes. Helm simplifies the installation of all components in one command. Install using Helm is recommended as you will not be missing any configuration steps and very efficient. 


Implementation steps

We need to add the Helm Stable Charts for your local client. Execute the below command:

helm repo add stable

# Add prometheus Helm repo
helm repo add prometheus-community

helm search repo prometheus-community

Prometheus and grafana helm chart moved to kube prometheus stack

Create Prometheus namespace
kubectl create namespace prometheus

Install kube-prometheus-stack

Below is helm command to install kube-prometheus-stack. The helm repo kube-stack-prometheus (formerly prometheus-operator) comes with a grafana deployment embedded.

helm install stable prometheus-community/kube-prometheus-stack -n prometheus
Lets check if prometheus and grafana pods are running already

kubectl get pods -n prometheus

kubectl get svc -n prometheus

This confirms that prometheus and grafana have been installed successfully using Helm.

In order to make prometheus and grafana available outside the cluster, use LoadBalancer or NodePort instead of ClusterIP.

Edit Prometheus Service

kubectl edit svc stable-kube-prometheus-sta-prometheus -n prometheus

Edit Grafana Service

kubectl edit svc stable-grafana -n prometheus

Verify if service is changed to LoadBalancer and also to get the Load Balancer URL.

kubectl get svc -n prometheus

Access Grafana UI in the browser

Get the URL from the above screenshot and put in the browser

UserName: admin
Password: prom-operator

Create Dashboard in Grafana

In Grafana, we can create various kinds of dashboards as per our needs.

How to Create Kubernetes Monitoring Dashboard?

For creating a dashboard to monitor the cluster:

Click '+' button on left panel and select ‘Import’.

Enter 12740 dashboard id under Dashboard.

Click ‘Load’.

Select ‘Prometheus’ as the endpoint under prometheus data sources drop down.

Click ‘Import’.

This will show monitoring dashboard for all cluster nodes

How to Create Kubernetes Cluster Monitoring Dashboard?

For creating a dashboard to monitor the cluster:

Click '+' button on left panel and select ‘Import’.

Enter 3119 dashboard id under Dashboard.

Click ‘Load’.

Select ‘Prometheus’ as the endpoint under prometheus data sources drop down.

Click ‘Import’.

This will show monitoring dashboard for all cluster nodes

    Create POD Monitoring Dashboard

    For creating a dashboard to monitor the cluster:

    Click '+' button on left panel and select ‘Import’.

    Enter 6417 dashboard id under Dashboard.

    Click ‘Load’.

    Select ‘Prometheus’ as the endpoint under prometheus data sources drop down.

    Click ‘Import’.

    This will show monitoring dashboard for all cluster nodes.

    Cleanup EKS Cluster

    Use the below command to delete EKS cluster to avoid being charged by AWS.

    eksctl delete cluster --name demo-eks --region us-east-1

    or Login to AWS console --> AWS Cloud formation --> delete the stack manually.

    you can also delete the cluster under AWS console --> Elastic Kubernetes Service --> Clusters
    Click on Delete cluster

    Wednesday, May 25, 2022

    No such property: docker for class: groovy.lang.Binding | Jenkins Pipeline Error Docker Build | Jenkins docker pipeline error

    Jenkins Pipeline Error: 

    groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding.

    We most likely encountered the same issue, in order to fix it, install Docker Pipeline plugin in Jenkins:

    Root Cause and Fix:

    Jenkins need to have Docker Pipeline plug-in to perform Docker builds.

    Jenkins > Manage Jenkins > Manage Plugins > Available tab

    Search for Docker Pipeline install it, restart Jenkins and you are ready to go.

    Friday, May 20, 2022

    How to check whether my user data passing to EC2 instance is working | AWS EC2 bootstrap script log

    The cloud-init output log file (/var/log/cloud-init-output.log) captures console output so it is easy to debug your scripts following a launch if the instance does not behave the way you intended.

    Check the Logs in EC2 instance

    Login to EC2 instance, and type the below command:

    tail -f /var/log/cloud-init-output.log

    This will give the output of bootstrap execution

    Automate EKS Cluster using Bootstrap Script | Bootstrap script for setting up Jenkins, Docker and EKS Cluster in AWS cloud


    You need to create an IAM role with Administrator Access policy and attach that IAM role to EC2 instance while you provision.

    Click on Advanced Details and under user data:

    Script for setting up Jenkins, Docker and setting EKS cluster using eksctl command:


    # Shell script for installing Java,  Maven, Jenkins, EKS Cluster in Ubuntu EC2 instance

    # Command for installing Java 11

    sudo apt-get update

    sudo apt-get install default-jdk -y

    # Command for installing maven

    sudo apt-get install maven -y

    # Script for Jenkins installation

    #Add Repository key to the system

    curl -fsSL | sudo tee \
      /usr/share/keyrings/jenkins-keyring.asc > /dev/null

    Append debian package repo address to the system

    echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \ binary/ | sudo tee \
      /etc/apt/sources.list.d/jenkins.list > /dev/null

    sudo apt-get update

    # Install Jenkins

    sudo apt-get install jenkins -y

    echo "Jenkins installed successfully.."

    #Install Docker

    sudo apt-get update

    #Install the below packages

    sudo apt install gnupg2 pass -y

    #Install docker

    sudo apt install -y

    #Add Ubuntu user to Docker group

    sudo usermod -aG docker $USER

    # start Docker

    sudo systemctl start docker

    sudo systemctl enable docker

    sudo systemctl status docker

    sudo usermod -a -G docker jenkins

    sudo service jenkins restart

    #Reload system daemon files

    sudo systemctl daemon-reload

    #Restart Docker service as well

    sudo service docker stop

    sudo service docker start

    # Install AWS CLI

    curl "" -o "" 

    sudo apt install unzip

    sudo unzip  

    sudo ./aws/install

    aws --version

    #Install eksctl on Linux

    curl --silent --location "$(uname -s)_amd64.tar.gz" | tar xz -C /tmp

    #Move the extracted binary to /usr/local/bin. 

    sudo mv /tmp/eksctl /usr/local/bin

    eksctl version

    # Install Kubectl

    sudo curl --silent --location -o /usr/local/bin/kubectl

    sudo chmod +x /usr/local/bin/kubectl

    kubectl version --short --client

    # Install Helm

    curl -fsSL -o

    sudo chmod 700

    sudo ./

    helm version --client

    sudo su - jenkins

    #Create EKS cluster using eksctl command

    eksctl create cluster --name demo-eks --region us-east-1 --nodegroup-name my-nodes --node-type t3.small --managed --nodes 2 

    Thursday, May 12, 2022

    AWS, Azure Cloud and DevOps Coaching Online Classes | July/Aug 2023 Schedule

    Are you in IT? Tired of your work? Are you not able to make any good progress in your career? 

    Are you not having a job? Looking for a break in IT? Are you interested in learning DevOps? 
    Did you get laid off from your previous job due to Covid-19
    You are in the right place to kick start your career in DevOps. DevOps is one of the top and hot IT skills right now. Currently almost all the employers are struggling to get right resources in their teams who can do the DevOps and automation work..You could be that person by attending this 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 Coaching Highlights:

    - Comprehensive hands on knowledge on Git, Jenkins, Maven, SonarQube, Nexus, Terraform, Ansible, Puppet, Docker, AWS IAM, ECR, Docker registry. AWS and Azure cloud platforms.

    - Coach is having about 23+ yrs of professional IT experience, 8+ Yrs in DevOps/Cloud/Automation.

    - Many students already got placed in reputed companies from this 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 exercises...
    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+ students successfully for past five years and many of my students got placed with many large enterprises in DFW, Charlotte, Houston, Austin, Chicago, Florida, Seattle, Bay area, Ohio, NJ and NY areas..

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

    Contact no # : +1(469) 850-6424
    Email id:
    Contact: Coach AK

    Tuesday, May 10, 2022

    Install kubectl on Ubuntu Instance | How to install kubectl in Ubuntu | Install kubectl on Linux Instance

    Kubernetes uses a command line utility called kubectl for communicating with the cluster API server. It is tool for controlling Kubernetes clusters. kubectl looks for a file named config in the $HOME directory.

    sudo curl --silent --location -o /usr/local/bin/kubectl

    sudo chmod +x /usr/local/bin/kubectl 

    Verify if kubectl got installed
    kubectl version --short --client

    error: exec plugin: invalid apiVersion ""

    Kubectl Error:

    you may get this error when ever you are running kubectl command

    error: exec plugin: invalid apiVersion ""


    Make sure you update kubeconfig with below command:

    aws eks update-kubeconfig --name ${EKS_CLUSTER_NAME} --region ${REGION}

    How to install AWS CLI: 

    Please click on the below link:

    Error: checking AWS STS access – cannot get role ARN for current session: operation error STS: GetCallerIdentity

    Error: checking AWS STS access – cannot get role ARN for current session: operation error STS: GetCallerIdentity


    You need to attach IAM role with Administrator Access policy to the EC2 instance for creating EKS cluster.

    Monday, May 2, 2022

    stderr: remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication. remote: App passwords are recommended | returned status code 128 Jenkins Bitbucket | How to Create app passwords in Bitbucket?

    When you are creating any freestyle jobs or pipeline jobs in Jenkins, when you try to checkout a project from Bitbucket and If you are using Bibucket password, you may get this error.

    Reason for this error - returned status code 128 Jenkins Bitbucket:

    Beginning March 1, 2022, Bitbucket Cloud users will no longer be able to use their account passwords when using Basic authentication for Git over HTTPS and the Bitbucket Cloud REST API. The removal of account password usage for Basic authentication when using Git over HTTPS and/or the Bitbucket Cloud REST API is due to Bitbucket Cloud's ongoing effort to align with internal infrastructure and improve Atlassian account security. App passwords are substitute passwords for a user's account and are designed to be used for a single purpose with limited permissions.

    How to Create App Passwords in Bitbucket?

    Go to Bitbucket--> Settings
    Click on App passwords --> Create app password

    Now enter label name and click on read/write under repositories

    Click on Create, this will generate app password.
    Now you can this app password in Jenkins jobs.

    Watch these steps in Action in YouTube:

    Sunday, May 1, 2022

    Provision Ubuntu 22.0.4 EC2 Instance | How to create EC2 instance in AWS console | Launch Ubuntu 22.0.4 instance in AWS

    How to create EC2 instance in AWS console using new UI experience?

    What is EC2 instance? 

    It is virtual server provided by AWS. We will be using this EC2 to setup both Jenkins and Tomcat. Please follow the below steps to create an EC2 instance.

    Watch here for live demo:

    1: Login to AWS console by clicking this link -->
    click on All services, Click on Compute -->  Click on EC2

    2. Click on Launch instance

    3. Enter Name as EC2 and enter 2 as number of instances (one for Jenkins and another for Tomcat)

    4. Select Ubuntu 

    5. choose Ubuntu server 22.0.4 as AMI

    6. Enter t2.small as instance type
    7. Click on Create new Key Pair

    8. Choose the existing key pair if you have one, otherwise create new one, give some name as myJenkinsKey. Make sure you download the key in your local machine. Please do NOT give space or any character while naming the key.

    9. Under Network settings, Click Edit

    Add port range as 8080 and select AnyWhere as Source Type, that should enter as Source

    10. Enter 10 GB as storage 
    And then make sure in Summary, values appear as below:

    11. Click on Launch Instance.

    Click on View instances

    Now you should be able to view instances in AWS console. Now you can re-name as Jenkins-EC2 and Tomcat-EC2

    Connect to EC2 instance from local machine:
    Please click the below link to understand the steps for connecting to EC2 instance from your local machine - windows or Apple laptop.

    How to create Pull Request (PR) templates in Github repository | Creating a pull request template for your GitHub repository

    Creating pull request (PR) templates in GitHub can help streamline the process of submitting PRs by providing a predefined structure. Thi...