Google App Engine (GAE):
A managed service provided by GCP. Easiest way to deploy your application.
GAE helps in auto scaling, load balancing as well as health check monitoring.
In simplest terms, GAE provided end to end application management.
A very important feature provided by GAE is traffic management (splitting) between different application versions.
Please don't be confused between GAE and Compute Engine. GAE comes under PaaS and Compute Engine under IaaS. Have a look at the diagram below (taken from google cloud via Internet) which depicts the responsibility of the owner from IaaS, PaaS and SaaS.
With Compute Engine, being IaaS, one has more flexibility but comes with more responsibility.
In GAE, being PaaS, there is less responsibility but less flexibility. It's Server-less.
Google Kubernetes Engine (GKE)
GKE is a very popular open source container orchestration tool. Its a managed service offered by GCP.
- Provides cluster management for the VMs that one wants to deploy.
- All these VMs can be of different types.
- GKE provides all of the below
- Auto scaling
- Health check and self heal (replace)
- Auto repair and auto upgrade
- Load balance
- Support for SSD disks (local)
- Support for persistent disks
- Zero downtime deployments
- Cloud Logging
- Cloud Monitoring
- Uses container optimized OS (from Google)
- Create a new project (optional) or use an existing project
- Connect to the project using Cloud shell [gcloud config set project <Project ID>]
- In the console, go to "Kubernetes Engine" and enable the APIs.
- In the console, go to "Kubernetes Engine" and create "Kubernetes cluster"
- Cluster options
- Standard - User takes ownership of the cluster
- Auto Pilot - As the name suggests, GKE will take ownership of the cluster.
- Alternatively use cloud shell to create cluster [gcloud container clusters create]
- Connect to the cluster using Cloud shell [gcloud container clusters get-credentials <clustername> --zone <selected zone> --project <project ID>
- Get the above command from the cluster console
- Deploy microservice
- kubectl create deployment <deployment name> --image <image name>
- kubectl get deployment (to see deployment details)
- To access this deployment, expose it externally
- kubectl expose deployment <deployment name> --type=LoadBalancer --port=<port#>
- Kubernetes service gets created from the above command
- To view the service
- kubectl get services
- You can see the cluster IP, External IP, Type and Name
- Once you have the external ID, you can connect to it
- curl IP_address:port#
- Use the above IP to access via browser with the micro service name
- Scaling the deployment
- While connected to the cloud shell and the cluster
- kubectl scale deployment <deployment name> --replicas=n
- As mentioned in 6.2, use kubectl get deployment to get details and see if it's scaled.
- These instances are called as "pod"
- kubectl get pods to see details
- If we need to scale to a higher value, we need to first scale up the # of nodes in the cluster
- gcloud container clusters resize <cluster name> --node-pool <node pool name> --num-nodes=x --zone=<zone name>
- Get the node pool name from the console (go to cluster and node)
- Get the zone name from the console (go to cluster)
- The same applies when we want to reduce the # of nodes
- But why not auto-scale?
- kubectl autoscale deployment <deployment name> --max=mx_n --cpu-percent=X
- To see this, we need to find if the pods were autoscaled horizontally
- kubectl get hpa
- But shouldn't we auto scale cluster as well?
- gcloud container clusters update <cluster name> --enable-autoscaling --min-nodes=min_x --max-nodes=max_x
- All good? Lets also learn how to delele?
- Delete microservice? kubectl delete service <microservice-name>
- Delete deployment? kubectl delete deployment <deployment name>
- Delete cluster? gcloud containers clusters delete <cluster name> --zone <zone name>
- We get options to choose from:
- Charge for CPU usage only when a request is processed (invocation)
- Charge for entire lifecycle of the container instance
- Auto scaling configuration option is provided.
- Authentication option is also provided
No comments:
Post a Comment