1. 安装Docker
安装docker步骤如下:
- 下载Docker
- 启用hyper-v
2.1.powershell,管理员运行Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
- 安装wsl
- 配置Docker镜像加速地址(阿里云)
4.1."registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com", "https://docker.mirrors.ustc.edu.cn"]
注意:安装过程中会重启两次
2.安装K8S
- 拉取k8s-for-docker-desktop代码
管理员身份运行PowerShell,切换到该目录下,启用 PowerShell 脚本的执行权限
set-executionpolicy remotesigned
,然后执行
.\load_images.ps1
-
Docker开启K8S
-
安装K8S Dashboard
kubectl apply -f .\kubernetes-dashboard.yaml
然后,添加默认账号,授权登录基于Token登录
kubectl apply -f .\kube-system-default.yaml$TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
kubectl config set-credentials docker-desktop --token="${TOKEN}"
echo $TOKEN
- k8s 拉取kubernetesui/dashboard
docker pull kubernetesui/dashboard:v2.5.1
kubectl create -f kubernetes-dashboard.yaml
- 开启API Server服务
kubectl proxy
- 创建 ClusterRoleBinding
vim dash.yaml---
apiVersion: v1
kind: ServiceAccount
metadata:name: admin-usernamespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:name: admin-user
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: cluster-admin
subjects:
- kind: ServiceAccountname: admin-usernamespace: kubernetes-dashboardkubectl apply -f dash.yaml
kubectl -n kubernetes-dashboard create token admin-user
- 开启API Server服务
kubectl proxy
访问网站(http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
),输入令牌,成功访问
如果出现问题,重启电脑
附录
参考
- k8s