Hands on DevSecOps Coaching that is provided on AWS and Azure Cloud platforms. Contact Coach AK at devops.coaching@gmail.com for more info. You can also reach out to Coach AK at +1(469) 733-5248
If you are using an AWS free tier account, every time you stop and restart the EC2
instance the public ip/dns name changes. To avoid this you can use the Elastic IP address provided by AWS.
Elastic IP address is static IP address or permanent address provided by AWS.
How to create Elastic IP address:
Go to AWS console, Click on EC2, Elastic IPs.
Click on Allocate Elastic IP address
Now it should create Elastic IP address.
Click
on Actions, Associate Elastic IP address and choose your instance from
Instances textbox and pick up the Private ip address automatically.
That's it! Elastic IP(static) address have been assigned to your EC2 instance.
Download the file using the curl command. The -o
option specifies the file name that the downloaded package is written to. In
this example, the file is written to
AWSCLIV2.pkg in the current folder.
Run the standard macOS installer program, specifying the
downloaded .pkg file as the source. Use the
-pkg parameter to specify the name of the package to install,
and the -target / parameter for which drive to install the package
to. The files are installed to /usr/local/aws-cli, and a
symlink is automatically created in /usr/local/bin. You
must include sudo on the command to grant write permissions to
those folders.
Webhooks are triggers that enables developers to trigger Jenkins jobs automatically every time there is a code change. Jenkins builds can be triggered by following ways:
pull - using poll scm
push mechanism - by triggering a build from Bitbucket or GitHub for every repository changes.
Slack commands
we will see in this article how to trigger (push) build in Jenkins for every change in bitbucket repository:
Changes needed in Jenkins
Select the job you would like to configure Webhook is for. Click on configure, under Build triggers section, click on Build when a change is pushed to Bitbucket. Save the build job.
Changes needed in Bitbucket 1. Go to Bitbucket, choose the repository where you have your webapp configured., go to settings, click on web hooks. 2. enter title, url which should be like --> http://jenkins_server_url/bitbucket-hook/
for e.g., http://ec2-18-191-42-55.us-east-2.compute.amazonaws.com:8080/bitbucket-hook/
3. status should be active.
4. click on skip certificate verification 5. triggers --> repository push Click save. you should be able to see the webhooks.
Now click on View requests. Make sure the url is correct
Now make a code change in Bitbucket to see if that triggers a build in Jenkins automatically. You can also watch the steps in my YouTube channel as well:
We will learn how to automate Docker builds using Jenkins and Deploy into Kubernetes Cluster setup using AKS. We will use Python based application. I have already created a repo with source code + Dockerfile. The repo also have Jenkinsfile for automating the following:
- Automating builds using Jenkins - Automating Docker image creation - Automating Docker image upload into Docker registry - Automating Deployments to Kubernetes Cluster
Pre-requisites: 1. AKS Cluster is setup and running. Click here to learn how to create AKS cluster.
2. Jenkins Master is up and running.
3. Setup Jenkins slave to run Docker builds 4. Docker, Docker pipeline and Kubernetes Deploy plug-ins are installed in Jenkins
Now Create an entry for your Docker Hub account. Make sure you enter the ID as dockerhub
Step #2 - Create Credentials for Kubernetes Cluster
Click on Add Credentials, use Kubernetes configuration from drop down.
execute the below command to get kubeconfig info, copy the entire content of the file:
sudo cat ~/.kube/config
Enter ID as K8S and choose enter directly and paste the above file content and save.
Step # 3 - Create a pipeline in Jenkins
Create a new pipeline job.
Step # 4 - 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 { label 'myslave' }
environment {
//once you sign up for Docker hub, use that user_id here
registry = "your_docker_hub_user_id/mypython-app"
//- update your credentials ID after creating credentials for connecting to Docker Hub
registryCredential = 'dockerhub'
dockerImage = ''
}
stages {
How to migrate Jenkins jobs from one Jenkins instance to another Jenkins instance?
Jenkins
jobs can be migrated in many ways. You can establish SSH connection b/w
source machine and target machine and use scp command to copy from one
instance to another instance. You can also use Job import plug-in to
migrate jobs.
Pre-requisites:
Make sure you install job import plugin in target Jenkins instance.
Steps to migrate jobs from source Jenkins to Target Jenkins instance:
Make sure you have right Jenkins source URL by logging to Source Jenkins.
Click on Manage Jenkins --> Configure System
Copy the Jenkins URL.
Logout from source Jenkins.
Steps in Target Jenkins
1. Login to Target Jenkins
2. Go to Manage Jenkins -->configure system--> click on Job import plug-in
Add source Jenkins url and login credentials.
3. Click on Save
4. Go to Jenkins -->Job Import plug-in
5. Select source Jenkins from down and check search into folder option
click on Query
6. Now it should pull all the jobs, choose the jobs you would like to migrate and click on Import.
Make sure you choose install required plug-ins option as well.
Now you should see the message.
7. Go to Jenkins home page and refresh it. You should see the jobs migrated successfully.
You can watch the steps in my YouTube channel as well:
Note: Please note that Credentials will not be migrated, only Jobs and plug-ins will be migrated.