Minikube¶
Minikube is a tool that allows developers to run a Kubernetes cluster locally on their workstations.^[400-devops-06-kubernetes-minikube.md]
Installation and Setup¶
Minikube can be installed on Windows using the Chocolatey package manager:^[400-devops-06-kubernetes-minikube.md]
choco install minikube
Starting the Cluster¶
Minikube supports various drivers to run the cluster container, with Docker being a common choice.^[400-devops-06-kubernetes-minikube.md] To start a cluster using the Docker driver, use the following command:^[400-devops-06-kubernetes-minikube.md]
minikube start
Configuration¶
The Docker driver can be set as the default, ensuring consistency across restarts.^[400-devops-06-kubernetes-minikube.md]
minikube config set driver docker
Users can also allocate specific resources to the cluster, such as memory and CPUs, either via configuration commands or directly at startup:^[400-devops-06-kubernetes-minikube.md]
minikube config set memory 8192
minikube config set cpus 4
minikube start --cpus=6 --memory=12288
It is possible to run multi-node clusters for more complex testing scenarios:^[400-devops-06-kubernetes-minikube.md]
minikube start --nodes 2 -p multinode-demo
Environment Configuration¶
On Windows, specific environment variables may need to be configured to allow the command line interface to interact with the Minikube Docker daemon:^[400-devops-06-kubernetes-minikube.md]
minikube docker-env
Application Deployment¶
Once the cluster is running, standard kubectl commands are used to deploy and manage applications.^[400-devops-06-kubernetes-minikube.md] A typical workflow involves creating a deployment and exposing it via a service:^[400-devops-06-kubernetes-minikube.md]
- Create Deployment:
[kubectl](<./kubectl.md>) create deployment k8s02-minikube --image=docker.io/nginx:1.23 - Expose Service:
[kubectl](<./kubectl.md>) expose deployment k8s02-minikube --type=NodePort --port=80 - Verify Status:
[kubectl](<./kubectl.md>) get services k8s02-minikube
Accessing Services¶
Minikube provides convenient methods to access services running inside the cluster:^[400-devops-06-kubernetes-minikube.md]
- Open URL: The
minikube servicecommand automatically launches the application's URL in the default web browser.minikube service k8s02-minikube - Port Forwarding: Alternatively,
kubectlcan be used to forward a local port to the service.[kubectl port-forward](<./kubectl-port-forward.md>) service/k8s02-minikube 7080:80
Cluster Management¶
Minikube offers commands to control the state of the local cluster without losing data or configurations.^[400-devops-06-kubernetes-minikube.md]
- Pause/Unpause: Pausing the cluster stops the Kubernetes components (saving host resources) while keeping the deployed applications' state persistent.
minikube pause minikube unpause - Stop: Halting the cluster stops the virtual machine or container entirely.
minikube stop - Delete: To remove the cluster traces (requires a restart to rebuild).
minikube delete minikube delete --all
Add-ons¶
Users can extend the functionality of their local cluster using Minikube's add-on system.^[400-devops-06-kubernetes-minikube.md]
minikube addons list
Related Tools¶
Several tools integrate with Minikube to streamline development workflows:^[400-devops-06-kubernetes-minikube.md]
- [[Draft]]: A tool for streamlining containerized application development.
- Skaffold: Google's tool for automating the build and deployment process.
- [[Okteto]]: A platform for developing and deploying Kubernetes applications.
Sources¶
^[400-devops-06-kubernetes-minikube.md]