装置前筹备
确保本地曾经装置并启动好了Docker Desktop
拉取k8s镜像
克隆git仓库到本地
git clone https://github.com/gotok8s/k8s-docker-desktop-for-mac.git
进入我的项目目录,执行
./load_images.sh
期待所有镜像拉取实现
部署k8s
进入Docker Decktop
的设置页面,勾选Kubernetes
设置页的配置,点击右下角的Apply & Restart
按钮,期待k8s实现部署
实现当前能够验证一下部署状态
kubectl cluster-infokubectl get nodeskubectl describe node
装置k8s Dashboard
利用举荐配置
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml
获取登录token
开启代理并且设置代理端口为8001
kubectl proxy --port=8001
关上新的命令窗口,执行
获取token不带参数
curl 'http://127.0.0.1:8001/api/v1/namespaces/kube-system/serviceaccounts/kubernetes-dashboard/token' -H "Content-Type:application/json" -X POST -d '{}'
获取token带参数
curl 'http://127.0.0.1:8001/api/v1/namespaces/kube-system/serviceaccounts/kubernetes-dashboard/token' -H "Content-Type:application/json" -X POST -d '{"kind":"TokenRequest","apiVersion":"authentication.k8s.io/v1","metadata":{"name":"kubernetes-dashboard","namespace":"kube-system"},"spec":{"audiences":["https://kubernetes.default.svc.cluster.local"],"expirationSeconds":7600}}'
登录k8s Dashboard
复制上一步返回的token信息,浏览器拜访如下地址,填入token即可登录
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login