2018-09-26 04:40:24 +02:00
|
|
|
---
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Getting node labels
|
2018-09-26 04:40:24 +02:00
|
|
|
command: "kubectl get nodes -l role=ingress-controller"
|
|
|
|
|
register: nodes
|
2018-10-02 00:22:19 +02:00
|
|
|
changed_when: no
|
2018-09-26 04:40:24 +02:00
|
|
|
when: inventory_hostname == initial_master
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Printing nodes
|
2018-09-26 04:40:24 +02:00
|
|
|
debug: var=nodes
|
|
|
|
|
when: inventory_hostname == initial_master
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Labelling proxy nodes with role=ingress-controller
|
2018-09-26 04:40:24 +02:00
|
|
|
command: "kubectl label node {{ hostvars[item].ansible_hostname }} role=ingress-controller"
|
|
|
|
|
with_items:
|
|
|
|
|
- "{{ groups['k8s_proxy'] }}"
|
|
|
|
|
when:
|
|
|
|
|
- inventory_hostname == initial_master
|
|
|
|
|
- hostvars[item].ansible_hostname not in nodes.stdout
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Templating manifests
|
2018-09-26 04:40:24 +02:00
|
|
|
template:
|
|
|
|
|
src: "{{ item }}"
|
|
|
|
|
dest: "/tmp/{{ item | regex_replace('.j2', '') }}"
|
|
|
|
|
with_items:
|
|
|
|
|
- default-backend-controller.yml.j2
|
|
|
|
|
- default-backend-service.yml.j2
|
2018-10-02 00:22:19 +02:00
|
|
|
- traefik-ingress-clusterolebinding.yml.j2
|
|
|
|
|
- traefik-ingress-configmap.yml.j2
|
|
|
|
|
- traefik-ingress-sa.yml.j2
|
|
|
|
|
- traefik-ingress-clusterole.yml.j2
|
|
|
|
|
- traefik-ingress-ds.yml.j2
|
|
|
|
|
- traefik-ingress-service.yml.j2
|
2018-09-26 04:40:24 +02:00
|
|
|
when: inventory_hostname == initial_master
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Deploy the nginx_ingress_controller
|
2018-09-26 04:40:24 +02:00
|
|
|
kube:
|
2018-10-02 00:22:19 +02:00
|
|
|
filename: "{{ item }}"
|
2018-09-26 04:40:24 +02:00
|
|
|
state: latest
|
|
|
|
|
with_items:
|
2018-10-02 00:22:19 +02:00
|
|
|
- '/tmp/default-backend-controller.yml'
|
|
|
|
|
- '/tmp/default-backend-service.yml'
|
|
|
|
|
- '/tmp/traefik-ingress-clusterolebinding.yml'
|
|
|
|
|
- '/tmp/traefik-ingress-configmap.yml'
|
|
|
|
|
- '/tmp/traefik-ingress-clusterole.yml'
|
|
|
|
|
- '/tmp/traefik-ingress-sa.yml'
|
|
|
|
|
- '/tmp/traefik-ingress-ds.yml'
|
|
|
|
|
- '/tmp/traefik-ingress-service.yml'
|
2018-09-26 04:40:24 +02:00
|
|
|
when: inventory_hostname == initial_master
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Creating directory for scaleway-ipmove
|
2018-09-26 04:40:24 +02:00
|
|
|
file:
|
|
|
|
|
path: /usr/local/bin/scaleway-ipmove
|
|
|
|
|
state: directory
|
|
|
|
|
when: "'k8s_proxy' in group_names"
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Getting scaleway-ipmove.py
|
2018-09-26 04:40:24 +02:00
|
|
|
git:
|
|
|
|
|
repo: https://github.com/chmod666org/scaleway-ipmove
|
|
|
|
|
dest: /usr/local/bin/scaleway-ipmove
|
|
|
|
|
force: yes
|
|
|
|
|
when: "'k8s_proxy' in group_names"
|
|
|
|
|
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | notify.sh
|
2018-09-26 04:40:24 +02:00
|
|
|
template:
|
|
|
|
|
src: notify.sh.j2
|
|
|
|
|
dest: /usr/local/bin/scaleway-ipmove/notify.sh
|
|
|
|
|
mode: 0500
|
|
|
|
|
owner: root
|
|
|
|
|
group: root
|
|
|
|
|
when: "'k8s_proxy' in group_names"
|
|
|
|
|
|
|
|
|
|
# this runs keepalived on proxy nodes
|
2018-10-02 00:22:19 +02:00
|
|
|
- name: traefik-ingress-controller | Templating keepalived on proxy node
|
2018-09-26 04:40:24 +02:00
|
|
|
template:
|
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
|
with_items:
|
|
|
|
|
- { 'src': 'keepalived.yml.j2', 'dest': '/etc/kubernetes/manifests/keepalived.yml' }
|
|
|
|
|
when:
|
|
|
|
|
- "'k8s_proxy' in group_names"
|
|
|
|
|
- groups.k8s_proxy|length > 1
|