Thursday, May 21, 2020

DevOps Coaching for Oct 2021 on AWS and Azure Cloud with Job Assistance

Did you loose your job? Are you really want to learn during Covid-19 Lock down period?

Are you in IT? 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.. 

Are you interesting in learning about DevOps? 

One of the top and hot IT skills right now is DevOps.
DevOps is THE hot skill 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 Schedule - Sep 2021(currently enrolling)

Date Time Type When?
Oct 21st 6:00 to 7:45 PM CST Weekdays Tues/Thursday
Oct 23rd 11:35 AM to 01:15 PM CST on Saturdays
         &
02:00 PM to 4 pm CST on Sundays
Weekends Sat/Sun

DevOps Training highlights:

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

- 20+ years of IT exp, 5+ years 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 exercises...in 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  950+ people successfully for past four years and many of my students got placed with many large enterprises in DFW, Chicago, Florida, Seattle, Bay area, Ohio and NY areas..

Contact no: 469-733-5248
Email - devops.coaching@gmail.com
Contact: AK

Saturday, May 16, 2020

How To Use BootStrap Scripts in AWS EC2 Instance during Launch - Running commands on your Linux instance at launch | How to Run commands on your Linux instance at launch

What is bootstrap script in aws?

if you want to execute some commands during boot up(also launch), you can execute it easily by mentioning during step 3 of EC2 launch. Bootstrap scripts run only once - when the instance is instantiated for the 1st time.

Please follow the below steps to create an EC2 instance.  We will be installing Java, Maven, Jenkins and Apache during boot up.

Steps to add bootstrap script during EC2 launch

1: Go to AWS console. click on All services, Click on Compute -->  Click on EC2



2. Click on Launch instance. Choose an Amazon machine image (AMI), click next

3. select Ubuntu Server 18.04 LTS (HVM), SSD Volume Type


click next
4. choose an instance type as t2.small, 2GB memory. click next

5. in step 3, go down, under advanced details.  Copy the script
from this link.

6. Now continue like how you provision EC2 instance.
7. once you provision, you will be able to see Java, Maven and Jenkins installed in EC2 instance after launch.

Login to EC2 instance when you type 
java -version
mvn --version


Go to the browser and try to access Jenkins in the browser, Jenkins should be coming up.(make sure you open port 8080 in the firewall rules)

Java, Maven and Jenkins should be installed successfully.


Shell script for installing Java, Maven and Jenkins in Ubuntu instance

#!/bin/bash
# Shell script for installing Java, Jenkins and Maven in Ubuntu EC2 instance

# Command for installing Java 11
sudo apt-get update
sudo apt-get install default-jdk -y

# Command for installing aws-cli
sudo apt install awscli -y

# Command for installing maven
sudo apt-get install maven -y

# Script for Jenkins installation

#Add Repository key to the system
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

#  Append debian package repo address to the system
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list

sudo apt-get update
# Install Jenkins
sudo apt-get install jenkins -y
echo "Jenkins installed successfully.."

Monday, May 4, 2020

Top 15 Docker commands - Popular Docker commands

  • docker images - Lists all the docker images stored locally
  • docker build - Builds an image from a specified docker file
  • docker pull - pulls images from the docker repository
  • docker run - creates a container from an image
  • docker ps - lists the running containers
  • docker ps -a - shows all the running and exited containers
  • docker exec - access the running container
  • docker stop - stops a running container
  • docker kill - kills the container by stopping its execution immediately
  • docker commit - creates a new image of an edited container on the local system
  • docker login - This command is used to login to the docker hub repository
  • docker push - pushes an image to the docker hub repository
  • docker rm - deletes a stopped container
  • docker rmi - deletes an image from local storage

Sunday, May 3, 2020

Automate Docker builds using Jenkins - Dockerize PHP App | Containerize PHP App | Build Docker images using Jenkins

We will learn how to automate Docker builds using Jenkins. We will use PHP based application. I have already created a repo with source code + Dockerfile. The repo also have Jenkinsfile for automating the following:

- Automating builds
- Automating Docker image creation
- Automating Docker image upload
- Automating Docker container provisioning

Pre-requistes:
1. Jenkins is up and running
2. Docker installed on Jenkins instance
3. Docker plug-in installed in Jenkins
4. user account setup in https://cloud.docker.com
5. Port 8086 open in security firewall rules

