# Setup Minikube

We will use minikube in to run kubernetes cluster in your local machine. You can download and install minikube from their official website: <https://minikube.sigs.k8s.io/docs/>.

## Start and Configure a Kubernetes Cluster

### Start Minkube

```bash
minikube start --kubernetes-version=v1.31.0 --cpus=2 --memory=4096
```

* This starts a cluster with 2 CPUs and 4GB of memory, running Kubernetes version 1.31.0.
* You can check the cluster status: `kubectl cluster-info`
* Which should return below information:

```bash
Kubernetes control plane is running at https://127.0.0.1:57821
CoreDNS is running at https://127.0.0.1:57821/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
```

### View Cluster Configuration

Check Node information.

```bash
kubectl get nodes
kubectl describe node minikube
```

List system components of kubernetes such as API Server, Scheduler, Controller Manager, CoreDNS, etc.

```bash
kubectl get pods -n kube-system
```

Above command should return you list like below.

```bash
NAME                               READY   STATUS    RESTARTS      AGE
coredns-6f6b679f8f-88xz9           1/1     Running   0             24m
etcd-minikube                      1/1     Running   0             24m
kube-apiserver-minikube            1/1     Running   0             24m
kube-controller-manager-minikube   1/1     Running   0             24m
kube-proxy-zxlvw                   1/1     Running   0             24m
kube-scheduler-minikube            1/1     Running   0             24m
storage-provisioner                1/1     Running   1 (24m ago)   24m
```

### Add/Remove Nodes

Although Minikube is single-node by default, simulate multi-node behavior using Minikube profiles. Here's how to add a new Node in minikube.

```bash
minikube node add
```

Get list of nodes again using `kubectl get nodes` and it should return newly added nodes.

```bash
NAME           STATUS   ROLES           AGE   VERSION
minikube       Ready    control-plane   32m   v1.31.0
minikube-m02   Ready    <none>          17s   v1.31.0
```

Removing a Node.

```bash
minikube node delete minikube-m02
```

## References

* <https://minikube.sigs.k8s.io/docs/tutorials/multi_node/>
