- AWS
- K8s
- CI/CD (Jenkins)
- Docker
- In this project, Firstly I created a source code repository on github.
- Created a Jenkins multi-branch pipeline.
- Created a Kubernete cluster using AWS-EKS.
- A public Docker registry to store images
- On every push or update to the source-code repository Jenkins pipeline gets triggered.
- On getting triggered Jenkins does the followings:
- Fetch the new/updated source code from the repository.
- Build contianer/docker image of fetched source code.
- pushes the built image to the dockerhub.
- And Deploy the YAML files (K8s resources) to Kubernetes (AWS EKS).
- At the end K8s pulls the latest build from the dockerhub (image registry) and restart the application.
- Firstly, Created a source code repository.
- Created EKS cluster in my AWS environment.
- Then, I started a multibranch job type pipeline of Jenkins with the following Jenkinsfile:
That does everything followings:
pipeline { environment { dockerimagename = "mdsahiloss/simple-user-profile-page" dockerImage = "" } agent any stages { stage('Checkout Source') { steps { git 'https://github.com/MdSahil-oss/simple-user-profile-page.git' } } stage('Build image') { steps{ script { dockerImage = docker.build dockerimagename } } } stage('Pushing Image') { environment { registryCredential = 'DockerhubCredentials' } steps{ script { docker.withRegistry( 'https://registry.hub.docker.com', registryCredential ) { dockerImage.push("latest") } } } } stage('Deploying Application container to Kubernetes') { steps { withKubeConfig([ clusterName: 'minikube', namespace: 'default', contextName: 'jenkins-minikube', serverUrl: 'https://192.168.49.2:8443', credentialsId: 'k8s-creadentials' ]) { sh 'kubectl delete -f ./k8s && kubectl apply -f ./k8s' } } } } }
- Builds container image
- Push container image to dockerhub (image registry)
- Redeploy yaml resources to K8s cluster.
That's all about this project.