1
0
IaC/ansible/roles/k8s_ingress_controller/tasks/main.yaml
2023-01-05 17:46:06 +10:00

61 lines
2.2 KiB
YAML

---
- name: download the ingress controller manifest
ansible.builtin.uri:
url: https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v{{ ingress_controller_version | string }}/deploy/static/provider/cloud/deploy.yaml
dest: "{{ ansible_search_path[0] }}/files/ingress_controller_v{{ ingress_controller_version }}.yaml"
creates: "{{ ansible_search_path[0] }}/files/ingress_controller_v{{ ingress_controller_version }}.yaml"
mode: 0664
- name: install ingress controller manifest to cluster
kubernetes.core.k8s:
state: present
src: "{{ ansible_search_path[0] }}/files/ingress_controller_v{{ ingress_controller_version | string }}.yaml"
- name: create replacement fact for ingress controller service
ansible.builtin.set_fact:
ingress_controller_service:
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
app.kubernetes.io/version: "{{ ingress_controller_version }}"
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
externalTrafficPolicy: Local
ipFamilyPolicy: RequireDualStack
ipFamilies:
- IPv4
- IPv6
ports:
- appProtocol: http
name: http
port: 80
protocol: TCP
targetPort: http
- appProtocol: https
name: https
port: 443
protocol: TCP
targetPort: https
selector:
app.kubernetes.io/component: controller
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/name: ingress-nginx
type: ClusterIP
- name: write out ingress controller service definition to file
ansible.builtin.copy:
content: "{{ ingress_controller_service | to_nice_yaml }}"
dest: "{{ ansible_search_path[0] }}/files/ingress_controller_service.yaml"
- name: install ingress controller manifest to cluster
kubernetes.core.k8s:
state: present
src: "{{ ansible_search_path[0] }}/files/ingress_controller_service.yaml"