Back to Overview

Kubernetes

devops containers infrastructure advanced

What is Kubernetes?

Kubernetes (often called K8s) is like a smart manager for your computer programs. It helps you run many small programs (called containers) across different computers, making sure they all work properly.


If one program crashes, Kubernetes automatically starts it again. If you need more copies of a program because lots of people are using it, Kubernetes can make more copies for you.

Simple Analogy

Think of Kubernetes like a smart babysitter for your computer programs:

  • The Babysitter (Kubernetes): Makes sure all the kids (programs) are playing nicely, have what they need, and are safe
  • The Kids (Containers): Your programs that need to be watched and taken care of
  • The House Rules (YAML Files): Instructions for how the babysitter should take care of the kids
  • The Neighborhood (Cluster): All the computers where your programs can run

Just like a good babysitter:

  • If a kid falls down (a program crashes), the babysitter helps them up (restarts the program)
  • If one room gets too crowded (a computer gets too busy), the babysitter moves some kids to another room (moves programs to another computer)
  • If you need more kids to play a game (more copies of a program), the babysitter can make more copies

Key Concepts

  • Pods: Like a playgroup of kids that always stay together
  • Nodes: The computers where your programs run (like the rooms in a house)
  • Cluster: All the computers working together (like the whole neighborhood)
  • Deployments: Instructions for how many copies of a program to run
  • Services: Ways for programs to find and talk to each other
  • Namespaces: Different areas where programs can run separately (like different houses)

Example

# A simple example of telling Kubernetes to run 3 copies of a program
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-website
spec:
  replicas: 3  # Run 3 copies
  selector:
    matchLabels:
      app: my-website
  template:
    metadata:
      labels:
        app: my-website
    spec:
      containers:
      - name: my-website
        image: my-website:1.0
        ports:
        - containerPort: 80