MSDN Community Learn

Your Hub for Modern Development Technologies

Kubernetes Basics: Orchestrating Your Containers

Welcome to the foundational module of our Kubernetes learning path! This section provides a clear, concise introduction to the core concepts of Kubernetes, designed to help you understand how to manage and scale your containerized applications effectively.

Kubernetes Logo

Kubernetes: The Container Orchestrator

What is Kubernetes?

Kubernetes (often abbreviated as K8s) is an open-source system for automating deployment, scaling, and management of containerized applications. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).

In essence, Kubernetes helps you run applications that are composed of many containers across a cluster of machines. It abstracts away the underlying infrastructure, allowing you to focus on deploying and managing your application code.

Why Use Kubernetes?

  • Automated Rollouts & Rollbacks: Deploy new versions of your application or automatically roll back to a previous version if something goes wrong.
  • Service Discovery & Load Balancing: Kubernetes can expose your containers using DNS names or IP addresses, and distribute network traffic to them.
  • Storage Orchestration: Allows you to automatically mount a storage system of your choice, such as local storage, public cloud providers, and more.
  • Self-healing: Restarts containers that fail, replaces and reschedules containers when nodes die, and kills containers that don't respond to user-defined health checks.
  • Secret & Configuration Management: Deploy and update secrets and application configurations without rebuilding your container images.
  • Batch Execution: Manage batch and CI workloads, replacing containers that fail at any step.

Core Concepts of Kubernetes

Let's dive into some of the fundamental building blocks of Kubernetes:

Pods

A Pod is the smallest deployable unit created and managed by Kubernetes. A Pod represents a running process on your cluster and can contain one or more containers. These containers share the same network namespace, IP address, and storage volumes. This allows them to communicate with each other easily.

Key takeaway: Pods are the atomic units of deployment.

Nodes

A Node is a worker machine in a Kubernetes cluster. It can be a virtual machine or a physical machine. Each Node runs at least the kubelet, a container runtime (like Docker or containerd), and the kube-proxy. Nodes are managed by the control plane.

Cluster

A Kubernetes Cluster is a set of Nodes that run containerized applications managed by Kubernetes. The cluster consists of at least one Master Node (the control plane) and multiple Worker Nodes.

Kubernetes Architecture Diagram

Simplified Kubernetes Cluster Architecture

Deployments

A Deployment provides declarative updates for Pods and ReplicaSets. You describe the desired state in a Deployment, and the Deployment Controller changes the actual state to the desired state at a controlled rate. Deployments can manage the rollout of new application versions, rollback to previous versions, and scale applications up or down.


apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
                

Services

A Service defines a logical set of Pods and a policy by which to access them. Services provide a stable IP address and DNS name for a set of Pods. This is crucial because Pods are ephemeral and can be rescheduled, meaning their IP addresses can change.


apiVersion: v1
kind: Service
metadata:
  name: my-nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer
                

Getting Started

To practice these concepts, you'll need a Kubernetes environment. You can set up a local cluster using tools like Minikube, kind, or Docker Desktop's built-in Kubernetes. For cloud-based learning, platforms like Azure Kubernetes Service (AKS) offer managed Kubernetes clusters.

Next Steps: Ready to dive deeper? Explore how to deploy applications with Deployments, expose them with Services, and manage their configuration. Check out our module on Azure Kubernetes Service (AKS) for a hands-on experience!