The ansible playbook is based on Kubernetes setup with CRI-O Runtime
I have also added a storage with iSCSI and NFS share and a MetalLB load balancer.
If you need a kubernetes bare-matal using kvm vm check the k8s-kvm project
See the inventory file
Check if all hosts are availabe:
$ ansible -i inventories/lab.yml -m ping allExecute the playbook
$ ansible-playbook -i inventories/lab.yml main.ymlThe kubectl config file is localted in the master node as /etc/kubernetes/admin.conf
Checking the cluster's nodes
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 3m43s v1.21.2
k8s-worker1 Ready <none> 3m18s v1.21.2
k8s-worker2 Ready <none> 3m18s v1.21.2Check the NFS/iSCI server ( execute the commands inside the host )
$ sudo exportfs -s
/data 192.168.123.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)
$ sudo iscsiadm -m discovery -t st -p 192.168.123.63
192.168.123.64:3260,1 iqn.2020-07.lab.com:lun1Install Traefik Ingress
$ helm repo add traefik https://helm.traefik.io/traefik
$ helm repo update
$ helm install traefik traefik/traefikdeploy the application
$ kubectl apply -f demos/ingress-traefik/Get the load balancer IP
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 82m
traefik LoadBalancer 10.96.144.154 192.168.123.250 80:31272/TCP,443:30990/TCP 4m1s
whoami ClusterIP 10.110.70.160 <none> 80/TCP 5m19sTest the application
$ curl 192.168.123.250Install Nginx Ingress
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.0/deploy/static/provider/baremetal/deploy.yamldeploy the application
$ kubectl apply -f demos/ingress-nginx/Get the load balancer IP
$ kubectl -n ingress-nginx get svc ingress-nginx-controller
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller LoadBalancer 10.99.148.104 192.168.123.250 80:31644/TCP,443:30111/TCP 6m31sTest the application
$ curl http://192.168.123.250/apple
apple
$ curl http://192.168.123.250/banana
banana