Skip to content

☸️ Kubernetes: Introduction Tutorial

Welcome to the Kubernetes introduction tutorial! Kubernetes is a powerful open-source platform designed to automate the deployment, scaling, and management of containerized applications. In this guide, we'll cover the fundamentals of Kubernetes, including its key features, installation, and basic commands to help you get started.

πŸ“‘ Table of Contents

  1. What is Kubernetes?
  2. Key Features
  3. Installation
  4. Basic Commands
  5. Getting Started with Kubernetes
  6. Further Reading

πŸ€” What is Kubernetes?

Kubernetes (often abbreviated as K8s) is an open-source container orchestration platform that simplifies the management of containerized applications across clusters of machines. It automates many tasks involved in deploying and managing applications, including scaling, load balancing, and failover.

🌟 Key Features

  • Automated Scaling: Adjusts the number of running containers based on demand.
  • Self-Healing: Replaces failed containers and restarts them as necessary.
  • Service Discovery and Load Balancing: Automatically exposes services and manages load balancing.
  • Storage Orchestration: Manages storage resources for containers, allowing them to use storage solutions easily.

πŸ› οΈ Installation

For Linux (Using Minikube)

  1. Install Minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
  1. Start Minikube:
minikube start
  1. Verify Kubernetes Cluster:
    kubectl cluster-info
    

For Windows/Mac

πŸ’» Basic Commands

  • Check Cluster Information:
kubectl cluster-info
  • List Nodes in the Cluster:
kubectl get nodes
  • Create a Deployment:
kubectl create deployment my-deployment --image=nginx
  • Expose a Deployment:
kubectl expose deployment my-deployment --port=80 --target-port=80 --type=NodePort
  • View Pods:
kubectl get pods
  • View Services:
    kubectl get services
    

πŸš€ Getting Started with Kubernetes

  1. Create a Deployment YAML File: A Deployment YAML file defines a set of Pods and the desired state of the application. Here’s an example:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app-container
          image: nginx
          ports:
            - containerPort: 80
  1. Apply the Deployment:
kubectl apply -f deployment.yaml
  1. Scale the Deployment:
kubectl scale deployment my-app --replicas=5
  1. Delete the Deployment:
    kubectl delete deployment my-app
    

πŸ“š Further Reading