1、安裝Docker Desktop
下載下傳位址 自行百度即可 M1 晶片選擇Apple chip (根據配置選擇)
2、K8S
git clone https://github.com/gotok8s/k8s-docker-desktop-for-mac.git
現在後執行腳本
./load_images.sh
安裝之後執行 kubectl 指令
見到下圖表示K8S安裝成功了。
3、Docker Desktop下啟用Kubernetes
具體步驟參照下圖所示,等待重新開機完畢,K8S安裝成功
# 輸入如下指令驗證
kubectl cluster-info
kubectl get namespace
kubectl get node
4、Dashboard 安裝
先貼兩張圖,直覺感受一下
登陸頁面,使用Token登陸
管理界面
下載下傳DashBoard安裝檔案 Yaml
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
使用Yaml檔案安裝
kubectl apply -f recommended.yaml
啟動Dashboard
kuberctl proxy
Dashboard通路位址
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
接下來的步驟為了生成登陸的Token 需要3個檔案
dashboard-adminuser.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: dashboard-admin
namespace: kubernetes-dashboard
dashboard-admin-bind-cluster-role.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dashboard-admin-bind-cluster-role
labels:
k8s-app: kubernetes-dashboard
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: dashboard-admin
namespace: kubernetes-dashboard
dashboard-admin-token.yaml
apiVersion: v1
kind: Secret
metadata:
name: dashboard-admin-secret
namespace: kubernetes-dashboard
annotations:
kubernetes.io/service-account.name: dashboard-admin
type: kubernetes.io/service-account-token
然後一次執行
kubectl apply -f dashboard-adminuser.yaml
kubectl apply -f dashboard-admin-bind-cluster-role.yaml
kubectl apply -f dashboard-admin-token.yaml
最後檢視Token 内容
kubectl describe secret dashboard-admin-secret -n kubernetes-dashboard
複制Token 就可以登陸Dashboard管理界面了。