Skip to content

Instantly share code, notes, and snippets.

@shaposhnikoff
Forked from devnut/kind.txt
Created June 12, 2023 14:04
Show Gist options
  • Save shaposhnikoff/74ca7d7b038c5afa13dedbfc0de4c62a to your computer and use it in GitHub Desktop.
Save shaposhnikoff/74ca7d7b038c5afa13dedbfc0de4c62a to your computer and use it in GitHub Desktop.
kind setup
1. install kind:
go or go1.20.3 install sigs.k8s.io/[email protected]
2. create a 3-node worker cluster by creating a yml file like this:
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
333create kubernets cluster:
kind create cluster --name local --config <filename from #2>
3. check cluster exists:
kind get clusters # should see "local"
4. install helm:
macports or brew, in case of macports "sudo port install helm"
5. use helm to install kubernetes dashboard chart repo
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
6. verify repo is installed:
helm repo list
7. use helm to deploy kubernetes dashboard
helm install dashboard kubernetes-dashboard/kubernetes-dashboard -n kubernetes-dashboard --create-namespace
8. wait for pod to start (should be running):
kubectl get pods -n kubernetes-dashboard
9. start proxy:
export POD_NAME=$(kubectl get pods -n kubernetes-dashboard -l "app.kubernetes.io/name=kubernetes-dashboard,app.kubernetes.io/instance=dashboard" -o jsonpath="{.items[0].metadata.name}")
echo https://127.0.0.1:8443/
kubectl -n kubernetes-dashboard port-forward $POD_NAME 8443:8443
10. open dashboard, note how there is no option to skip the login (note ignore the https cert warning for now if you see one):
https://127.0.0.1:8443/#/login
11. create admin-user service account yml file, with the following content:
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
12. apply yml file:
kubectl apply -f <admin-user yml filename>
13. get dashbaord token:
kubectl create token admin-user -n kubernetes-dashboard
14. use that token to login
15. go to "nodes" in dashboard, you should see:
local-worker
local-worker2
local-control-plane
16. load docker image into cluster
kind load docker-image go_skeleton --name local
17. make sure nodes are available
kubectl get nodes
18. start bash on a worker node:
docker exec -ti local-worker bash
19. find the binary to make sure its actually on the node:
find . -name <name of binary>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment