mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2025-12-28 11:42:37 +01:00
fix(cilium): use cilium lb
This commit is contained in:
@@ -221,10 +221,9 @@
|
||||
- name: Configure Cilium BGP
|
||||
when: cilium_bgp
|
||||
block:
|
||||
|
||||
- name: Copy BGP manifests to first master
|
||||
ansible.builtin.template:
|
||||
src: "cilium.crs.j2"
|
||||
src: "cilium-bgp.crs.j2"
|
||||
dest: /tmp/k3s/cilium-bgp.yaml
|
||||
owner: root
|
||||
group: root
|
||||
@@ -247,6 +246,37 @@
|
||||
ansible.builtin.command: "{{ item }}"
|
||||
loop:
|
||||
- k3s kubectl get CiliumBGPPeeringPolicy.cilium.io
|
||||
changed_when: false
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
|
||||
- name: Configure Cilium Load Balancer
|
||||
when: kube_vip_lb_ip_range is not defined and (cilium_bgp is not defined or cilium_iface is not defined)
|
||||
block:
|
||||
- name: Copy Load Balancer manifests to first master
|
||||
ansible.builtin.template:
|
||||
src: "cilium-lb.crs.j2"
|
||||
dest: /tmp/k3s/cilium-lb.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Apply BGP manifests
|
||||
ansible.builtin.command:
|
||||
cmd: kubectl apply -f /tmp/k3s/cilium-lb.yaml
|
||||
register: apply_cr
|
||||
changed_when: "'configured' in apply_cr.stdout or 'created' in apply_cr.stdout"
|
||||
failed_when: "'is invalid' in apply_cr.stderr"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Print error message if BGP manifests application fails
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ apply_cr.stderr }}"
|
||||
when: "'is invalid' in apply_cr.stderr"
|
||||
|
||||
- name: Test for LB config resources
|
||||
ansible.builtin.command: "{{ item }}"
|
||||
loop:
|
||||
- k3s kubectl get CiliumLoadBalancerIPPool.cilium.io
|
||||
changed_when: false
|
||||
loop_control:
|
||||
|
||||
@@ -19,16 +19,3 @@ spec: # CiliumBGPPeeringPolicySpec
|
||||
serviceSelector:
|
||||
matchExpressions:
|
||||
- {key: somekey, operator: NotIn, values: ['never-used-value']}
|
||||
---
|
||||
apiVersion: "cilium.io/v2alpha1"
|
||||
kind: CiliumLoadBalancerIPPool
|
||||
metadata:
|
||||
name: "01-lb-pool"
|
||||
spec:
|
||||
blocks:
|
||||
{% if "/" in cilium_bgp_lb_cidr %}
|
||||
- cidr: {{ cilium_bgp_lb_cidr }}
|
||||
{% else %}
|
||||
- start: {{ cilium_bgp_lb_cidr.split('-')[0] }}
|
||||
stop: {{ cilium_bgp_lb_cidr.split('-')[1] }}
|
||||
{% endif %}
|
||||
13
roles/k3s_server_post/templates/cilium-lb.crs.j2
Normal file
13
roles/k3s_server_post/templates/cilium-lb.crs.j2
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
apiVersion: "cilium.io/v2alpha1"
|
||||
kind: CiliumLoadBalancerIPPool
|
||||
metadata:
|
||||
name: "01-lb-pool"
|
||||
spec:
|
||||
blocks:
|
||||
{% if "/" in cilium_bgp_lb_cidr %}
|
||||
- cidr: {{ cilium_bgp_lb_cidr }}
|
||||
{% else %}
|
||||
- start: {{ cilium_bgp_lb_cidr.split('-')[0] }}
|
||||
stop: {{ cilium_bgp_lb_cidr.split('-')[1] }}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user