Hi guys, now I gonna show you how to deploy a auto-pilot cluster in Google Cloud Platform.
- An Account on GCP
- Install Google cloud SDK (gcloud) in your machine (https://cloud.google.com/sdk/docs/install)
- Install Kubectl in your machine (https://kubernetes.io/docs/tasks/tools/)
- Install Docker in your machine (https://docs.docker.com/get-docker/)
In your first time on GKE, you shall enable Kubernetes Engine on GCP. For more info (https://cloud.google.com/kubernetes-engine/docs/quickstart)
You can to create the cluster in the GUI of GCP.
- In Kubernetes Engine click in CREATE CLUSTER
- Choice GKE Autpilot and click in CONFIGURE button
- Choice your VPC and Subnetwork (Pre-configured) or use default this one π€£
- Click in CREATE
In your terminal, execute this command:
$ gcloud container clusters get-credentials CLUSTER_NAME --zone us-central-c)
In flag --zone you shall to put the correct region of your cluster, for example us-central-c.
Generate and upload of docker image in Google Cloud Docker HUB To Generate, execute this command, where the project-id param you can get in URL of GCP "project="
$ docker build -t gcr.io/[project-id]/simple-fastapi-example
To upload
$ docker push gcr.io/[project-id]/simple-fastapi-example
$ kubectl apply -f .k8s/service.yaml
$ kubectl get services
Output
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
app-service LoadBalancer x.x.x.x 192.168.0.1 80:30705/TCP 3s
kubernetes ClusterIP x.x.x.x <none> 443/TCP 2s
$ kubectl apply -f .k8s/deployment.yaml
For testing, you can access by browser the Loadbalancer external IP, for example 192.168.0.1
- GKE provisions and manages the cluster's underlying infrastructure, including nodes and node pools, giving you an optimized cluster with a hands-off experience
- Auto Vertical Scalling
- Basically you need just to execute kubectl commandsπ€π»
The HPA (Horizontal Pod Autoscaler) is the responsible for managing the pod replication, through of a configuration in the hpa.yaml, you can install a metric collector to get the most suitable configuguration for your Autoscaller.
$ kubectl apply -f .k8s/hpa.yaml
π¨π¨ Warning, for your HPA working correctly, you shall to configure some resource limit in your deployment else an overload can occur.
I will to speak more about the configs contained the deployment.yaml, service.yaml and hpa.yaml. Also will speak about set resource limits.