Minikube and Kubernetes Tutorial: Getting Started

This guide assumes you have a basic understanding of Docker, Kubernetes clusters, pods, and nodes. We’ll be deploying a simple Flask app using Minikube to get you started with Kubernetes development.

Prerequisites:

  • Basic understanding of Docker
  • Familiarity with Kubernetes concepts (clusters, pods, nodes)

Let’s Get Rolling!

1. Install Minikube:

Head over to the Minikube website and download the appropriate binary for your operating system: https://minikube.sigs.k8s.io/docs/start/?arch=%2Flinux%2Fx86-64%2Fstable%2Fbinary+download

2. Clone the Sample App:

We’ll use a simple Flask app to demonstrate deployment. Clone the repository using Git:

git clone https://github.com/CodesInTheShell/flask_vue_monolith

3. Start Minikube Cluster:

Start your Minikube cluster using the following command:

minikube start

4. Configure Docker for Minikube:

To run Docker commands within Minikube instead of your host machine, execute this command:

eval $(minikube docker-env)

5. List Docker Images:

Take a peek at the available Docker images to verify you’re working within the Minikube environment:

docker image ls

6. Build the Flask App Image:

Build the Docker image for your Flask app using the following command:

docker build -t python-flask:latest .

7. Deploy the Container:

Deploy the containerized Flask app to your Minikube cluster using a deployment manifest file (deployment.yaml). You’ll need to create this file with the appropriate configuration.

minikube kubectl apply -f deployment.yaml

8. Expose the Application:

Create a service manifest file (service.yaml) to expose the deployed container as a service. This allows external access to your application.

kubectl apply -f service.yaml

9. Verify Deployment:

Check the status of your pods and service using the following commands:

kubectl get pods
kubectl get svc

10. Access the Application:

Use the minikube service command to get the URL for accessing your deployed Flask app:

This command will provide you with the URL to open your application in a web browser.

minikube service python-flask-service --url

11. Clean Up:

When you’re finished, you can clean up the resources by deleting all deployed objects in the cluster:

Bash

kubectl delete all --all

Summary:

  • We set up a Minikube cluster.
  • Built a Docker image for the Flask app.
  • Deployed the container using a deployment manifest.
  • Created a service manifest to expose the application.
  • Accessed the application through the provided URL.
  • Cleaned up resources by deleting deployed objects.

Additional Notes:

  • Remember to replace python-flask-service with the actual service name defined in your service.yaml file.
  • This is a basic example. Kubernetes offers more advanced features and configurations for managing complex applications.

By following these steps, you’ve successfully deployed a simple application using Minikube and learned some fundamental Kubernetes concepts. Now, you can explore further and build more robust and scalable applications using Kubernetes.

See youtube video here: https://youtu.be/XtVjjSR5m1Q