techno-tim / k3s-ansible

The easiest way to bootstrap a self-hosted High Availability Kubernetes cluster. A fully automated HA k3s etcd install with kube-vip, MetalLB, and more. Build. Destroy. Repeat.
https://technotim.live/posts/k3s-etcd-ansible/
Apache License 2.0
2.41k stars 1.05k forks source link

MetalLB server tasks causing error when cilium is not being defined. #514

Closed Rina-Y closed 5 months ago

Rina-Y commented 5 months ago

I was running this collection via galaxy for a larger system I am setting up, and I had decided not to use cilium since it looks like it's still being worked on and went with the default flannel for now.

I only included the group_vars I needed, excluding all vars for cilium and calico. I received an error when it was trying to call the metallb tasks in both the k3s_server and k3s_server_post roles. I just quickly fixed it for myself in my collection copy, then have set up a pull request to fix it.

Here is the actual error:

FAILED! => {"msg": "The conditional check 'kube_vip_lb_ip_range is not defined and (not cilium_bgp or cilium_iface is not defined)' failed. The error was: error while evaluating conditional (kube_vip_lb_ip_range is not defined and (not cilium_bgp or cilium_iface is not defined)): 'cilium_bgp' is undefined. 'cilium_bgp' is undefined\n\nThe error appears to be in '~/.ansible/collections/ansible_collections/techno_tim/k3s_ansible/roles/k3s_server_post/tasks/main.yml': line 12, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Deploy metallb pool\n  ^ here\n"}

See #513 for the fix.

Rina-Y commented 5 months ago

Additional Information: My group_vars only included the variables that the sample said was necessary for an installation without using calico or cilium.

These are the included variables, but I used the sample values for timezone, token, and IPs.

---

k3s_version: v1.29.2+k3s1
system_timezone: "Your/Timezone"
systemd_dir: /etc/systemd/system
flannel_iface: "eth0"
apiserver_endpoint: "192.168.30.222"
k3s_token: "some-SUPER-DEDEUPER-secret-password"
k3s_node_ip: "{{ ansible_facts[(cilium_iface | default(calico_iface | default(flannel_iface)))]['ipv4']['address'] }}"
k3s_master_taint: "{{ true if groups['wvm'] | default([]) | length >= 1 else false }}"
extra_args: >-
  {{ '--flannel-iface=' + flannel_iface if calico_iface is not defined and cilium_iface is not defined else '' }}
  --node-ip={{ k3s_node_ip }}
extra_server_args: >-
  {{ extra_args }}
  {{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
  {% if calico_iface is defined or cilium_iface is defined %}
  --flannel-backend=none
  --disable-network-policy
  --cluster-cidr={{ cluster_cidr | default('10.52.0.0/16') }}
  {% endif %}
  --tls-san {{ apiserver_endpoint }}
  --disable servicelb
  --disable traefik
extra_agent_args: >-
  {{ extra_args }}
kube_vip_tag_version: "v0.7.2"
metal_lb_type: "native"
metal_lb_mode: "layer2"
metal_lb_speaker_tag_version: "v0.14.3"
metal_lb_controller_tag_version: "v0.14.3"
metal_lb_ip_range: "192.168.30.80-192.168.30.90"
group_name_master: 'control'
timothystewart6 commented 5 months ago

closed by https://github.com/techno-tim/k3s-ansible/pull/513