minikube single-node cluster

curl -LO
sudo install minikube-darwin-amd64 /usr/local/bin/minikube
minikube start –driver=virtualbox #have many other options like docker/podman
kubectl get nodes
minikube status

minikube multi-node cluster

新版本的minikube开始尝试支持multiple-node cluster

$minikube start --nodes 2 -p cluster --driver=virtualbox #cluster is the name of the cluster you're creating
More options: --memory='8g' (per vm, default is 2g) --cpus=4 (per vm, default is 2)
$kubectl get nodes
$minikube status -p cluster
$minikube dashboard -p cluster #create a dashboard
$minikube stop -p cluster
$minikube delete -p cluster

create a service (2 instances)

See official site.
$vi hello-deployment.yml
$vi hello-svc.yml
$kubectl apply -f hello-deploy.yml
$kubectl apply -f hello-svc.yml
$kubectl get pods -o wide
$kubectl get pod -w -l app=nginx
$minikube service list -p cluster
$minikube service service_name –url
$kubectl get service service_name
$curl #run many times to see which pod a response is from
$kubectl get pods

$kubectl logs -f pod_name
$kubectl exec -it pod_name — /bin/bash
$kubectl get pod pod_name -o yams
$kubectl get events

minikube add-ons

$minikube addons list -p cluster
$minikube addons enable <name> -p cluster
$minikube addons open <name> -p cluster #expose a browser endpoint
$minikube addons disable <name> -p cluster #disable add-on


Use kubectl run to execute a container that provides the nslookup command from the dnsutils package. Using nslookup on the Pods’ hostnames, you can examine their in-cluster DNS addresses.

$kubectl run -i –tty –image busybox:1.28 dns-test –restart=Never –rm
$nslookup web-0.nginx

$kubectl get statefulset web