Learn About Kubernetes (K8s) Objects
I recently completed the AWS EKS K8S training from AWS. The company I work for is going to be shifting as many workloads as possible to Kubernetes, so it’s something I need to learn. A lot has changed in K8s since I used it in 2018 on the Google Cloud Platform.
In this article, you will learn the basics about all of the objects that make up a Kubernetes cluster.
What is a Kubernetes Cluster?
The cluster is a logical collection of Kubernetes objects.
It is made up of:
- a collection of nodes
- has a minimum of 1 worker
- has a control plane
The cluster is the heart of Kubernetes and provides the capability to schedule and run containers across a group of machines, instances, or virtual machines. Clusters can be run locally, in the cloud, or span both on-premise and offsite, making them extremely flexible.
The cluster has a desired state configuration, and the state defines what workloads should be running on the cluster. The cluster manages the desired state by allocating resources as needed. If the desired state is 3 nodes, Kubernetes will ensure there are 3 resources running at all times.
What is a Kubernetes Node?
A Kubernetes node is a worker machine. In AWS, it is a cloud instance. The control plane manages the nodes.
Nodes are:
- a group of containers
- either a virtual or physical instance
- managed by the control plane and contains services needed to run the pods
Each node runs (at least) the Kubelet process and a container runtime (typically docker)
What is a Kubernetes Pod?
A pod is a group of containers that share storage, network resources and a podspec file. Each pod runs one or more application containers that are coupled together.
To compare with Docker, a Pod is similar to a group of Docker containers with shared namespaces and shared filesystem volumes.
Pods are:
- A group of one or more containers.
- pods defined by PodSpec file.
- Pods are building blocks of K8s for deployment, scaling, and replication.
- Pods can run a single container.
- Pods can run multiple continers that need to work together. (For example, when scaling horizontally)
- Pods have init containers that run and complete before the app containers are started.
- Pods are ephemeral.
What is an Ephemeral Volume?
Some applications need disk space for caching or read-only data for config files or secret keys. Ephemeral Volumes are used for these purposes and follow the Pods lifecycle because each ephemeral volume is created and destroyed with the pod.
There are four types of Ephemeral Volumes:
- emptyDir: empty at Pod startup, with storage coming locally from the kubelet base directory (usually the root disk) or RAM
- configMap, downwardAPI, secret: inject different kinds of Kubernetes data into a Pod
- CSI ephemeral volumes: similar to the previous volume kinds, but provided by special CSI drivers which specifically support this feature
- generic ephemeral volumes, which can be provided by all storage drivers that also support persistent volumes
To summarize, Ephemeral Volumes are:
- shared storage volume for the pod
- Persistence of data when container restarts
- When pod ceases, K8s destroy ephemeral vols
Persistent Vol
- Same as Ephemeral but with lifecycle rules
What is a Kubernetes Service?
The service exposes the appication on the pods as a network service, including an IP address and DNS entry. Kubernetes Services are used to keep track of all network allocations (e.g Front-end and Back-End application endpoints)
- Service is a logical collection of pods and access points.
Services is a huge subject within Kubernetes, you will find detailed information here
What is a Kubernetes Namespace?
A namespace is used to isolate groups of resources within a cluster.
- Virtual cluster back by same physical cluster
- Namespaces are especially useful when multiple teams or projects use the same cluster.
What is a ReplicaSet?
The replicaset is tasked with ensuring that the required number of pods are running at a given time.
- Ensures that a specific number of pod replicas are running at any given time
That it for part 1 of objects. We will be back with part 2 shortly
1 Response
[…] into the world of Kubernetes on Google Cloud Platform (GCP)? This introductory guide is tailor-made for beginners, walking you […]