Last active
March 20, 2020 22:25
-
-
Save rgaidot/2ddfab0ef0885230b478d334c1b9a4d0 to your computer and use it in GitHub Desktop.
Boostrap k3d with kubernetes dashboard - curl https://gist.githubusercontent.com/rgaidot/2ddfab0ef0885230b478d334c1b9a4d0/raw/0283a1468e28c5b150a7e9bc4ef3c137405607fe/boostrap-k3d.sh | bash -s 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
cat <<EOF | |
__ ________ .___ | |
| | __\_____ \ __| _/ | |
| |/ / _(__ < / __ | | |
| < / \/ /_/ | | |
|__|_ \/______ /\____ | | |
\/ \/ \/ | |
Boostrap k3d with kubernetes dashboard (you can remove after by using 'k3d delete k3s-default') | |
--- | |
EOF | |
echo "run k3d with $1 worker(s)..." | |
if [ -z "$1" ]; then | |
echo 'WORKERS must be set.' | |
exit 1 | |
fi | |
k3d create --workers $1 | |
sleep 7 | |
export KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')" | |
kubectl cluster-info | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc6/aio/deploy/recommended.yaml | |
kubectl -n kubernetes-dashboard apply -f - <<EOF | |
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: admin-user | |
namespace: kubernetes-dashboard | |
--- | |
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 get secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}') -o yaml | grep "token:" | awk '{print $2}' | base64 -D) | |
echo "Please wait a few seconds. Copy token below and open http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login :" | |
echo $TOKEN | |
kubectl proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment