fix(cilium): use cilium lb

This commit is contained in:
Timothy Stewart
2024-07-27 12:32:22 -05:00
parent 4bee4230de
commit 15e97bad1d
3 changed files with 45 additions and 15 deletions

View File

@@ -221,10 +221,9 @@
- name: Configure Cilium BGP - name: Configure Cilium BGP
when: cilium_bgp when: cilium_bgp
block: block:
- name: Copy BGP manifests to first master - name: Copy BGP manifests to first master
ansible.builtin.template: ansible.builtin.template:
src: "cilium.crs.j2" src: "cilium-bgp.crs.j2"
dest: /tmp/k3s/cilium-bgp.yaml dest: /tmp/k3s/cilium-bgp.yaml
owner: root owner: root
group: root group: root
@@ -247,6 +246,37 @@
ansible.builtin.command: "{{ item }}" ansible.builtin.command: "{{ item }}"
loop: loop:
- k3s kubectl get CiliumBGPPeeringPolicy.cilium.io - 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 - k3s kubectl get CiliumLoadBalancerIPPool.cilium.io
changed_when: false changed_when: false
loop_control: loop_control:

View File

@@ -19,16 +19,3 @@ spec: # CiliumBGPPeeringPolicySpec
serviceSelector: serviceSelector:
matchExpressions: matchExpressions:
- {key: somekey, operator: NotIn, values: ['never-used-value']} - {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 %}

View 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 %}