mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 13:46:59 +01:00
98 lines
3.5 KiB
YAML
98 lines
3.5 KiB
YAML
|
|
---
|
||
|
|
- name: nginx_ingress_controller | Getting node labels
|
||
|
|
command: "kubectl get nodes -l role=ingress-controller"
|
||
|
|
register: nodes
|
||
|
|
when: inventory_hostname == initial_master
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Printing nodes
|
||
|
|
debug: var=nodes
|
||
|
|
when: inventory_hostname == initial_master
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Labelling proxy nodes with role=ingress_controller
|
||
|
|
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
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Templating manifests
|
||
|
|
template:
|
||
|
|
src: "{{ item }}"
|
||
|
|
dest: "/tmp/{{ item | regex_replace('.j2', '') }}"
|
||
|
|
with_items:
|
||
|
|
- default-backend-controller.yml.j2
|
||
|
|
- default-backend-service.yml.j2
|
||
|
|
- nginx-ingress-clusterolebinding.yml.j2
|
||
|
|
- nginx-ingress-configmap.yml.j2
|
||
|
|
- nginx-ingress-sa.yml.j2
|
||
|
|
- nginx-ingress-clusterole.yml.j2
|
||
|
|
- nginx-ingress-controller.yml.j2
|
||
|
|
- nginx-ingress-service.yml.j2
|
||
|
|
when: inventory_hostname == initial_master
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Deploy the nginx_ingress_controller
|
||
|
|
kube:
|
||
|
|
name: "{{ item.name }}"
|
||
|
|
resource: "{{ item.type }}"
|
||
|
|
filename: "{{ item.file }}"
|
||
|
|
state: latest
|
||
|
|
with_items:
|
||
|
|
- { 'name': 'default-http-backend', 'type': 'deploy', 'file': '/tmp/default-backend-controller.yml' }
|
||
|
|
- { 'name': 'default-http-backend', 'type': 'svc', 'file': '/tmp/default-backend-service.yml' }
|
||
|
|
- { 'name': 'ingress', 'type': 'clusterrolebinding', 'file': '/tmp/nginx-ingress-clusterolebinding.yml' }
|
||
|
|
- { 'name': 'system:ingress', 'type': 'clusterrole', 'file': '/tmp/nginx-ingress-clusterole.yml' }
|
||
|
|
- { 'name': 'ingress', 'type': 'sa', 'file': '/tmp/nginx-ingress-sa.yml' }
|
||
|
|
- { 'name': 'nginx-ingress-cfg', 'type': 'configmap', 'file': '/tmp/nginx-ingress-configmap.yml' }
|
||
|
|
- { 'name': 'nginx-ingress-controller', 'type': 'deploy', 'file': '/tmp/nginx-ingress-controller.yml' }
|
||
|
|
- { 'name': 'nginx-ingress', 'type': 'svc', 'file': '/tmp/nginx-ingress-service.yml' }
|
||
|
|
when: inventory_hostname == initial_master
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Removing manifest
|
||
|
|
file:
|
||
|
|
path: "/tmp/{{ item }}"
|
||
|
|
state: absent
|
||
|
|
with_items:
|
||
|
|
- default-backend-controller.yml
|
||
|
|
- default-backend-service.yml
|
||
|
|
- nginx-ingress-clusterolebinding.yml
|
||
|
|
- nginx-ingress-configmap.yml
|
||
|
|
- nginx-ingress-sa.yml
|
||
|
|
- nginx-ingress-clusterole.yml
|
||
|
|
- nginx-ingress-controller.yml
|
||
|
|
- nginx-ingress-service.yml
|
||
|
|
when: inventory_hostname == initial_master
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Creating directory for scaleway-ipmove
|
||
|
|
file:
|
||
|
|
path: /usr/local/bin/scaleway-ipmove
|
||
|
|
state: directory
|
||
|
|
when: "'k8s_proxy' in group_names"
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | Getting scaleway-ipmove.py
|
||
|
|
git:
|
||
|
|
repo: https://github.com/chmod666org/scaleway-ipmove
|
||
|
|
dest: /usr/local/bin/scaleway-ipmove
|
||
|
|
force: yes
|
||
|
|
when: "'k8s_proxy' in group_names"
|
||
|
|
|
||
|
|
- name: nginx_ingress_controller | notify.sh
|
||
|
|
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
|
||
|
|
- name: nginx_ingress_controller | Templating keepalived on proxy node
|
||
|
|
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
|