Exploring minikube commands
How to use Minikube commands guide
With Civo Academy, learn about the various commands used to perform tasks with Minikube
Minikube Commands to get started with
Let's look into a few of the Minikube commands that are very useful and make you even more familiar with the particular system. One of the commands we can use to output the environment variable is
docker-env. So, for example, we can use the command
"minikube docker-env". If you have worked with Docker machines, you'll notice that the output is similar, and you can see that both the docker-machine env and minikube docker-env serve the same purpose. They output the environment variables required for a local Docker client to communicate with a remote server of Docker. In this particular case, that Docker server is inside a virtual machine that Minikube is creating.
You can also do some verification. For example, list all the running containers on that virtual machine. Then, you can write the command
"docker container ls" and see Minikube is up and running. Also, you can see all the containers that Kubernetes require. Then, of course, you can consider them as system containers, but that's a little more for you to explore.
Since almost everything in that virtual machine is a container pointing to the local Docker client, it should be all you need besides Kubectl. However, you might want to SSH into the virtual machine in some cases. In that case, enter the command
minikube ssh. After that, enter the command
docker container ls and you will get to see the listed containers. So, we entered into the Minikube, listed all the containers, and now, we can also exit out of it.
Kubectl with Minikube
Now, we will check if Kubectl is also pointing to that particular virtual machine of Minikube. We have to enter the command
Kubectl config current-context to do that, which will return Minikube as the output. It portrays that Kubectl is configured to talk to the Kubernetes inside the newly created cluster. You can also list all the nodes from Kubectl. For that, enter the command
kubectl get nodes, and you will again receive Minikube as the output. You will notice that it says there is only one node because we mentioned in the beginning that it works as the master node and the worker node.
Now, we will look at all the components that are currently running in our cluster. You can notice that this is a very tiny cluster, and we don't have many things going on over here. To get a glance at all the running services, enter the command
kubectl get all-namespaces, and you can see that I have a few things running because I already used it before. You will be able to see all the applications, dashboards, and other running things.
Starting, Stopping, and Deleting a Cluster
You'll learn more about deployments and all these other things in future sessions. Some of the common Minikube commands are something that we can look at. For example, you can look into the command for stopping Minikube. So if we enter the command
minikube stop, it will stop your Kubernetes cluster. It shuts down the virtual machine, but it will preserve all the cluster states and data. If we start the cluster again, it will restore it to the previous data. You can start it again by using the command
minikube start, or you can also delete it by using
minikube delete. If we enter
minikube delete, it will delete the cluster. It's going to shut down and delete the Minikube virtual machine. One thing to note over here is that no data or state will be preserved.