Creating Kubernetes Cluster
As discussed in earlier chapters, for our learning environment we will be using Minikube to create our kubernetes cluster. Minikube kubernetes cluster runs on single node meaning both the control plane and worker node will be the same.
Create Minikube K8s Cluster
Assuming you have installed minikube, the only command you need to start the cluster is:
minikube startMinikube will spin up k8s cluster with default driver depending on your OS (mostly docker) however you can change it if required or failed to start. See available drivers per OS. It may take some time to start your cluster for the first time but hopefully you will see:
😄 minikube v1.38.1 on Ubuntu 24.04 (kvm/amd64)
✨ Using the docker driver based on existing profile
👍 Starting "minikube" primary control-plane node in "minikube" cluster
<stripped for readability>
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by defaultNote
As kubernets ultimately manages containers, you need containerd and preferably docker (assuming you are transitioning from Docker to K8s) as dependencies.
Minikube manages your K8s cluster but to interact with the cluster you need kubectl which you should install from kubernetes.
What’s Inside The K8s Cluster?
Setting up the cluster means to make sure all the mandatory kubernetes components are available both in control plane and in worker node which is the same in Minikube K8s cluster. You can see the status:
minikube statusminikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: ConfiguredMinikube has actually started our cluster inside the docker container (default driver). You can see that:
docker container lsCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4825cc8bbef7 gcr.io/k8s-minikube/kicbase:v0.0.50 "/usr/local/bin/entr…" 17 hours ago Up 7 minutes 127.0.0.1:32768->22/tcp, 127.0.0.1:32769->2376/tcp, 127.0.0.1:32770->5000/tcp, 127.0.0.1:32771->8443/tcp, 127.0.0.1:32772->32443/tcp minikubeThis means obviously you can go inside the container and see what’s going on:
docker container exec -it minikube bashNobody is stopping you to go inside the cluster using docker container exec but Minikube makes it simple:
minikube sshMinikube configs for ssh and other normally lives at ~/.minikube.
Note
In real world, you will be SSHing ssh -i <key> somehost to some control plane instead of minikube ssh.
With minikube ssh, you will get PS4 prompt i.e. you are now inside the cluster:
docker@minikube:~$Where are the kubernetes components running?
Yep that’s a good question. Actually they are running inside the minikube container as containers. Yeah, containers container. Once inside Minikube container, you can:
docker container lsYou will see a very long list of containers (stripped for readability) running which are actually the components of K8s managed by Minikube:
docker container ls --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.Names}}'CONTAINER ID IMAGE COMMAND NAMES
0ffcc1736067 6e38f40d628d "/storage-provisioner" k8s_storage-provisioner_storage-provisioner_kube-system_e1f227fd-2888-4f8b-b9c3-1b2820f33784_6
23d613973c86 aa5e3ebc0dfe "/coredns -conf /etc…" k8s_coredns_coredns-7d764666f9-q52dv_kube-system_74e10ab8-65a1-496f-97a7-a3657d9b76c3_3
4af57f93317a 6521110cdb01 "/usr/local/bin/kube…" k8s_kube-proxy_kube-proxy-hdhv4_kube-system_b4e71313-7606-4703-870c-802923d3839a_3We will explore more in upcomming chapters.