Integrating Google Kubernetes Engine with Container Registry using CloudBuild!
Motive: To update your Kubernetes containers with the latest image and updated code using CI-CD (CloudBuild)
What is Google Kubernetes Engine?
Google Kubernetes Engine (GKE) is a management and orchestration system for Docker container and container clusters that run within Google's public cloud services. Google Kubernetes Engine is based on Kubernetes, Google's open-source container management system.
What is Container Registry?
Container Registry is a single place for your team to manage Docker images, perform vulnerability analysis, and decide who can access what with fine-grained access control. Existing CI/CD integrations let you set up fully automated Docker pipelines to get fast feedback.
What is CloudBuild?
Cloud Build is a managed service on Google Cloud Platform infrastructure that allows you to continuously build, test and deploy containers. Cloud Build lets you build software quickly across all languages. Cloud Build works across multiple environments such as VMs, serverless, Kubernetes, or Firebase
Flow Diagram
So basically, the scenario is like we have our deployment-ready and deployment is exposed using LoadBalancer and we need to update the image used by the pods through automation. So here comes the role of CloudBuild to create a trigger whenever changes are pushed by the developer the CloudBuild will run the trigger automatically and your container image will be updated! Now, Let's start with the practical!
Prerequisites :
Here's my cluster ready
Here's my deployment ready
And here's my deployment exposed service using LoadBalancer
领英推荐
So here the version is 1.0
Below is the output from the LoadBalancer IP
Now clone your repo in the terminal and add some changes in server.js file such that the version is now 2.0
Now I'm pushing these changes in source repo
You can refresh and see the changes in your source repo
You will now see that the trigger has been started automatically
My build has successfully run and what it has done is building a new Dockerfile , pushing the image to Container Registry(GCR) and terminating old running pods and launching new pods with the updated image
Now you can see the New deployed image with the updated version v2.0.
GitHub repo : https://github.com/mohak77/cicd-service.git
Thankyou! I hope it helps , open for suggestions.
DevOps @Forescout ?? | Google Champion Innovator | AWS | DevOps | 3X GCP | 1X Azure | 1X Terraform | Ansible | Kubernetes | SRE | Jenkins | Tech Blogger ??
3 年Great bro Mohak Gund