1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
| mkdir -p ~/kubernetes/kubernetes-dashboard
cd ~/kubernetes/kubernetes-dashboard
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm repo update kubernetes-dashboard
helm search repo kubernetes-dashboard
DASHBOARDVERSION=`helm search repo kubernetes-dashboard -o yaml | grep 'version:' | grep -v 'app_version:' | awk '{print $2}'`
echo ${DASHBOARDVERSION}
helm pull kubernetes-dashboard/kubernetes-dashboard --version ${DASHBOARDVERSION}
tar xf kubernetes-dashboard-${DASHBOARDVERSION}.tgz
helm show values ./kubernetes-dashboard
helm upgrade --install --dry-run --debug \
--namespace kubernetes-dashboard \
--create-namespace \
--set metrics-server.enabled=false \
--set nginx.enabled=false \
--set cert-manager.enabled=false \
--set app.ingress.enabled=true \
--set app.ingress.ingressClassName=nginx \
--set app.ingress.hosts[0]=dashboard.k8s.local \
kubernetes-dashboard ./kubernetes-dashboard
helm upgrade --install \
--namespace kubernetes-dashboard \
--create-namespace \
--set metrics-server.enabled=false \
--set nginx.enabled=false \
--set cert-manager.enabled=false \
--set app.ingress.enabled=true \
--set app.ingress.ingressClassName=nginx \
--set app.ingress.hosts[0]=dashboard.k8s.local \
kubernetes-dashboard ./kubernetes-dashboard
kubectl -n kubernetes-dashboard get events --sort-by .lastTimestamp -w
watch kubectl -n kubernetes-dashboard get pods
kubectl -n kubernetes-dashboard get ingress
# 查看状态
helm -n kubernetes-dashboard list
helm -n kubernetes-dashboard status kubernetes-dashboard
helm -n kubernetes-dashboard get values kubernetes-dashboard
helm -n kubernetes-dashboard get manifest kubernetes-dashboard
watch kubectl -n kubernetes-dashboard get pods -o wide
# 卸载
#helm -n kubernetes-dashboard uninstall kubernetes-dashboard
# Creating a Service Account
kubectl apply -f - <<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
EOF
# Creating a ClusterRoleBinding
kubectl apply -f - <<EOF
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
EOF
# 获取临时token
kubectl -n kubernetes-dashboard create token admin-user
# 创建永久token
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: admin-user
namespace: kubernetes-dashboard
annotations:
kubernetes.io/service-account.name: "admin-user"
type: kubernetes.io/service-account-token
EOF
# 获取永久token
kubectl get secret admin-user -n kubernetes-dashboard -o jsonpath={".data.token"} | base64 -d
# 清除账号
# kubectl -n kubernetes-dashboard delete serviceaccount admin-user
# kubectl -n kubernetes-dashboard delete clusterrolebinding admin-user
|