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

More customisation / overrides for kube-vip #221

Open daanh432 opened 1 year ago

daanh432 commented 1 year ago

Currently it's not possible to have the announced apiserver_endpoint and actual kube-vip endpoint to differ.

With special routing and site-to-site tunnels it would be nice to have the option to override this within the configuration of this ansible-playbook.

Suggested Changes

With a simple change to the vip.yaml.j2 template overriding this would be possible and it wouldn't be an required property or breaking change to existing workflows. I can open a pull request with this change but I'm not quite familiar with the automated test tooling used just yet.

See an example for the required changes to support complex routing configurations below or in this example PR.

@@ -31,9 +31,9 @@ spec:
         - name: port
           value: "6443"
         - name: vip_interface
-          value: {{ flannel_iface }}
+          value: {{ kube_vip_iface | default(flannel_iface) }}
         - name: vip_cidr
-          value: "{{ apiserver_endpoint | ansible.utils.ipsubnet | ansible.utils.ipaddr('prefix') }}"
+          value: "{{ kube_vip_endpoint | default(apiserver_endpoint) | ansible.utils.ipsubnet | ansible.utils.ipaddr('prefix') }}"
         - name: cp_enable
           value: "true"
         - name: cp_namespace
@@ -51,7 +51,7 @@ spec:
         - name: vip_retryperiod
           value: "2"
         - name: address
-          value: {{ apiserver_endpoint }}
+          value: {{ kube_vip_endpoint | default(apiserver_endpoint) }}
         image: ghcr.io/kube-vip/kube-vip:{{ kube_vip_tag_version }}
         imagePullPolicy: Always
         name: kube-vip
# interface which will be used for flannel
flannel_iface: "eth0"

# (optional) kube_vip_iface is an optional override for the network interface kube-vip will ARP announce
kube_vip_iface: "eth0"

# apiserver_endpoint is virtual ip-address which will be configured on each master
apiserver_endpoint: "10.66.10.1"

# (optional) kube_vip_endpoint is an optional override for the internal listening endpoint for the kube-vip interface
kube_vip_endpoint: "10.66.1.5"
timothystewart6 commented 1 year ago

This was closed by https://github.com/techno-tim/k3s-ansible/pull/238 wasn't it @sleiner ?

sleiner commented 1 year ago

@timothystewart6 Part of it at least (the kube-vip interface can now be set independently of the flannel one)

bornav commented 7 months ago

Following up on the merge of #238, Is there something holding up the implementation of the example? Having known we could already specify kube_vip_iface in the vars file would have been quite useful

timothystewart6 commented 6 months ago

PRs are welcome!