This guide provides a step-by-step overview of setting up Kubernetes. Whether you are a beginner or an experienced user, this guide will help you get started with Kubernetes.

Prerequisites

  • A Linux machine or a virtual machine running Linux.
  • Docker installed on your machine.
  • Basic knowledge of Linux commands.

Install Kubernetes

  1. Install Minikube: Minikube is a tool that makes it easy to run Kubernetes locally. You can install Minikube by following the instructions here.

  2. Start Minikube: Once Minikube is installed, you can start it with the following command:

    minikube start
    
  3. Verify Installation: To verify that Kubernetes is running, use the following command:

    kubectl version
    

Deploy an Application

  1. Create a Deployment: Create a new deployment file named myapp-deployment.yaml with the following content:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: myapp
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: myapp
      template:
        metadata:
          labels:
            app: myapp
        spec:
          containers:
          - name: myapp
            image: nginx:latest
    
  2. Apply the Deployment: Apply the deployment to your cluster with the following command:

    kubectl apply -f myapp-deployment.yaml
    
  3. Verify Deployment: To verify that the deployment was created successfully, use the following command:

    kubectl get deployments
    

Access the Application

  1. Get the Service IP: Get the IP address of the service associated with the deployment with the following command:

    kubectl get svc
    
  2. Access the Application: Open your web browser and enter the service IP address. You should see the Nginx default page.

Conclusion

Congratulations! You have successfully set up Kubernetes and deployed an application. For more information on Kubernetes, visit the official Kubernetes documentation.

Kubernetes Architecture

Kubernetes Architecture