启用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
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
评论 (0)