Minikube
1. Minikube Commands
A minikube cluster consists of 1 node, that serves both as the master node & the worker node, looks like that:
On the left, you can see at the top level the Kubernetes Cluster. Under the Kubernetes Cluster, there could be 1 or more nodes (servers). Minikube used to have only 1 (it can now have more). Under the Node, there could be 1 or more pods. Under the pod, there could be 1 or more containers. Usually? A pod holds only 1 container.
When creating a minikube cluster for the first time, by default, it's created with:
- 1 kubernetes cluster
- 1 node (that acts like both the master & worker node)
- 1 pod
- Command 1: minikube delete
The command:
minikube delete
Description:
Deletes a local Kubernetes cluster. This command deletes the VM, and removes all associated files.
- Command 2: minikube profile list
The command:
minikube profile list
Description:
Lists all minikube profiles. Lists all valid minikube profiles and detects all possible invalid profiles.
A response example would look like:
- Deleting "minikube" in docker ...
- Deleting container "minikube" ...
- Removing C:\Users\tal\.minikube\machines\minikube ...
- Removed all traces of the "minikube" cluster.
- Command 3: minikube profile
The command:
Set profile as default:
minikube profile profile_name
Get current profile:
minikube profile
Description:
profile
sets the current minikube profile, or gets the current profile if no arguments are provided. This is used to run and manage multiple minikube instances. You can return to the default minikube profile by running minikube profile default
- Command 4: minikube start
The command:
If it's your 1st time running this command:
- Option 1: start a cluster using the docker driver
minikube start --driver=docker --profile profile_name
- Option 2: make docker the default driver, then you could use short:
minikube start
minikube config set driver docker
minikube start
If it's your 2nd+ time running this command:
minikube start
Description:
Starts a kubernetes cluster locally on your machine.
For this command to work, your machine's Docker Engine needs to be running. It should take a few minutes to start a minikube cluster. That cluster has only 1 node, which acts as both the master node & the worker node.
The cluster is created with a default profile called minikube
, which you could override using the --profile
(-p
) flag:
minikube start --profile prod
A response example would look like:
- minikube v1.26.1 on Microsoft Windows 10 Home 10.0.19044 Build 19044
- Using the docker driver based on user configuration
- Using Docker Desktop driver with root privileges
- Starting control plane node minikube in cluster minikube
- Pulling base image ...
> gcr.io/k8s-minikube/kicbase: 74.85 MiB / 386.61 MiB 19.36% 4.79 MiB p/s
- Command 5: minikube stop
The command:
minikube stop
Description:
Stops a running local Kubernetes cluster.
Stops a local Kubernetes cluster. This command stops the underlying VM or container, but keeps user data intact. The cluster can be started again with the "start" command.
A response example would look like:
- minikube v1.26.1 on Microsoft Windows 10 Home 10.0.19044 Build 19044
- Using the docker driver based on user configuration
- Using Docker Desktop driver with root privileges
- Starting control plane node minikube in cluster minikube
- Pulling base image ...
> gcr.io/k8s-minikube/kicbase: 74.85 MiB / 386.61 MiB 19.36% 4.79 MiB p/s
- Command 6: minikube status
The command:
minikube status --profile profile_name
Description:
Shows the status of your kubernetes cluster.
A response example would look like:
A good response would look like:
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
If a cluster does not exist, the response would appear as such:
Profile "minikube" not found.
- Command 7: minikube ip
minikube ip --node node_name --profile profile_name
Description:
Returns the IP address of the specified node.
Commonly used options:
-
Flag 1: -n | --node
By default, it returns the ip of the node which is considered as the primary control plane. To get the ip of some other node, use the-n
,--node
flag followed by its name.minikube ip --node luckylove
- Command 8: minikube node list
minikube node list
Description:
Returns a list of all nodes inside the minikube cluster.
A response example would look like:
minikube 192.168.49.2
- Command 9: minikube ssh
minikube ssh --node node_name --profile profile_name
Description:
A way to connect to your minikube environment (for debugging).
With this command you don't even need to enter a password! So it's much more comfortable.
A response example would look like:
docker@minikube:~$
We can learn from the output above that when we ran minikube start
to create the cluster, minikube by default created a username called "docker", with a default password of "tcuser".
- Username: docker
- Password: tcuser
- Command 10: minikube service
minikube service -n <namespace> name_of_service
Description:
In case of a NodePort type, opens up a web browser with the kubernetes URL for the service running in your local cluster.