Kubernetes Tutorial for Beginners

DevOps

YOUR COSMETIC CARE STARTS HERE

Find the Best Cosmetic Hospitals

Trusted • Curated • Easy

Looking for the right place for a cosmetic procedure? Explore top cosmetic hospitals in one place and choose with confidence.

“Small steps lead to big changes — today is a perfect day to begin.”

Explore Cosmetic Hospitals Compare hospitals, services & options quickly.

✓ Shortlist providers • ✓ Review options • ✓ Take the next step with confidence

Here’s a cleaned-up, beginner-friendly Kubernetes tutorial based on your session notes.

Kubernetes Tutorial for Beginners

1. What is Kubernetes?

Kubernetes, often called K8s, is an open-source platform used to deploy, manage, and scale containerized applications.

It helps you run applications in containers across one or more machines in an automated and reliable way.

In simple terms:

  • Docker creates and runs containers
  • Kubernetes manages those containers at scale

2. Why Kubernetes?

Kubernetes is useful because it helps with:

  • Automation of application deployment
  • Scaling applications up or down
  • Self-healing when containers fail
  • Load distribution across systems
  • High availability of applications
  • Easy management of containerized workloads

Instead of manually starting containers on multiple servers, Kubernetes handles it for you.


3. Basic Kubernetes Architecture

A Kubernetes cluster mainly has:

  • Workstation / Laptop
  • Master Node (Control Plane)
  • Worker Node(s)

Workstation / Laptop

This is where an administrator or developer runs commands using:

  • kubectl
  • kubeconfig

The kubeconfig file is usually stored at:

~/.kube/config
Code language: JavaScript (javascript)

It contains:

  • API server address
  • user details
  • certificates

This allows your laptop to communicate securely with the Kubernetes cluster.


4. How Kubernetes Works

The basic request flow is:

Human → kubectl → API Server

When you run a command like:

kubectl get nodes
Code language: JavaScript (javascript)

kubectl sends the request to the API Server, which talks to other Kubernetes components and returns the result.


5. Master Node Components

The Master Node manages the cluster.

Main components include:

API Server

  • Entry point for all Kubernetes commands
  • Accepts requests from kubectl

etcd

  • Key-value database
  • Stores cluster state and configuration

Controller Manager

  • Watches cluster state
  • Makes sure the desired state matches the actual state

Scheduler

  • Decides on which worker node a pod should run

Kube Proxy

  • Manages network communication

Kubelet

  • Runs on nodes
  • Ensures containers are running as expected

Container Engine

Examples:

  • Docker
  • containerd

6. Worker Node Components

Worker nodes run the actual application workloads.

They usually contain:

  • Kubelet
  • Container Engine (docker or containerd)
  • Kube Proxy

The worker node receives instructions from the control plane and runs the assigned pods.


7. Cluster Setup Concepts

Master Node Initialization

Usually done with:

kubeadm init

Worker Node Join

Usually done with:

kubeadm join <master-ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>
Code language: HTML, XML (xml)

Do not share live join tokens publicly. They should be treated as sensitive cluster credentials.


8. Local and Cloud Kubernetes Options

Local Setup

For practice and learning:

  • Minikube

Typical lab setup example:

  • 1 VM = Workstation + Master
  • 1 VM = Worker

Cloud Kubernetes Services

Managed Kubernetes services include:

  • EKS – Amazon Elastic Kubernetes Service
  • AKS – Azure Kubernetes Service
  • GKE – Google Kubernetes Engine

9. Common Kubernetes Commands

Cluster Information

kubectl cluster-info
kubectl get nodes
kubectl get pods
kubectl get pods --all-namespaces
kubectl version
Code language: JavaScript (javascript)

Check Installed Tools

which kubectl
which kubelet
which kubeadm
which containerd
which dockerd

Check Running Processes

ps -eaf | grep kubectl
ps -eaf | grep kubelet
ps -eaf | grep containerd

10. Kubernetes API Operations

Kubernetes resources support basic CRUD operations:

Create

Using command:

kubectl create ...

Using YAML:

kubectl create -f file.yaml
Code language: CSS (css)

Read

Using command:

kubectl get ...
Code language: JavaScript (javascript)

Using YAML:

kubectl get -f file.yaml
Code language: JavaScript (javascript)

Update

Using command:

kubectl edit ...

Using YAML:

kubectl apply -f file.yaml
Code language: CSS (css)

Delete

Using command:

kubectl delete ...
Code language: JavaScript (javascript)

Using YAML:

kubectl delete -f file.yaml
Code language: JavaScript (javascript)

11. Namespace in Kubernetes

A Namespace is used to logically separate resources in a cluster.

Examples:

kubectl get ns
kubectl create ns dev
kubectl create ns qa
kubectl describe ns qa
kubectl delete ns dev
Code language: JavaScript (javascript)

Namespace YAML Example

apiVersion: v1
kind: Namespace
metadata:
  name: devops1
  labels:
    kubernetes.io/metadata.name: devops1

Create it with:

kubectl create -f ns.yaml
Code language: CSS (css)

Update it with:

kubectl apply -f ns.yaml
Code language: CSS (css)

Delete it with:

kubectl delete -f ns.yaml
Code language: JavaScript (javascript)

12. Pod in Kubernetes

A Pod is the smallest deployable unit in Kubernetes.

A pod can contain one or more containers.

Pod YAML Example

apiVersion: v1
kind: Pod
metadata:
  name: rajesh
  labels:
    app: helloworld
spec:
  containers:
  - name: devopsschool1
    image: scmgalaxy/nginx-devopsschoolv1
    ports:
    - name: nginx-port
      containerPort: 80

Pod Commands

Create pod:

kubectl create -f pod.yaml
Code language: CSS (css)

View pods:

kubectl get pods
kubectl get pods -o wide
Code language: JavaScript (javascript)

Describe pod:

kubectl describe pod rajesh

Delete pod:

kubectl delete pod rajesh
Code language: JavaScript (javascript)

Access pod shell:

kubectl exec -it rajesh -- /bin/bash
Code language: JavaScript (javascript)

13. Useful Pod Testing Commands

Check pod IP

kubectl get pods -o wide
Code language: JavaScript (javascript)

Test application

curl http://<pod-ip>
ping <pod-ip>
Code language: HTML, XML (xml)

View logs

kubectl logs rajesh

Attach to running container

kubectl attach rajesh

14. Port Forwarding

Port forwarding allows you to access a pod locally.

Example:

kubectl port-forward --address 0.0.0.0 pod/rajesh 8888:80

This maps:

  • local port 8888
  • to pod container port 80

You can then access the app in a browser using your machine’s IP and port 8888.


15. Copy Files to a Pod

Example:

kubectl cp ns.yaml rajesh:/tmp
kubectl exec rajesh -- ls /tmp

This copies ns.yaml into the /tmp directory of the pod.


16. Authorization Checks

Kubernetes lets you verify permissions using:

kubectl auth can-i create pod
kubectl auth can-i delete pod
Code language: JavaScript (javascript)

These commands help confirm whether a user has permission to perform actions.


17. Events and Troubleshooting

Useful debugging commands:

kubectl describe <resource>
kubectl logs <pod-name>
kubectl exec -it <pod-name> -- /bin/bash
kubectl attach <pod-name>
kubectl port-forward <pod-name> <local-port>:<container-port>
kubectl cp <src> <pod-name>:<path>
kubectl auth can-i <action> <resource>
kubectl events
Code language: HTML, XML (xml)

Common troubleshooting tools

  • describe → detailed resource information
  • logs → application/container logs
  • exec → shell access inside container
  • events → cluster-level activity and errors

18. Important Kubernetes Resources to Learn Next

From your notes, these are the next topics after pods:

  • ReplicationController
  • Deployment
  • Service
  • RBAC

These are important because:

  • Deployment manages pods and updates
  • Service exposes applications
  • RBAC controls user permissions

19. Beginner Summary

Kubernetes is a platform that manages containers across servers.

Key points:

  • kubectl is the command-line tool
  • The API Server is the entry point
  • The Master Node controls the cluster
  • Worker Nodes run applications
  • Namespaces organize resources
  • Pods run containers
  • YAML files define resources
  • Commands like get, create, apply, and delete manage objects

20. Practice Flow for Beginners

A simple learning flow:

  1. Check cluster nodeskubectl get nodes
  2. Check namespaceskubectl get ns
  3. Create a namespacekubectl create ns dev
  4. Create a pod from YAMLkubectl create -f pod.yaml
  5. Verify podkubectl get pods -o wide
  6. Inspect podkubectl describe pod rajesh
  7. Access podkubectl exec -it rajesh -- /bin/bash
  8. View logskubectl logs rajesh
  9. Delete podkubectl delete pod rajesh

Final Note

Your notes are a solid base for a beginner Kubernetes session. I converted them into a structured tutorial so it is easier to teach, revise, or share.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.