summaryrefslogtreecommitdiff
path: root/roles/kubernetes/addons/ingress-nginx/tasks/main.yml
blob: db918a4d43994ce3323561376bdedbbda59e29fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
- name: deploy ingress-nginx addon
  run_once: true
  delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
  block:
  - name: create base directory for ingress-nginx addon
    file:
      path: /etc/kubernetes/addons/ingress-nginx
      state: directory

    ## you may download these using the following command:
    # wget -O deploy.{{ kubernetes_ingress_nginx_version }}.yml  https://github.com/kubernetes/ingress-nginx/raw/controller-v{{ kubernetes_ingress_nginx_version }}/deploy/static/provider/baremetal/deploy.yaml
  - name: copy base config for ingress-nginx
    copy:
      src: "deploy.{{ kubernetes_ingress_nginx_version }}.yml"
      dest: /etc/kubernetes/addons/ingress-nginx/upstream.yml

  - name: generate kustomization for ingress-nginx
    template:
      src: "kustomization.{{ kubernetes_ingress_nginx_variant }}.yml.j2"
      dest: /etc/kubernetes/addons/ingress-nginx/kustomization.yml

  - name: check if ingress-nginx is already installed
    check_mode: no
    command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -k /etc/kubernetes/addons/ingress-nginx
    failed_when: false
    changed_when: false
    register: kube_ingress_nginx_diff_result

  - name: install ingress-nginx onto the cluster
    when: kube_ingress_nginx_diff_result.rc != 0
    command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -k /etc/kubernetes/addons/ingress-nginx