sudo mkdir -p /opt/cli/minikube-linux-amd64/bin
curl -sLO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /opt/cli/minikube-linux-amd64/bin/minikube
sudo update-alternatives --install /usr/local/bin/minikube minikube\
/opt/cli/minikube-linux-amd64/bin/minikube 1980
rm -rf minikube-linux-amd64
Order |
Port Type |
Internal IP |
Internal Port |
External IP |
External Port
|
1 |
TCP |
0.0.0.0 |
32443 |
127.0.0.1 |
49153
|
2 |
TCP |
0.0.0.0 |
8443 |
127.0.0.1 |
49154
|
3 |
TCP |
0.0.0.0 |
5000 |
127.0.0.1 |
49155
|
4 |
TCP |
0.0.0.0 |
2376 |
127.0.0.1 |
49156
|
5 |
TCP |
0.0.0.0 |
22 |
127.0.0.1 |
49157
|
Kubectl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt install kubectl
Cluster
minikube start
:'
😄 minikube v1.25.2 on Ubuntu 22.04
✨ Automatically selected the docker driver. Other choices: none, ssh
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.23.3 preload ...
> preloaded-images-k8s-v17-v1...: 505.68 MiB / 505.68 MiB 100.00% 4.60 MiB
> gcr.io/k8s-minikube/kicbase: 379.06 MiB / 379.06 MiB 100.00% 2.47 MiB p/
🔥 Creating docker container (CPUs=2, Memory=6900MB) ...
🐳 Preparing Kubernetes v1.23.3 on Docker 20.10.12 ...
▪ kubelet.housekeeping-interval=5m
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
'
kubectl get po -A
minikube kubectl -- get po -A
:'
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-64897985d-thxhw 1/1 Running 0 8m14s
kube-system etcd-minikube 1/1 Running 0 8m26s
kube-system kube-apiserver-minikube 1/1 Running 0 8m26s
kube-system kube-controller-manager-minikube 1/1 Running 0 8m26s
kube-system kube-proxy-xqfl2 1/1 Running 0 8m13s
kube-system kube-scheduler-minikube 1/1 Running 0 8m26s
kube-system storage-provisioner 1/1 Running 1 (7m43s ago) 8m25s
'
Dashboard
minikube dashboard
:'
🔌 Enabling ...
▪ Using image kubernetesui/metrics-scraper:v1.0.7
▪ Using image kubernetesui/dashboard:v2.3.1
🤔 Verifying dashboard health ...
🚀 Launching proxy ...
🤔 Verifying proxy health ...
🎉 Opening http://127.0.0.1:36403/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
Gtk-Message: 17:34:36.652: Failed to load module "canberra-gtk-module"
Gtk-Message: 17:34:36.654: Failed to load module "canberra-gtk-module"
'
Deploy
kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment hello-minikube --type=NodePort --port=8080
kubectl get services hello-minikube
minikube service hello-minikube
kubectl port-forward service/hello-minikube 7080:8080
http://localhost:7080/
LoadBalancer deployments
kubectl create deployment balanced --image=k8s.gcr.io/echoserver:1.4
kubectl expose deployment balanced --type=LoadBalancer --port=8080
minikube tunnel
kubectl get services balanced
Example
docker build -t chorke/crawler:1.0.00 -f ./Dockerfile .
minikube image load chorke/crawler:1.0.00
minikube image ls --format table
kubectl run crawler --image=chorke/crawler:1.0.00 --image-pull-policy=Never --restart=Never
kubectl get pod
kubectl logs crawler
kubectl delete pod crawler
kubectl delete -n default pod crawler
kubectl create deployment crawler --image=chorke/crawler:1.0.00
kubectl expose deployment crawler --type=NodePort --port=1983
kubectl get services crawler
minikube kubectl -- get service crawler
minikube service --all
kubectl port-forward service/crawler 1983:1983
http://localhost:1983/crawler
Knowledge
minikube stop
minikube start
minikube pause
minikube unpause
minikube addons list
minikube delete --all
|
minikube docker-env
minikube image ls --format table
minikube config set memory 16384
eval $(minikube -p minikube docker-env)
minikube start -p aged --kubernetes-version=v1.16.1
minikube start -p aged --kubernetes-version=v1.24.0
|
|
docker ps -a
docker images
docker image ls
docker network ls
docker rm $(docker ps -a -q)
docker stop $(docker ps -a -q)
docker build\
-t chorke/crawler:1.0.00 -f ./Dockerfile .
docker logs crawler
docker stop crawler && docker rm crawler
|
kubectl get pod
kubectl cluster-info
kubectl get namespaces
kubectl -n kube-system get svc -o wide
minikube image ls --format table
minikube image load chorke/crawler:1.0.00
kubectl run crawler --image=chorke/crawler:1.0.00\
--image-pull-policy=Never --restart=Never
kubectl logs crawler
kubectl delete pod crawler
|
|
docker container inspect minikube \
--format="Template:(index (index .NetworkSettings.Ports \"8443/tcp\") 0).HostPort"
docker container ls --filter=name=minikube --format="Template:.Ports" | tr , \\n
|
References