In this lab session I will be setting up Kubernetes jenkins pipeline on AWS.
This will be a long session but I will be setting up everything from the scratch.
Here are steps which we will go through -
Setting up AWS EC2 Machine - First we need to set up EC2 machine where we will be installing the Jenkins along with Gradle, kubectl, eksctl, docker. We can not use t2.micro instance because we will need more CPU and memory to run Jenkins and Gradle.
Connect to EC2 machine - After starting the EC2 machine we will use the private key-pair file to connect to EC2 instance.
Install JDK - As we need to install Jenkins so we need to have JDK(https://adoptopenjdk.net/) pre-installed onto the EC2 machine. For this lab session I will be using adopt open JDK 11.
Install and Setup Jenkins - In this step we are going to install Jenkins and also going to the setup admin user
Assign administrative privileges to Jenkins user - After installing and setting up the Jenkins on EC2 machine we need to assign root privileges so that we can execute Docker and Gradle commands inside the Jenkins pipeline
Install Docker - The next step would be to install docker so that we can create a docker image and push the docker image to docker hub
Install and Configure AWS CLI - After installing the docker we need to install and configure AWS CLI so that we can use EKSCTL to set up and start the Kubernetes cluster.
Install kubectl - Also along with EKSCTL we need to install Kubectl so that we can view the deployments and services
Install eksctl - Now we need to install eksctl so that we can set up and start the Kubernetes cluster without using AWS UI
Add docker hub and GITHUB credentials - As we need to clone the github repo and push the docker image to docker hub we need to store credentials of github and docker inside Jenkins.
Jenkins script for stages - Once we are done all the above steps we are going to write the Jenkins pipeline scripts for all the stages