create_cluster.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. - name: "Create minikube Clusters"
  2. hosts: all
  3. vars:
  4. # the demo work directory
  5. work_dir: "{{ playbook_dir }}/work"
  6. # the kubeconfig directory
  7. kubeconfig_dir: "{{ work_dir }}/.kube"
  8. # the kubernetes version to use with minikube
  9. minikube_kubernetes_version: v1.21.6
  10. # the minikube home directory
  11. minikube_home_dir: "{{ work_dir }}/.minikube"
  12. # minikube profiles
  13. minikube_profiles:
  14. mgmt: # profile name and Kubernetes context name
  15. create: yes
  16. destroy: no
  17. memory: 16g # override the default memory, note the attribute name without prefix _minikube
  18. addons:
  19. - metallb
  20. lbStartIP: 192.168.64.80
  21. lbEndIP: 192.168.64.90
  22. cluster1: # profile name and Kubernetes context name
  23. create: yes
  24. destroy: no
  25. addons:
  26. - metallb
  27. lbStartIP: 192.168.64.110
  28. lbEndIP: 192.168.64.120
  29. roles:
  30. - role: kameshsampath.minikube
  31. # Some extra configurations
  32. tasks:
  33. - name: "Configure metallb"
  34. ansible.builtin.expect:
  35. command: "{{ minikube_binary }} -p {{ item.key }} addons configure metallb"
  36. responses:
  37. "-- Enter Load Balancer Start IP:": "{{ item.value.lbStartIP}}"
  38. "-- Enter Load Balancer End IP:": "{{ item.value.lbEndIP}}"
  39. loop: "{{ minikube_profiles | dict2items }}"
  40. loop_control:
  41. label: "{{ item.key }}"
  42. register: lb_setup_result
  43. when: item.value.create and not item.value.destroy