-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-dashboard.sh
30 lines (24 loc) · 1020 Bytes
/
install-dashboard.sh
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
#!/bin/bash
# Install Kubernetes Dashboard
# http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default
export KUBECONFIG=/etc/kubernetes/admin.conf
sudo apt-get install -y jq
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml
# Create admin account for accessing kubernetes dashboard
kubectl create -n kube-system serviceaccount admin
kubectl create clusterrolebinding admin \
--clusterrole=cluster-admin \
--group=system:serviceaccounts
# Find and print authentication token
get_token () {
export TOKEN_NAME=`kubectl get serviceaccount -n kube-system admin -o json | jq -er '.secrets[0].name'`
}
get_token
while [[ $TOKEN_NAME != *admin-token* ]]
do
echo "Waiting for secret to be set..."
sleep 1s
get_token
done
export DASHBOARD_TOKEN=`kubectl get secrets $TOKEN_NAME -n kube-system -o json | jq -r '.data.token' | base64 --decode`
echo "Admin token for dashboard: $DASHBOARD_TOKEN"