Files
the_information_nexus/tech_docs/minikube_setup_debian.md

6.0 KiB
Raw Blame History

Certainly! Let's deploy a more useful sample application—a simple web application that uses Nginx as a web server and serves a static HTML page. This example will cover the creation of a deployment, a service, and accessing the application.

Step 1: Create a Deployment YAML File

  1. Create a file named nginx-deployment.yaml with the following content:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.21.6
            ports:
            - containerPort: 80
            volumeMounts:
            - name: html
              mountPath: /usr/share/nginx/html
          volumes:
          - name: html
            configMap:
              name: html-configmap
    

Step 2: Create a ConfigMap for the HTML Page

  1. Create a file named html-configmap.yaml with the following content:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: html-configmap
    data:
      index.html: |
        <!DOCTYPE html>
        <html>
        <head>
            <title>Welcome to Nginx</title>
        </head>
        <body>
            <h1>Welcome to your Nginx application!</h1>
            <p>Deployed with Minikube on Kubernetes.</p>
        </body>
        </html>
    

Step 3: Create a Service YAML File

  1. Create a file named nginx-service.yaml with the following content:

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

Step 4: Deploy the Application

  1. Apply the ConfigMap:

    kubectl apply -f html-configmap.yaml
    
  2. Apply the Deployment:

    kubectl apply -f nginx-deployment.yaml
    
  3. Apply the Service:

    kubectl apply -f nginx-service.yaml
    

Step 5: Access the Application

  1. Check the status of the pods to ensure they are running:

    kubectl get pods
    
  2. Get the URL for the Nginx service:

    minikube service nginx-service --url
    
  3. Open the URL in your web browser. You should see the static HTML page served by Nginx.

Step 6: Clean Up

  1. To delete the resources, you can run:

    kubectl delete -f nginx-service.yaml
    kubectl delete -f nginx-deployment.yaml
    kubectl delete -f html-configmap.yaml
    

This setup will provide you with a more useful and practical application deployment scenario, giving you a better understanding of how to work with Kubernetes deployments, services, and ConfigMaps.


Here's a step-by-step guide to set up Minikube on your Debian 12 system for a complete Kubernetes learning lab:

Prerequisites

  1. System Requirements:

    • 2 CPUs or more
    • 2GB of free memory
    • 20GB of free disk space
    • Internet connection
  2. Software Requirements:

    • Docker
    • Kubectl
    • Minikube

Step 1: Install Docker

  1. Update your package list:

    sudo apt-get update
    
  2. Install required packages:

    sudo apt-get install -y ca-certificates curl gnupg lsb-release
    
  3. Add Dockers official GPG key:

    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    
  4. Set up the Docker repository:

    echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
  5. Install Docker Engine:

    sudo apt-get update
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    
  6. Start and enable Docker:

    sudo systemctl start docker
    sudo systemctl enable docker
    
  7. Verify Docker installation:

    sudo docker run hello-world
    

Step 2: Install Kubectl

  1. Download the latest release:

    curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    
  2. Make the kubectl binary executable:

    chmod +x kubectl
    
  3. Move the binary to your PATH:

    sudo mv kubectl /usr/local/bin/
    
  4. Verify the installation:

    kubectl version --client
    

Step 3: Install Minikube

  1. Download the latest Minikube binary:

    curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    
  2. Install Minikube:

    sudo install minikube-linux-amd64 /usr/local/bin/minikube
    
  3. Verify the installation:

    minikube version
    

Step 4: Start Minikube

  1. Start Minikube with Docker driver:

    minikube start --driver=docker
    
  2. Verify Minikube status:

    minikube status
    

Step 5: Basic Minikube Commands

  • Check cluster info:

    kubectl cluster-info
    
  • Deploy a sample application:

    kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
    kubectl expose deployment hello-minikube --type=NodePort --port=8080
    minikube service hello-minikube --url
    
  • Access Minikube Dashboard:

    minikube dashboard
    

Step 6: Stop and Delete Minikube

  • Stop Minikube:

    minikube stop
    
  • Delete Minikube:

    minikube delete
    

Additional Resources

This setup will provide you with a complete learning lab for Kubernetes using Minikube on your Debian 12 system. Let me know if you need further assistance or have any questions!