minikube操作教程
安装
官方文档
amd64
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
arm64
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-arm64
sudo install minikube-linux-arm64 /usr/local/bin/minikube
- 没安装
kubectl
可以使用minikube kubectl --
代替
启动你的集群
开始
minikube start --force
kubectl get po -A
minikube version
web界面
minikube dashboard --port=19888
# eg: http://127.0.0.1:19888/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
kubectl安装
官方文档
x86_64
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
arm64
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version
kubectl cluster-info
kubectl get nodes
helloworld
kubectl run hello-world -ti --rm --image=hello-world:latest --restart=Never --
部署应用程序
services
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube --type=NodePort --port=8080
kubectl get services hello-minikube
minikube service hello-minikube
or
kubectl port-forward service/hello-minikube 7080:8080
loadBalancer
kubectl create deployment balanced --image=kicbase/echo-server:1.0
kubectl expose deployment balanced --type=LoadBalancer --port=8080
minikube tunnel
kubectl get services balanced
Ingress
minikube addons enable ingress
…
管理你的集群
minikube pause
minikube unpause
minikube stop
minikube config set memory 9001
minikube addons list
minikube delete --all
旅行指南
基本控制
minikube start
minikube dashboard
kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube --type=NodePort --port=8080
minikube service hello-minikube
minikube start --kubernetes-version=latest
minikube start -p cluster2
minikube stop
minikube delete
minikube delete --all
部署应用程序
kubectl create deployment hello-minikube1 --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8080
minikube addons list
minikube addons enable <name>
minikube start --addons <name1> --addons <name2>
minikube addons open <name>
minikube addons disable <name>
Get pods
minikube kubectl -- get pods
minikube kubectl -- create deployment hello-minikube --image=kicbase/echo-server:1.0
minikube kubectl -- expose deployment hello-minikube --type=NodePort --port=8080
minikube kubectl -- --help
访问应用程序
NodePort
minikube service <service-name> --url
kubectl create deployment hello-minikube1 --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube1 --type=NodePort --port=8080
kubectl get svc
minikube service hello-minikube1 --url
ps -ef | grep [email protected]
http://127.0.0.1:TUNNEL_PORT
LoadBalancer
minikube tunnel
kubectl create deployment hello-minikube1 --image=kicbase/echo-server:1.0
kubectl expose deployment hello-minikube1 --type=LoadBalancer --port=8080
kubectl get svc
http://REPLACE_WITH_EXTERNAL_IP:8080
minikube tunnel --cleanup
配置集群
minikube config
Dashboard
minikube dashboard
minikube dashboard --port=19888
minikube dashboard --url
教程kubernetes101
创建一个 Kubernetes 集群
minikube version
minikube start
kubectl version
kubectl cluster-info
kubectl get nodes
部署一个应用程序
kubectl create deployment nginx --image=nginx:latest
kubectl get deployments
kubectl proxy # 和minikube dashboard一样
curl http://localhost:8001/version
探索你的应用程序
kubectl get pods
kubectl describe pods
kubectl logs $POD_NAME
kubectl exec $POD_NAME -- env
kubectl exec -ti $POD_NAME -- bash
curl localhost:80
exit
公开你的应用程序
kubectl get pods
kubectl get services
kubectl expose deployment/nginx --type="NodePort" --port 80
kubectl get services
kubectl describe services/nginx
curl $(minikube ip):$NODE_PORT
kubectl describe deployment
kubectl get pods -l app=nginx
kubectl get services -l app=nginx
kubectl label pods $POD_NAME version=v1
kubectl describe pods $POD_NAME
kubectl get pods -l version=v1
kubectl delete service -l app=nginx
kubectl get services
扩展你的应用程序
kubectl expose deployment/nginx --type="NodePort" --port 80
kubectl get deployments
kubectl get rs
kubectl scale deployments/nginx --replicas=4
kubectl get pods -o wide
kubectl describe deployments/nginx
Load Balancing
kubectl describe services/nginx
curl $(minikube ip):$NODE_PORT
kubectl scale deployments/nginx --replicas=2
kubectl get deployments
kubectl get pods -o wide
更新你的应用程序
kubectl get deployments
kubectl get pods
kubectl describe pods
kubectl set image deployments/nginx nginx=nginx:v2
kubectl get pods
kubectl describe services/nginx
kubectl rollout status deployments/nginx
kubectl describe pods
# 回滚
kubectl set image deployments/nginx nginx=nginx:v10
kubectl get deployments
kubectl get pods
kubectl describe pods
kubectl rollout undo deployments/nginx
kubectl get pods
kubectl describe pods