# 设置 docker 加速镜像 ➜ minikube start --registry-mirror=https://registry.docker-cn.com Starting local Kubernetes v1.8.0 cluster... Starting VM... Getting VM IP address... Moving files into cluster... Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster. Loading cached images from config file.
3.2 检测状态
1 2 3 4
➜ minikube status minikube: Running cluster: Running kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100
3.3 启动 kubernetes dashboard
1 2
➜ minikube dashboard Opening kubernetes dashboard in default browser...
输入以上命令,浏览器中应该就会显示以下界面:
3.4 测试
运行一个 nginx 的 pod
1 2
➜ kubectl run hello --image=nginx --port=80 deployment "hello" created
导出运行的 nginx 服务
1 2
➜ kubectl expose deployment hello --type=NodePort service "hello" exposed
查看一下运行情况,需要等一会才会显示状态为 Running
1 2 3
➜ kubectl get pod NAME READY STATUS RESTARTS AGE hello-6dbbbb95d-4cqwz 1/1 Running 0 2m
➜ curl $(minikube service hello --url) <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p>
<p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p> </body> </html>
3.5 其它
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# 查看集群的所有资源 ➜ kubectl get all ➜ kubectl get all -o wide
# 进入节点服务器 ➜ minikube ssh
# 执行节点服务器命令,例如查看节点 docker info ➜ minikube ssh -- docker info