• HINDI
  •    
  • Saturday, 17-Jan-26 04:39:36 IST
Tech Trending :
* πŸ€–How OpenAI + MCP Servers Can Power the Next Generation of AI Agents for Automation * πŸ“š Book Recommendation System Using OpenAI Embeddings And Nomic Atlas Visualization

Getting Started with Kubernetes: Setup Guide & Must-Know Commands

Contents

Table of Contents

    Contents
    Getting Started with Kubernetes: Setup Guide & Must-Know Commands

    Getting Started with Kubernetes: Setup Guide & Must-Know Commands

    In a world where applications are becoming more modular, distributed, and dynamic, Kubernetes (K8s) has emerged as the de facto standard for container orchestration. Whether you're building microservices or deploying scalable cloud-native apps, Kubernetes offers the automation and control needed to operate at scale.


    This guide will walk you through:


    What Kubernetes is


    How to set up Kubernetes (locally and in production)


    Key Kubernetes architecture concepts


    Most important kubectl commands for everyday use


    Let’s dive in.


    πŸ“˜ What is Kubernetes?


    Kubernetes is an open-source platform for automating deployment, scaling, and management of containerized applications. Originally developed by Google, it's now maintained by the Cloud Native Computing Foundation (CNCF).


    Think of it as the operating system for your containers β€” managing them intelligently across clusters of machines.


    🧠 Why Use Kubernetes?

    Feature Benefit

    πŸš€ Auto-scaling Adjust container replicas based on load

    πŸ” Self-healing Automatically replaces failed containers

    πŸ”„ Rolling updates Zero-downtime updates to applications

    βš–οΈ Load balancing Distributes traffic across pods

    πŸ” Secrets & Config Management Manages environment-sensitive data securely

    🌍 Cloud & On-prem ready Portable across any environment

    🧱 Kubernetes Architecture (Simplified)

    [ User / kubectl ]

             β†“

        [ API Server ]

             β†“

    [ Scheduler ] ← [ Controller Manager ]

             β†“

         [ ETCD ] ← Cluster State

             β†“

     [ Worker Nodes ]

        - Kubelet

        - Kube Proxy

        - Container Runtime (Docker / containerd)



    Master Node: Controls the cluster


    Worker Node: Runs your containers inside Pods


    Pod: Smallest deployable unit (contains 1 or more containers)


    πŸ› οΈ Kubernetes Setup Guide

    βœ… Option 1: Local Setup using Minikube


    Great for developers, demos, and POCs.


    πŸ”Ή Step 1: Prerequisites


    Docker or VirtualBox


    Minikube


    Kubectl


    πŸ”Ή Step 2: Start Minikube

    minikube start


    πŸ”Ή Step 3: Verify Installation

    kubectl version --client

    kubectl get nodes



    βœ… You now have a working single-node Kubernetes cluster on your machine!


    βœ… Option 2: Production-like Setup with kubeadm


    For staging, production, or multi-node clusters.


    πŸ”Ή Step 1: Provision Linux VMs


    Minimum two VMs:


    1 Master Node


    1+ Worker Nodes


    πŸ”Ή Step 2: Install Docker

    sudo apt update

    sudo apt install docker.io -y


    πŸ”Ή Step 3: Install Kubernetes Tools

    sudo apt install -y apt-transport-https curl

    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

    echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" |

    sudo tee /etc/apt/sources.list.d/kubernetes.list


    sudo apt update

    sudo apt install -y kubelet kubeadm kubectl

    sudo apt-mark hold kubelet kubeadm kubectl


    πŸ”Ή Step 4: Initialize Cluster

    sudo kubeadm init --pod-network-cidr=192.168.0.0/16



    Save the kubeadm join command to use on worker nodes.


    πŸ”Ή Step 5: Configure kubectl

    mkdir -p $HOME/.kube

    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

    sudo chown $(id -u):$(id -g) $HOME/.kube/config


    πŸ”Ή Step 6: Install Pod Network (Calico, Flannel, etc.)

    kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml


    πŸ”Ή Step 7: Join Worker Nodes


    On each worker, run the saved kubeadm join command.


    πŸ“¦ Essential Kubernetes Commands

    🎯 Cluster & Node Info

    kubectl get nodes

    kubectl describe node <node-name>


    πŸš€ Deployments & Pods

    kubectl create deployment myapp --image=nginx

    kubectl get deployments

    kubectl get pods

    kubectl describe pod <pod-name>

    kubectl delete pod <pod-name>


    πŸ”„ Scaling & Updating

    kubectl scale deployment myapp --replicas=3

    kubectl rollout restart deployment myapp

    kubectl set image deployment/myapp nginx=nginx:1.25


    🌐 Services & Networking

    kubectl expose deployment myapp --type=NodePort --port=80

    kubectl get services


    πŸ“ YAML-based Operations

    kubectl apply -f deployment.yaml

    kubectl delete -f deployment.yaml

    kubectl edit deployment myapp


    πŸ› οΈ Troubleshooting & Logs

    kubectl logs <pod-name>

    kubectl describe pod <pod-name>

    kubectl get events


    🧠 Pro Tips for Kubernetes Users

    Tip Why it matters

    βœ… Use Namespaces For environment isolation (dev, staging, prod)

    βœ… Use Liveness/Readiness Probes For intelligent container management

    βœ… Automate with Helm Easier deployment with charts

    βœ… Monitor with Prometheus/Grafana Visual observability

    βœ… Secure with RBAC Control who can access what

    🌐 Popular Kubernetes Use Cases


    βœ… Microservices management


    βœ… Auto-scaling APIs


    βœ… Machine learning model deployments


    βœ… Real-time data processing (Kafka, Spark)


    βœ… CI/CD pipeline integration


    🧭 What’s Next?


    Kubernetes is a vast ecosystem. Once you're comfortable with the basics, you can dive into:


    Helm (Kubernetes package manager)


    Ingress controllers


    Service Mesh (Istio, Linkerd)


    Kubernetes security (RBAC, Network Policies)


    Kubernetes in production (EKS, GKE, AKS)


    πŸ“Œ Conclusion


    Kubernetes is not just a tool, but a cloud-native operating model. Whether you're deploying a simple app or a massive, microservice-based architecture β€” Kubernetes gives you resilience, flexibility, and control.


    With the setup options and command list provided here, you now have the foundation to start building your Kubernetes journey.