Kubernetes for Beginners
In this Kubernetes tutorial for beginners, you’ll learn all kubernetes structure and key concepts such as containers, nodes, deployment, and more.
In this Kubernetes tutorial for beginners, you will learn the essentials of Kubernetes.
In this digital age, organizations are continuously seeking ways to efficiently manage all of their applications. This need for streamlined operations has paved the way for containerization, an approach that organizes different applications keeping them easier to manage. However, with the growing complexity of modern applications and the increasing number of containers to manage, an orchestration system becomes essential. Kubernetes is an open-source container orchestration platform that can help with precisely that. Throughout this article, we discuss what Kubernetes is, Kubernetes components, and the architecture of Kubernetes.
What is Kubernetes? Key definitions and concepts
What is Kubernetes? Kubernetes (k8s) is an open-source system for managing container-based platforms. With Kubernetes, you can deploy cloud-native applications anywhere and manage them all exactly the same.
What is Kubernetes used for and why do you need it? Kubernetes is used to easily manage, deploy, and scale containerized workloads. Kubernetes groups containers into logical units for ease of discovery and management. Overall, it makes managing containers on multiple hosts easier. Here is a visualization of the essential Kubernetes concepts I outline below from Luke’s slide:
A container is the smallest unit in the Kubernetes world. The main purpose of Kubernetes is to manage, deploy, and, to a certain extent, monitor containers. Kubernetes management is not limited to Docker containers.
A node is the host that the container runs on. This means that a Kubernetes “cluster” is a group of nodes that run the containerized application. There are two types of nodes: worker nodes and master nodes.
A pod is a management unit in Kubernetes consisting of one or more containers. Each pod has its own unique IP address and storage namespaces. All containers share these networking and storage resources. One of the characteristics mentioned in this presentation is that pods are “mortal.” This means when a pod is deleted, it is gone for good. A YAML (Yet Another Markup Language) file is used to define a Pod. Here is a sample copy of a YAML file representing a Pod:
- name: nginx
A Deployment is a new way to handle High Availability (HA) in Kubernetes in place of the Replication Controller. A pod by itself is “mortal” but with a Deployment, Kubernetes can make sure that the number of Pods that a user specifies is always up and running in the system. A Deployment specifies how many instances of a pod will run. A YAML file is used to define a Deployment. Here is an example of a YAML file representing a Deployment:
- name: nginx
According to the official Kubernetes website, “A Kubernetes Service is an abstraction which defines a logical set of Pods and a policy by which to access them – sometimes called a micro-service.”
Luke discussed the concept of Cluster IP and NodePorts. Cluster IP is internal to Kubernetes, and the NodePorts are the published IP addresses for external users to access the services. Routes to services are based on labels. As with Pods and Deployments, a service is also defined by a YAML file.
This diagram from the presentation puts the Service YAML file and the Deployment YAML file side by side. Note the arrow that makes it easy to see that a Service is connected to a Deployment via the label attribute. In this case, the label is nginx.
A side note on “Declarative” in Kubernetes
One important Kubernetes concept to keep in mind: “Declarative” is an operation based on YAML files. Kubernetes depends on a YAML file to check if the desired Pod, Deployment, or Service is running as defined. We can perform kubectl apply a hundred times with no undesirable or unexpected outcome. Kubernetes just checks if the system is running according to the desired state as defined in the YAML file.
For example, for scripts that are not declarative, there is a command to append a certain text to a file. It will just append without checking if the text is already in that file. If you apply the script to append a certain text ten times, the exact text will appear in that file ten times.
Because of the time limit of the talk, Luke focused on the Master node and the worker node in Kubernetes architecture. The Master node is the control plane while the worker node is where the containers are being deployed.
You can find a more detailed description of Kubernetes architecture on GitHub.
We need to initialize the Master node with kubeadm init. This creates a few digital certificates and an output with the join command kubeadm join –token=. We can use that command on the worker node to join to the master.
For a more detailed description of the kubeadm command and how to initialize and create various nodes, check out the Kubernetes Getting Started Guides for kubeadm.
For more comprehensive Kubernetes resources, check out:
- Kubernetes Containers Explained
Kubernetes for Beginners: Parting Thoughts
If you’re just getting started with your Kubernetes journey, we can help. Weaveworks has a vast array of learning resources to help you understand the cloud-native ecosystems, Kubernetes, and GitOps - a standardized workflow for how to deploy, configure, monitor, and manage Kubernetes application.
Explore the key benefits of GitOps and the operating models for building cloud-native applications, by downloading this whitepaper “Automating Kubernetes with GitOps”.