GKE cluster automation using terraform and manifest

GKE cluster automation using terraform and manifest

No alt text provided for this image

Deploying your application on Kubernetes cluster is like getting the maximum outcome of your application while you are totally free mind to manage your application instances and when you able to provision your Kubernetes cluster on GCP using any IaC (Infrastructure as code) tool like terraform it will be so much helpful in your DevOps process.

So here is a flawless procedure I would like to share with you which I recently deployed in my cloud ecosystem, and my Kubernetes cluster is highly Available, super scalable fault and strong fault-tolerant now, the application is running flawlessly without a single hassle.

Below is my approach to creating a GKE on GCP using terraform and k8s manifest files and on the top of Kubernetes there is one app is running used from my docker hub image.

  1.  Terraform IAC (infrastructure as a code) script to create a GKE on GCP:- I used WSL on my windows 10 so on the top of ubuntu I have installed the GCP Cloud SDK and terraform on my local laptop from where I used to execute all DevOps commands to create the GKE Cluster as required
No alt text provided for this image
terraform plan -out 'devops-plan-GKE.plan'

2. The terraform apply output once successful of execution of the IAC script completion

There are 2 files for terraform providers.tf, main.tf, and variables.sh to create GKE using terraform with where I have declared the value of machine type, min, and max no of nodes in the pool.

terraform apply 'devops-plan-GKE.plan'
No alt text provided for this image

3. Once the GKE cluster is successfully created you need to create credentials to your KUBECONFIG (~/.kube/config) so that you can interact with this cluster and once its done next step to execute your k8s deployment and service to deploy your application and load balancer respectively so the application can interact with end-users using the interest.

gcloud container clusters get-credentials <cluster-name> --region us-central1


kubectl apply --filename hello-k8s-deploy.yaml
 

kubectl apply --filename hello-k8s-svc.yaml

the output would be like below once you successfully executed the application deployment and services in your Kubernetes cluster

No alt text provided for this image

4. The manifest file also using my docker hub image (meetravi007/ravi-app:v1.0) for creating deploying the app in pods. please refer to my GitHub repository shared in this article.

5. Once successfully k8s cluster deployment is completed you can able to get load balancer external up for end-user use over the internet.

No alt text provided for this image
No alt text provided for this image

6. you can run the web application using LB external IP

No alt text provided for this image

5. All required terraform files and yamls is available on my GitHub but they are not public, as mentioned in the task, we may have an online demo if you like my approach to taking this task, sorry I didn’t get much time to do other task mentioned due to also having some current project work in parallel.

6. I configured the autoscaling on pods, auto-healing of pods as well in case of any pod stopped working and also it's highly available since I put HTTP liveliness in every 5 sec so if any pod will not respond it will automatically create another one within the GKE Cluster apart from this is also highly faulted tolerance.

No alt text provided for this image

7. Here is my GitHub link for above code to deploy in your cloud environment -

 Feel free to reach if any challenge you have  to deploy this ???????

Thank you, ?? Ravi Bhargava

Links: -

https://www.dhirubhai.net/in/ravindrabhargava/

https://github.com/ravindrabhargava

Priyesh Mishra

Solution Architect

4 年

Very useful

Piyush Chavda

Certified with NISM Series V-A Mutual Fund Distributors, AWS SAA-C01, OCI 4x, Azure Fundamentals, Aviatrix ACE, Nutanix NCP 5 - MCI, Six Sigma, Scrum Fundamentals, Cloud Computing and Cyber Security Learnings Enthusiast

4 年

This will help. Thanks for your good info share ??

要查看或添加评论,请登录

Ravindra B.的更多文章

社区洞察

其他会员也浏览了