This README provides step-by-step instructions for setting up a development and deployment environment for your project. The environment involves technologies like Docker, Kubernetes, Jenkins, and GitHub.
- Installation and Setup
- Ubuntu Server and Docker
- Kubernetes Cluster Setup
- Automated Build and Release with Jenkins
https://drive.google.com/file/d/1HSFAQOaUX285cRCGmbiPx5dzLrO-d7JC/view?usp=sharing
https://drive.google.com/file/d/12jGbqji73piYlNwunUmf0P5Qeth064ZC/view?usp=sharing
-
GitHub Repository : Commit code for HW1 on a github repository. GitHub repository.
-
Docker Hub Repository: A Docker Hub repository for the .war file is available at Docker Hub Repository.
-
Start an EC2 instance using an Ubuntu AMI. You can access the Rancher Dashboard here.
-
Install Docker on the Ubuntu instance.
-
Run Rancher on the EC2 instance. You can verify that Rancher is running by executing
sudo docker ps
. -
Access the Rancher dashboard using the public DNS address of the EC2 instance.
-
Create a custom cluster within Rancher for your application.
-
Create another EC2 instance, ensuring it has at least 25GB of storage, and use an Ubuntu AMI. This instance will serve as your Kubernetes server. You can access it at K8s server.
-
After installing Docker on the new EC2 instance, register the nodes for your Kubernetes cluster using the provided command. This instance will host the etcd, control panel, and worker nodes.
-
Once the Kubernetes cluster is active, create two deployments (one with NodePort and one with LoadBalancer).
-
Download the KubeConfig file for your cluster and save it.
-
Provide the Docker repository address for the deployment to pull the image and deploy the application.
-
Verify that the pods are created and have a status of "running."
-
Check the logs for the pods using the command
kubectl logs <pod_name>
to ensure the .war file was successfully loaded. -
You should be able to access the "Student Survey" form from the deployment services address.
-
Create another EC2 instance to host Jenkins. You can access Jenkins at Jenkins.
-
Install Java on this instance and then install Jenkins from https://pkg.jenkins.io/debian/.
-
Login to Jenkins UI then: Manage Jenkins -> Credentials(Under Security) -> Click on (global) under Domains -> Add Credentials
-
To add kubeconfig.yaml, Kind = Secret file, File = Attach your .yaml file downloaded from Rancher, ID = You can give any name or it will be auto generated.
-
We also added credentials for DockerHub follow same steps as point 3, which we used in our Jenkins file.
-
Create a Jenkins pipeline and install the necessary plugins, including CloudBees Docker and Rancher.
-
Configure the pipeline with the source as your GitHub repository. Enable polling of the SCM every minute and provide access to the JenkinsFile stored in your GitHub repository.
-
Create and push a 'JenkinsFile' that consists of stages, including: a. Build. b. Push to Docker Hub. c. Deploy on Rancher single node. d. Deploy on Rancher.
-
Once the pipeline is successfully set up, any changes to the code pushed to GitHub will trigger a new build. After completing all the pipeline stages, the new build will be pushed to Docker Hub, and the image will be updated in Rancher deployments, now hosting the newly created build.