Created
September 16, 2020 17:38
-
-
Save junqueira/f1bd9f1a955a1bbd8696b5bdc28e4830 to your computer and use it in GitHub Desktop.
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
| #start-KinD: Kubernetes made easy in a container | |
| # wsl --import mk8s C:\wsldistros\mk8s C:\wslsources\focal.tar.gz --version 2 | |
| # wsl --set-default-version 2 | |
| # wsl --set-default Ubuntu-20.04 | |
| # Download the latest version of KinD | |
| sudo apt update && apt upgrade -y | |
| # curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-$(uname)-amd64 | |
| curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.8.1/kind-$(uname)-amd64 | |
| # Make the binary executable | |
| chmod +x ./kind | |
| # Move the binary to your executable path | |
| sudo mv ./kind /usr/local/bin/ | |
| # Check if the KUBECONFIG is not set | |
| echo $KUBECONFIG | |
| # Check if the .kube directory is created > if not, no need to create it | |
| ls $HOME/.kube | |
| # Create the cluster and give it a name (optional) | |
| kind delete cluster -v 9 | |
| kind delete cluster --name wslkind | |
| kind create cluster --name wslkind | |
| # Check if the .kube has been created and populated with files | |
| ls $HOME/.kube | |
| # Check how many nodes it created | |
| kubectl get nodes | |
| # Check the services for the whole cluster | |
| kubectl get all --all-namespaces | |
| # Create a config file for a 3 nodes cluster | |
| cat << EOF > kind-3nodes.yaml | |
| kind: Cluster | |
| apiVersion: kind.x-k8s.io/v1alpha4 | |
| nodes: | |
| - role: control-plane | |
| - role: worker | |
| - role: worker | |
| EOF | |
| # Create a new cluster with the config file | |
| kind delete cluster --name wslkindmultinodes | |
| kind create cluster --name wslkindmultinodes --config ./kind-3nodes.yaml | |
| # Check how many nodes it created | |
| kubectl get nodes | |
| # Check the services for the whole cluster | |
| kubectl get all --all-namespaces | |
| # Install the Dashboard application into our cluster | |
| kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc6/aio/deploy/recommended.yaml | |
| # Check the resources it created based on the new namespace created | |
| kubectl get all -n kubernetes-dashboard | |
| # Create a new ServiceAccount | |
| kubectl apply -f - <<EOF | |
| apiVersion: v1 | |
| kind: ServiceAccount | |
| metadata: | |
| name: admin-user | |
| namespace: kubernetes-dashboard | |
| EOF | |
| # Create a ClusterRoleBinding for the ServiceAccount | |
| 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 | |
| # Get the Token for the ServiceAccount | |
| kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}') | |
| # Copy the token and copy it into the Dashboard login and press "Sign in" | |
| # Start a kubectl proxy | |
| echo Enter the URL on your browser: | |
| echo http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ | |
| kubectl proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment