mac快速启动k8s
# 安装docker desktop
- 下载docker desktop https://www.docker.com/get-started/
- 点点点 安装完成
# 配置国内镜像地址
启动 docker desktop
配置国内镜像地址
点击docker desktop右上角设置
配置源
# 启动k8s
# 安装Dashboard
创建 Dashboard pod
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
1查看 Dashboard pod 健康状态
kubectl get pods -n kube-system
1如果处于
ImagePullBackOff
状态,镜像拉取失败, 使用命令kubectl describe pods kubernetes-dashboard-cd4778d69-7stbb -n kube-system
查看pod日志Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 4m38s default-scheduler Successfully assigned kube-system/kubernetes-dashboard-975499656-krwl7 to k8s-node2 Normal Pulling 2m32s (x4 over 4m38s) kubelet, k8s-node2 Pulling image "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1" Warning Failed 2m16s (x4 over 4m22s) kubelet, k8s-node2 Failed to pull image "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1": rpc error: code = Unknown desc = Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers) Warning Failed 2m16s (x4 over 4m22s) kubelet, k8s-node2 Error: ErrImagePull Normal BackOff 112s (x6 over 4m22s) kubelet, k8s-node2 Back-off pulling image "k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1" Warning Failed 99s (x7 over 4m22s) kubelet, k8s-node2 Error: ImagePullBackOff
1
2
3
4
5
6
7
8
9
10ImagePullBackOff
解决办法: 手动拉取镜像, 并修改标签# 手动拉取镜像:注意版本号 docker pull loveone/kubernetes-dashboard-amd64:v1.10.1 # 修改标签:注意版本号,修改自己报错日志的版本号 docker tag loveone/kubernetes-dashboard-amd64:v1.10.1 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.1 # 重新创建Dashboard pod kubectl delete -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/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
1
2
3
4
5
6
7
8
启动 kubectl proxy
kubectl proxy -p 8000 # 默认端口号 80001
1页面访问
http://localhost:8000/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
创建 ServiceAccount
本地创建
k8s-admin.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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18创建service account
kubectl apply -f k8s-admin.yaml
1获取token
kubectl -n kubernetes-dashboard create token admin-user
1
在页面输入token,登陆即可
上次更新: 2023/06/02, 19:38:12