Docker Desktop启动Kubernetes

moonjerx
2021-09-07 / 0 评论 / 188 阅读 / 正在检测是否收录...

kt9fops9.png
启用k8s后,等待安装完成。

1.查看kubectl版本:
kubectl version
2.配置kubernetes:

可选操作:切换Kubernetes运行上下文至docker-desktop(之前版本的context为docker-for-desktop)

kubectl config use-context docker-desktop
3.验证Kubernetes集群状态
kubectl cluster-info
kubectl get nodes

kt9il21d.png

4.配置Kubernetes控制台
  • (1)部署Kubernetes dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml

或者

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc5/aio/deploy/recommended.yaml

或者

kubectl create -f kubernetes-dashboard.yaml
  • (2)检查kubernetes-dashboard应用状态
kubectl get pod -n kubernetes-dashboard
  • 开启API Server访问代理
kubectl proxy
  • (3)通过URL访问kubernetes dashboard
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
  • (4)生成令牌Token(需用Windows PowerShell打开,CMD无法执行)
$TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
kubectl config set-credentials docker-for-desktop --token="${TOKEN}"
echo $TOKEN

kt9j1w7k.png

kt9j1l2t.png

0

评论 (0)

取消

您的IP: