- name: Loadbalancer | Setup '{{ microk8s_lb_provider }}'
  ansible.builtin.include_tasks: "loadbalancer/{{ microk8s_lb_provider }}.yaml"

- name: Loadbalancer | Create Loadbalancer for Nginx ingress
  environment:
    PATH: "{{ k8s_venv }}/bin:{{ ansible_env.PATH }}"
  vars:
    ansible_python_interpreter: "{{ k8s_venv }}/bin/python"
  kubernetes.core.k8s:
    state: present
    kubeconfig: "{{ k8s_kubeconfig }}"
    wait: true
    definition:
      apiVersion: v1
      kind: Service
      metadata:
        name: ingress
        namespace: ingress
      spec:
        selector:
          name: nginx-ingress-microk8s
        type: LoadBalancer
        ports:
          - name: http
            protocol: TCP
            port: "{{ microk8s_lb_http_port }}"
            targetPort: 80
          - name: https
            protocol: TCP
            port: "{{ microk8s_lb_https_port }}"
            targetPort: 443
