Kubernetes, aka, K8s is an open-source system for automating deployment, scaling, and managing containerized applications. It handles the work of scheduling containers onto a compute cluster and manages the workloads to ensure they run as the user intends.
What will you learn:-
- What is Kubernetes
- How to use Kubernetes on GCP
1. What is Kubernetes
- Kubernetes, aka, K8s is an open-source system for automating deployment, scaling, and managing containerized applications. It handles the work of scheduling containers onto a compute cluster and manages the workloads to ensure they run as the user intends.
2. Kubernetes Architecture
It has two major components:-
i. Master Node – The master node receives input from the CLI or UI as it is the entry point for all the administrative tasks. It has the following four components:-
- API Server – The API server is the entry point for all the REST commands used to control the cluster.
- Controller Manager – Is a daemon that regulates the Kubernetes cluster, and manages different non-terminating control loops.
- etcd – etcd is a simple, distributed, consistent key-value store. It’s mainly used for shared configuration and service discovery.
- Scheduler – The scheduler schedules the tasks to slave nodes. It stores the resource usage information for each slave node.
ii. Worker Node – Worker nodes contain all the necessary services to manage the networking between the containers, communicate with the master node, and assign resources to the scheduled containers.It’s three major components are:-
- Kubelet – It watches for tasks sent from the API Server, executes the task, and reports back to the Master. It also monitors pods and reports back to the control panel if a pod is not fully functional.Kube-proxy – The Kube-proxy makes sure that each node gets its IP address, implements local iptables and rules to handle routing and traffic load-balancing.Container Runtime – The container runtime is the software that is responsible for running containers. Containers are run inside the pods
Kubernetes supports several container runtimes: Docker, containerd, CRI-O, and any implementation of the Kubernetes CRI (Container Runtime Interface).
3. Using Kubernetes on GCP
GCP provides a managed and secured Kubernetes service called GKE (Google Kubernetes Engine) to create and maintain k8s clusters. GKE is GCP’s enterprise-grade platform to deploy containerized applications and services on kubernetes clusters.
4. Key Features of GKE:
- Enterprise-ready Kubernetes applications are directly available for deployment from Google Marketplace.
- Cluster auto-scaling as well as Horizontal and Vertical Pod auto-scaling based on changing workload requirements.
- Workload and network security provided by GKE sandbox as a second layer of defense between containerized workloads in addition to supporting the native Kubernetes Network Policy
Check out all the features provided by GKE here.
5. Cluster Creation on GKE:
Follow the steps below to create a cluster using GKE console:
- Go to https://console.cloud.google.com/kubernetes/ to access the GKE console.
- Click the Create Cluster button.
In the Cluster basics section, complete the following:
- Enter the Name for your cluster. ( e.g. my-first-cluster )
- For the Location type, select Zonal, and then select the desired zone for your cluster. ( e.g. us-central1-c)
- Choose a Master Version. Let’s go with the default selection for “Static version” for now. (which is 1.14.10-gke.24 as of writing this article)
From the navigation pane, under Node Pools, click default-pool.
- Enter a Name for the default Node pool. (e.g. my-default-pool)
- Choose the Node version for your nodes. (Let’s leave it to the default value which is 1.14.10-gke.24 as of this writing)
- Enter the Number of nodes to create in the cluster. (Let’s have 4 nodes)
- Leave other options as default.
From the navigation pane, under Node Pools, click default-pool.
- Enter a Name for the default Node pool. (e.g. my-default-pool)
- Choose the Node version for your nodes. (Let’s leave it to the default value which is 1.14.10-gke.24 as of this writing)
- Enter the Number of nodes to create in the cluster. (Let’s have 4 nodes)
- Leave other options as default.
- From the navigation pane, under Node Pools, click Nodes.
- From the Image type drop-down list, select the desired node image. Let’s leave it to default which is Container-Optimized OS or “cos” as of this writing. You can read more about Node images on GKE here.
- Choose the default Machine configuration to use for the instances. Read here for comparison of different machine types and the recommended types for different use cases.
- The default machine type is n1-standard-1. Each machine type is billed differently. For machine type pricing information, refer to the machine type price sheet.
- From the Boot disk type drop-down list, select the desired disk type.
- Enter the Boot disk size.
- Leave other fields as default and Click Create.
- After a few minutes, you will have your first k8s cluster running with your chosen configuration.