-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathdeploy_dashboard_user.sh
executable file
·32 lines (24 loc) · 1.22 KB
/
deploy_dashboard_user.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
31
32
#!/usr/bin/env bash
# Source common libraries and env variables
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR="${SCRIPT_DIR}/../.."
source ${ROOT_DIR}/scripts/common.sh
# Make the dashboard a NodePort
kubectl patch svc -n kube-system kubernetes-dashboard -p '{"spec": {"type": "NodePort", "ports": [{"nodePort": 31443, "port": 443}] }}'
kubectl -n kube-system get sa admin-user 2>&1 | grep "NotFound" >/dev/null 2>&1
if [ $? -eq 0 ] ; then
kubectl apply -f workloads/services/k8s/k8s-dashboard-admin.yml
fi
# Get IP of first master
dashboard_port=$(kubectl -n kube-system get svc kubernetes-dashboard --no-headers -o custom-columns=PORT:.spec.ports.*.nodePort)
master_ip=$(kubectl get nodes -l node-role.kubernetes.io/control-plane= --no-headers -o custom-columns=IP:.status.addresses.*.address | cut -f1 -d, | head -1)
# Get access token
token=$(kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}') | grep ^token: | awk '{print $2}')
export dashboard_url="https://${master_ip}:${dashboard_port}"
# Print Dashboard address
echo
echo "Dashboard is available at: ${dashboard_url}"
# Print token
echo
echo "Access token: ${token}"
echo