Table of contents:
- Google Kubernetes Engine (GKE)
- How GKE works
- Basic terminology
- Creating Kubernetes Cluster
- Connecting to a Kubernetes Cluster
Google Kubernetes Engine (GKE), a managed Kubernetes service that you can use to deploy and operate containerized applications at scale using Google's infrastructure.
A GKE environment consists of nodes, which are Compute Engine virtual machines (VMs), that are grouped together to form a cluster. You package your apps (also called workloads) into containers. You deploy sets of containers as Pods to your nodes. You use the Kubernetes API to interact with your workloads, including administering, scaling, and monitoring.
-
Node is a virtual server (server on cloud)
-
Kubernetes manages 1000s of nodes. It has master nodes (or manager) to manage the worker nodes. The combination of master nodes and worker nodes forms a cluster
-
Containers package an application so it can easily be deployed to run in its own isolated environment. Containers are run on Kubernetes clusters. Containers are an isolated environment to run any code.
-
Pod is the smallest deployable unit. Pod is a collection of containers that can run on a host. A Kubernetes node can contain multiple Pods, and a Pod can contain multiple containers
-
ReplicaSet ensures that a specified number of pod replicas are running at any given time.
-
Service allows your application to receive traffic through a permanent address. It provides a constant frontend url for our consumers, irrespective of the changes happening in backend url due to pod changes. Load Balancer is a type of service.
gcloud container clusters get-credentials <cluster-name> --region <region-name> --project <project-id>
-
1. Check version:
kubectl version -
2. Create Deployment:
kubectl create deployment <deployment name> --image=<image name> -
3. Expose Deployment:
kubectl expose deployment <deployment name> --type=<type> --port=<port name> -
4. View Workloads:
-
5. Verify Endpoints:
-
6. get:
kubectl get <type>Where type can be event(s), pod(s), replicaset(s), deployment(s), service(s), all
with options:
kubectl get <type> -o widesort events by creation time:
kubectl get events --sort-by=.metadata.creationTimestamp -
7. explain:
kubectl explain <type>Where type can be event(s), pod(s), replicaset(s), deployment(s), service(s)
-
8. describe:
kubectl describe pod <pod-name> -
9. delete:
kubectl delete pods <pod name>Deletes everything (Deployments, services, pods, replicaset ...etc) about the given app-name
kubectl delete all -l app=<app-name>Even after deleting the pod, the replicaset made sure to have sufficient number of pods running. So it sprung up another pod.
-
10. scale deployment:
kubectl scale deployment <deployment name> --replicas=<number of replicas>
-
1. Installing gcloud CLI
gloud init -
2. Installing kubectl
kubectl version --clientConnect to the cluster and issue the command
kubectl versionto check both client and server versions
-
1. Creating deployment manually
-
1.1 Deploying currency exchange microservice
-
kubectl create deployment currency-exchange --image=ldeepak/udemy-microservices-currency-exchange-service:0.0.11-SNAPSHOT -
kubectl expose deployment currency-exchange --type=LoadBalancer --port=8000 -
kubectl get svc, to get the External IP of the service. -
Execute the request on postman: http://External IP:8000/currency-exchange/from/USD/to/INR
-
-
1.2 Deploying currency conversion microservice
-
kubectl create deployment currency-conversion --image=ldeepak/udemy-microservices-currency-conversion-service:0.0.11-SNAPSHOT -
kubectl expose deployment currency-conversion --type=LoadBalancer --port=8100 -
kubectl get svc, to get the External IP of the service. -
Execute the request on postman: http://External IP:8100/currency-conversion-feign/from/USD/to/INR/quantity/10
-
-
-
2. Creating deployment using declarative YAML configuration file
- Create your deployment file
kubectl apply -f <deployment-file-name.yaml>kubectl get all, to check the deploymentkubectl get svc, to get the External IP of the service- Execute the request on postman: http://External IP:8000/currency-exchange/from/USD/to/INR
-
3. Check difference in deployment file
kubectl diff -f <deployment-file-name.yaml> -
4. Check deployment history
kubectl rollout history deployment <app_name>


















