Introduction-to-Kubernetes-and-Cloud-Native-Technologies

Module 2

Kubernetes Fundamentals: Core Concepts

In Module 1, we learned that Kubernetes is like a city planner for containers, managing them to keep applications running smoothly. Now, we’ll explore the core concepts of Kubernetes—pods, nodes, and clusters—and get hands-on with kubectl, the tool you’ll use to talk to Kubernetes. By the end of this module, you’ll understand how Kubernetes organizes applications and how to interact with a cluster.

Learning Objectives:

What is a Kubernetes Cluster?

A Kubernetes cluster is like a city where your applications live. It’s made up of multiple servers (called nodes) working together to run your containers. Think of the cluster as the entire city, with different parts handling specific tasks.

A cluster has two main components:

Let’s break down the key pieces of this city.

Pods: The Smallest Unit in Kubernetes

A pod is the smallest unit in Kubernetes, like an apartment in our city analogy. It’s where one or more containers live. Containers in the same pod share the same resources (like storage and network) and work closely together, like roommates sharing a kitchen.

For example:

Key Points about Pods:

Analogy: Think of a pod as a lunch tray holding one or more dishes (containers). The tray makes it easy to move everything together, but if the tray breaks, the kitchen (Kubernetes) replaces it with a new one.

Nodes: Where Pods Live

A node is a server (physical or virtual) in the Kubernetes cluster, like a building in our city. Nodes are where pods run. There are two types of nodes:

Control Plane Nodes: These run the components that manage the cluster, like the scheduler (decides where pods go) and the API server (handles communication).

Worker Nodes: These run your application pods. Each worker node has tools like the kubelet (a Kubernetes agent) that talks to the control plane and manages containers.

Fun Fact: A small cluster might have one node acting as both control plane and worker, like a small town where the mayor also runs the local shop. In bigger clusters, these roles are separated.

Kubernetes Architecture: How It All Fits Together

Let’s put it together with a diagram :

Cluster

Explanation:

Worker nodes run pods and include the following key components:

  1. Kubelet:
  1. Kube-proxy:
  1. Container Runtime:
    • Runs containers (e.g., containerd, CRI-O, Docker).
    • Interfaces with kubelet to start/stop containers.
  2. Pods:
    • The smallest deployable units in Kubernetes, hosting one or more containers..

Getting Started with kubectl

kubectl (pronounced “cube control”) is your command-line tool for interacting with Kubernetes, like a walkie-talkie to talk to the city hall. You’ll use it to create, inspect, and manage pods, nodes, and other resources.

Basic Commands:

Hands-On Exercise: Explore a Kubernetes Cluster

Let’s try some kubectl commands using a free online sandbox. No installation is needed yet—we’ll cover setting up your own cluster later.

  1. Go to Play with Kubernetes (https://labs.play-with-k8s.com/) or Katacoda Kubernetes Playground (https://www.katacoda.com/courses/kubernetes/playground).

  2. Start a Kubernetes cluster as guided by the platform (usually takes 1-2 minutes).
  3. Run these commands:
  1. Try creating a simple pod: kubectl run my-web-pod --image=nginx --restart=Never

This creates a pod named my-web-pod running an Nginx web server. Check it with kubectl get pods. View details with kubectl describe pod my-web-pod.

Note for Beginners: If you’re not ready for hands-on, just follow along. The commands above show how Kubernetes organizes resources. We’ll do more hands-on in later modules.

Quiz

  1. What is a pod in Kubernetes?
    • A) A server in the cluster.
    • B) A database for storing cluster data.
    • C) The smallest unit that holds one or more containers.
  2. What does the control plane do?
    • A) Runs application pods.
    • B) Manages the cluster and makes decisions.
    • C) Stores application data.
  3. What command shows all nodes in a cluster?
    • A) kubectl show pods
    • B) kubectl describe cluster
    • C) kubectl get nodes

Answers: 1-C, 2-B, 3-C

Further Reading

What’s Next?

In Module 3, we’ll dive into Containers and Docker Basics, learning how containers are created and why they’re essential for Kubernetes. You’ll try running a container locally or in a sandbox to prepare for deploying apps in Kubernetes.

Proceed to Module 3