安裝Dashboard
首先先下載官方的yaml檔案
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta5/aio/deploy/recommended.yaml訪問方式
1、直接https
修改訪問方式,這個地方可以隨機分配也可以直接指定,在這裡我指定了埠
kind: ServiceapiVersion: v1metadata: labels: k8s-app: kubernetes-dashboard name: kubernetes-dashboard namespace: kubernetes-dashboardspec: type: NodePort ports: - port: 443 targetPort: 8443 nodePort: 30018 #指定埠為30018,不寫則為隨機分配 selector: k8s-app: kubernetes-dashboard2、kubectl proxy 方式訪問
開啟kubectl proxy
kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'訪問地址
http://192.168.136.134:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login這裡的地址是master節點的地址
開始安裝
kubectl create -f ~/recommended.yaml檢查pad是否啟動
建立賬號建立admin賬號
cat <<EOF > dashboard-admin.yamlapiVersion: v1kind: ServiceAccountmetadata: labels: k8s-app: kubernetes-dashboard name: dashboard-admin namespace: kubernetes-dashboardEOFkubectl create -f dashboard-admin.yaml為使用者分配許可權
cat <<EOF > dashboard-admin-bind-cluster.yamlapiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata: name: dashboard-admin-bind-cluster-role labels: k8s-app: kubernetes-dashboardroleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cluster-adminsubjects:- kind: ServiceAccount name: dashboard-admin namespace: kubernetes-dashboardEOFkubectl create -f dashboard-admin-bind-cluster.yaml檢視token
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep dashboard-admin | awk '{print $1}')
選擇第二個輸入圖中的token
因為我們沒有安裝metrics-server所以Pods的CPU、記憶體情況是看不到的,下面我們安裝一下。
安裝metrics-server下載映象包
docker pull bluersw/metrics-server-amd64:v0.3.6docker tag bluersw/metrics-server-amd64:v0.3.6 k8s.gcr.io/metrics-server-amd64:v0.3.6
執行下面的命令
mkdir metrics-servercd metrics-serverwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/aggregated-metrics-reader.yamlwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/auth-delegator.yamlwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/auth-reader.yamlwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/metrics-apiservice.yamlwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/metrics-server-deployment.yamlwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/metrics-server-service.yamlwget https://raw.githubusercontent.com/kubernetes-incubator/metrics-server/master/deploy/1.8%2B/resource-reader.yaml
修改配置檔案
安裝metrics-server
kubectl apply -f ./
訪問一下就可以看到資源了
最新評論