Windows 10 开启 Docker Desktop 中的 Kubernetes
开启 ExpressVPN启动 Docker DesktopSettings > Kubernetes > Enable Kubernetes开启后,需要等待一段时间,会自动下载 images 文件,之后 Kubernetes 会主动重新启动如果 Kubernetes 没有启动成功,尝试重启 Docker DesktopKubernetes 正常启动后,Docker Desktop 中2个图标都是
-
开启 ExpressVPN
-
启动 Docker Desktop
-
Settings > Kubernetes > Enable Kubernetes
-
开启后,需要等待一段时间,会自动下载 images 文件,之后 Kubernetes 会主动重新启动
-
如果 Kubernetes 没有启动成功,尝试重启 Docker Desktop
-
Kubernetes 正常启动后,Docker Desktop 中2个图标都是绿色
-
检查 Kubernetes cluster 状态
kubectl get nodes # Kubernetes 集群的系统容器 默认不会在 docker 中显示,通过以下docker命令是看不到的 docker container ls docker info
-
使用 kubectl 部署 Kubernetes Dashboard v2.6.0
# 部署 Kubernetes Dashboard v2.6.0 kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml # 启动代理 kubectl proxy # 代理正常启动后会显示:Starting to serve on 127.0.0.1:8001 # 创建管理员账号 kubernetes-dashboard ,该账号仅有少量权限 kubectl -n kubernetes-dashboard create token kubernetes-dashboard # 创建成功后会显示 Token # eyJhbGciOiJSUzI1NiIsImtpZCI6Iko4Tl8xMVV4dlVQM3JWbzJ0M3NRaGc1NkNJdVZybmk5aXd3dW5Fczd4WkkifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNjU2NjY4ODUyLCJpYXQiOjE2NTY2NjUyNTIsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsInVpZCI6IjBhNDJjOTlhLTk5ZDctNDYwYy1hM2E4LWNiNjM4MTdkZmUxZCJ9fSwibmJmIjoxNjU2NjY1MjUyLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQifQ.ySvpHIv4gwJAAJ2PccNSLlRjuUZDkWsBiZK3PiOj-0P4E-P7i54T_WYsCg4nddiZTSOcoDlZMu98dwUvL71paFICc_GMTsH8P9V1xUxNxTVxAluuGmHZeFeafy29MnpkXRBljFRxOfZiFbTKvxGep6cPmwQPnnFFz1-DyHVBVYLg-ZV27qX4MMfW-QL_V98wo7zwtFIxgMSqCXyYlZVxiC3AjNEMS7bnU4ZzV0aKoLVWEDnyn5QVtnPHMDYIj2PGtF5D5opEYQ-QN9HINKL_e1i5n4ZTF3siDCY-eeUybwVKRnsYkX1Tp4IYY7N3xyhcUUMKWFyJNI03ZG0ROpBSzg
-
访问 Kubernetes Dashboard http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
-
选择 Token ,在下面输入框输入 kubernetes-dashboard 的 Token
-
登录进入后可以修改默认语言
-
通过以下命令可以将 kubernetes-dashboard 账号、规则删除,可以参考 Creating sample user
kubectl -n kubernetes-dashboard delete serviceaccount kubernetes-dashboard kubectl -n kubernetes-dashboard delete clusterrolebinding kubernetes-dashboard
-
通过创建如下 account.yaml 文件来创建一个具有全部管理权限的用户
apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kubernetes-dashboard --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: admin-user roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-admin subjects: - kind: ServiceAccount name: admin-user namespace: kubernetes-dashboard
-
运行命令
kubectl apply -f ./account.yaml kubectl -n kubernetes-dashboard create token admin-user # eyJhbGciOiJSUzI1NiIsImtpZCI6Iko4Tl8xMVV4dlVQM3JWbzJ0M3NRaGc1NkNJdVZybmk5aXd3dW5Fczd4WkkifQ.eyJhdWQiOlsiaHR0cHM6Ly9rdWJlcm5ldGVzLmRlZmF1bHQuc3ZjLmNsdXN0ZXIubG9jYWwiXSwiZXhwIjoxNjU2NjcxMTI2LCJpYXQiOjE2NTY2Njc1MjYsImlzcyI6Imh0dHBzOi8va3ViZXJuZXRlcy5kZWZhdWx0LnN2Yy5jbHVzdGVyLmxvY2FsIiwia3ViZXJuZXRlcy5pbyI6eyJuYW1lc3BhY2UiOiJrdWJlcm5ldGVzLWRhc2hib2FyZCIsInNlcnZpY2VhY2NvdW50Ijp7Im5hbWUiOiJhZG1pbi11c2VyIiwidWlkIjoiMzkxMDNiYjctZDVlOS00ZDA2LTlmNGEtOTRjODA2NTcxZDMwIn19LCJuYmYiOjE2NTY2Njc1MjYsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlcm5ldGVzLWRhc2hib2FyZDphZG1pbi11c2VyIn0.dzi2yYzoGL1q9rm5I6ATTpnyicfSE2M_pnDgfSHHCBAXYFHAjBgZs4-OstRnyGGfgUzOZYI7Kx2QVS3JWGRu83LTYHZjudzIlqX6CbHhbxRPaSgU1LljDhMydi1oFgdmg4TEPMejrw2OZ-TuCFPCs575BuoT6Bw2KZnp4IDT1-ctsc1K6lwpsF7pKN0Q6JJsXrWCisPyf7NohXrbHE0EhzsItDEKRbGVpn_pSr1IRn0mDt06S0Y-ZJpJ4nwcKQQhwT4dYA1PKUdy2djpO4xK3syZc9E2wefHbhOm47fF-T_8lL_SoNqjWRv5e0VpvSax1IZpCYylxToUM9QbwR8NXg
-
注意查看内容的时候,使用的是 default 命名空间,是不包含 kubernetes 系统服务的
-
可以 运行一个示例 Example Voting App
# 创建 vote 命名空间 kubectl create namespace vote # 创建服务 kubectl create -f k8s-vote/ # 检查服务启动情况 kubectl -n vote get pods
-
Example Voting App 的架构如下图
欢迎访问我的博客 原文 天天成长 - Windows 10 开启 Docker Desktop 中的 Kubernetes
更多推荐
所有评论(0)