Skip to content

Instantly share code, notes, and snippets.

@rgaidot

rgaidot/boostrap-k3d.sh

Last active Mar 20, 2020
Embed
What would you like to do?
#!/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
You can’t perform that action at this time.