Step #1 - Create Credentials for Docker Hub
Go to your Jenkins where you have installed Docker as well. Go to credentials -->


Click on Global credentials
Click on Add Credentials


Now Create an entry for Docker Hub credentials

Make sure you take note of the ID as circled below:


Step # 2 - Create a scripted pipeline in Jenkins, name can be anything

Step # 3 - Copy the pipeline code from below
Make sure you change red highlighted values below:
Your docker user id should be updated.
your registry credentials ID from Jenkins from step # 1 should be copied

pipeline {
    agent any 
    environment {
        //TODO # 1 --> once you sign up for Docker hub, use that user_id here
        registry = "your_docker_userid/myphp-app-may20"
        //TODO #2 - update your credentials ID after creating credentials for connecting to Docker Hub
        registryCredential = 'fa32f95a-2d3e-4c7b-8f34-11bcc0191d70'
        dockerImage = ''
    }
    
    stages {
        stage('Cloning Git') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '', url: 'https://bitbucket.org/ananthkannan/phprepo/']]])       
            }
        }
    
    // Building Docker images
    stage('Building image') {
      steps{
        script {
          dockerImage = docker.build registry
        }
      }
    }
    
     // Uploading Docker images into Docker Hub
    stage('Upload Image') {
     steps{    
         script {
            docker.withRegistry( '', registryCredential ) {
            dockerImage.push()
            }
        }
      }
    }
    
     // Stopping Docker containers for cleaner Docker run
     stage('docker stop container') {
         steps {
            sh 'docker ps -f name=myPhpContainer -q | xargs --no-run-if-empty docker container stop'
            sh 'docker container ls -a -fname=myPhpContainer -q | xargs -r docker container rm'
         }
       }
    
    
    // Running Docker container, make sure port 8096 is opened in 
    stage('Docker Run') {
     steps{
         script {
            dockerImage.run("-p 8086:80 --rm --name myPhpContainer")
         }
      }
    }
  }
}  

Step # 4 - Click on Build - Build the pipeline
Once you create the pipeline and changes values per your Docker user id and credentials ID, click on 

Steps # 5 - Access PHP App
Once build is successful, go to browser and enter http://public_dns_name:8086
You should see page like below:

Create Jenkins Pipeline for automating Docker image creation and push docker image into Docker Hub | Dockerize Python App

We will learn how to automate Docker builds using Jenkins. We will use Python based application. I have already created a repo with source code + Dockerfile. We will be creating Jenkins pipeline for automating builds.


- Automating builds
- Automating Docker image creation
- Automating Docker image upload
- Automating Docker container provisioning

Pre-requistes:
1. Jenkins is up and running
2. Docker installed on Jenkins instance and configured.
3. Docker plug-in installed in Jenkins
4. user account setup in https://cloud.docker.com
5. port 8096 is opened up in firewall rules.

Step #1 - Create Credentials for Docker Hub
Go to your Jenkins where you have installed Docker as well. Go to credentials -->


Click on Global credentials
Click on Add Credentials


Now Create an entry for Docker Hub credentials

Make sure you take note of the ID as circled below:


Step # 2 - Create a pipeline in Jenkins, name can be anything

Step # 3 - Copy the pipeline code from below
Make sure you change red highlighted values below:
Your docker user id should be updated.
your registry credentials ID from Jenkins from step # 1 should be copied

pipeline {
    agent any 
    environment {
        //once you sign up for Docker hub, use that user_id here
        registry = "your_docker_user_id/mypythonapp"
        //- update your credentials ID after creating credentials for connecting to Docker Hub
        registryCredential = 'fa32f95a-2d3e-4c7b-8f34-11bcc0191d70'
        dockerImage = ''
    }
    
    stages {
        stage('Cloning Git') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '', url: 'https://bitbucket.org/ananthkannan/mypythonrepo']]])       
            }
        }
    
    // Building Docker images
    stage('Building image') {
      steps{
        script {
          dockerImage = docker.build registry
        }
      }
    }
    
     // Uploading Docker images into Docker Hub
    stage('Upload Image') {
     steps{    
         script {
            docker.withRegistry( '', registryCredential ) {
            dockerImage.push()
            }
        }
      }
    }
    
     // Stopping Docker containers for cleaner Docker run
     stage('docker stop container') {
         steps {
            sh 'docker ps -f name=mypythonappContainer -q | xargs --no-run-if-empty docker container stop'
            sh 'docker container ls -a -fname=mypythonappContainer -q | xargs -r docker container rm'
         }
       }
    
    
    // Running Docker container, make sure port 8096 is opened in 
    stage('Docker Run') {
     steps{
         script {
            dockerImage.run("-p 8096:5000 --rm --name mypythonappContainer")
         }
      }
    }
  }
}

Step # 4 - Click on Build - Build the pipeline
Once you create the pipeline and changes values per your Docker user id and credentials ID, click on 

Steps # 5 - Access Python App
Once build is successful, go to browser and enter http://public_dns_name:8096
You should see page like below:




Saturday, May 2, 2020

Docker Jenkins Integration | Building Docker Images using Jenkins | How to automate Docker Images creation using Jenkins

Every time developer makes code changes, you would want to Jenkins to automate Docker images creation and pushing into Docker registry. Let us see how to do this.

Pre-requistes:
Jenkins is up and running
Docker is installed in Jenkins machine. Click here to learn how to install Docker. 

Docker plug-in installed in Jenkins.
Docker pipeline plug-in installed in Jenkins.

Steps:

Add jenkins user to Docker group
sudo usermod -a -G docker jenkins

Restart Jenkins service
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
 
Watch the above steps in YouTube video

Install Docker Ubuntu | How to install Docker in Ubuntu 18.0.4 | Setup Docker on Ubuntu

Please find steps needed for installing Docker in Ubuntu 18.0.4 instance. You can install in Docker in many ways. But try only one option.

Docker installation steps using default repository from Ubuntu
Update local packages by executing below command:
sudo apt-get update

Install the below packages
sudo apt install gnupg2 pass -y

gnupg2 is tool for secure communication and data storage. It can be used to encrypt data and to create digital signatures
 
Install docker
sudo apt install docker.io -y

Add Ubuntu user to Docker group
sudo usermod -aG docker $USER

We need to reload shell in order to have new group settings applied. Now you need to logout and log back in command line or execute the below command:
newgrp docker

The Docker service needs to be setup to run at startup. To do so, type in each command followed by enter:

sudo systemctl start docker

sudo systemctl enable docker
sudo systemctl status docker

The above screenshot should confirm that Docker daemon is up and running.

Docker installation steps using Official Docker Repository (Alternative installation steps)

sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo systemctl status docker

now press q to come out this.
ps -ef | grep docker

docker --version

sudo docker run hello-world

the above command should display the below message..

you should see below message 
Hello from Docker!
This message shows that your installation appears to be working correctly.

Setup Docker Registry
Now we need to setup Docker registry. You have one of three options.

Option 1 - DockerHub as Docker Registry
Also, create an account(keep all lowercase in your username)  in the below website for storing docker images in public docker registry..

https://cloud.docker.com/
 
Option 2 - Configure Nexus as Docker Registry
Please click below link to configure Nexus as Docker Registry.
https://www.cidevops.com/2020/02/how-to-configure-nexus-as-docker.html

Option 3 - Configure AWS ECR as Docker Registry
Please click below link to configure Amazon ECR as Docker Registry.
https://www.cidevops.com/2020/05/how-to-setup-elastic-container-registry.html
 
Option 4 - Configure Azure Container Registry
Please click below link to configure ACR in Azure.
https://www.coachdevops.com/2019/12/how-to-upload-docker-images-to-azure.html

Microservices Introduction
Containerization is increasingly popular because containers are:
  • Flexible: Even the most complex applications can be containerized.
  • Lightweight: Containers leverage and share the host kernel.
  • Interchangeable: You can deploy updates and upgrades on-the-fly.
  • Portable: You can build locally, deploy to the cloud, and run anywhere.
  • Scalable: You can increase and automatically distribute container replicas.
  • Stackable: You can stack services vertically and on-the-fly.

How to Setup SonarQube on Azure VM | Install SonarQube Server on Ubuntu 18.0.4 VM in Azure Cloud

SonarQube is one of the popular static code analysis tools. SonarQube enables developers to write cleaner, safer code. SonarQube is open-sou...