Provision an on-prem Kubernetes test cluster with vagrant and ansible.
vagrant
ansible
virtualbox
For this tutorial we will make use of this fantastic repo.
Clone the repo:
git clone https://github.com/itwonderlab/ansible-vbox-vagrant-kubernetes.git && cd ansible-vbox-vagrant-kubernetes
start vagrant provisioning:
vagrant up
Once finished, create ssh tunnel with the Kubernetes master node:
ssh -L localhost:8001:127.0.0.1:8001 vagrant@192.168.50.11
Connect to the master node via vagrant ssh utility:
vagrant ssh k8s-m-1
Now we will manually deploy Kubernetes dashboard.
deploy it with the following command:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.0/aio/deploy/recommended.yaml
Create full privilege admin user:
mkdir ~/dashboard && cd ~/dashboard
create a yml file:
nano dashboard-admin.yaml
and paste 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
Deploy the admin user role:
kubectl apply -f dashboard-admin.yaml
Create admin login token
kubectl -n kubernetes-dashboard create token admin-user
start proxy:
kubectl proxy
Move to the local host, open the browser to the dashboard UI and login with the generated token:
firefox http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Create our app deployment: click on the '+' sing on the top right and select create => form
add the following data:
check the deployed app on the worker nodes: