k0sproject / k0s

k0s - The Zero Friction Kubernetes
https://docs.k0sproject.io
Other
3.83k stars 368 forks source link

Node Local loadbalancing seemingly not working as intended on 3-node controller+worker clusters #3957

Closed Starttoaster closed 10 months ago

Starttoaster commented 10 months ago

Before creating an issue, make sure you've checked the following:

Platform

Linux 5.15.0-88-generic #98-Ubuntu SMP Mon Oct 2 15:18:56 UTC 2023 x86_64 GNU/Linux
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Version

v1.26.7+k0s.0

Sysinfo

`k0s sysinfo`
Machine ID: "f1028d6abf81c1b8b72ad4e97b70aebac34433f8629b2767f04264d6e9877937" (from machine) (pass)
Total memory: 15.2 GiB (pass)
Disk space available for /var/lib/k0s: 1.2 TiB (pass)
Operating system: Linux (pass)
  Linux kernel release: 5.15.0-88-generic (pass)
  Max. file descriptors per process: current: 1048576 / max: 1048576 (pass)
  Executable in path: modprobe: /usr/sbin/modprobe (pass)
  /proc file system: mounted (0x9fa0) (pass)
  Control Groups: version 2 (pass)
    cgroup controller "cpu": available (pass)
    cgroup controller "cpuacct": available (via cpu in version 2) (pass)
    cgroup controller "cpuset": available (pass)
    cgroup controller "memory": available (pass)
    cgroup controller "devices": available (assumed) (pass)
    cgroup controller "freezer": available (assumed) (pass)
    cgroup controller "pids": available (pass)
    cgroup controller "hugetlb": available (pass)
    cgroup controller "blkio": available (via io in version 2) (pass)
  CONFIG_CGROUPS: Control Group support: built-in (pass)
    CONFIG_CGROUP_FREEZER: Freezer cgroup subsystem: built-in (pass)
    CONFIG_CGROUP_PIDS: PIDs cgroup subsystem: built-in (pass)
    CONFIG_CGROUP_DEVICE: Device controller for cgroups: built-in (pass)
    CONFIG_CPUSETS: Cpuset support: built-in (pass)
    CONFIG_CGROUP_CPUACCT: Simple CPU accounting cgroup subsystem: built-in (pass)
    CONFIG_MEMCG: Memory Resource Controller for Control Groups: built-in (pass)
    CONFIG_CGROUP_HUGETLB: HugeTLB Resource Controller for Control Groups: built-in (pass)
    CONFIG_CGROUP_SCHED: Group CPU scheduler: built-in (pass)
      CONFIG_FAIR_GROUP_SCHED: Group scheduling for SCHED_OTHER: built-in (pass)
        CONFIG_CFS_BANDWIDTH: CPU bandwidth provisioning for FAIR_GROUP_SCHED: built-in (pass)
    CONFIG_BLK_CGROUP: Block IO controller: built-in (pass)
  CONFIG_NAMESPACES: Namespaces support: built-in (pass)
    CONFIG_UTS_NS: UTS namespace: built-in (pass)
    CONFIG_IPC_NS: IPC namespace: built-in (pass)
    CONFIG_PID_NS: PID namespace: built-in (pass)
    CONFIG_NET_NS: Network namespace: built-in (pass)
  CONFIG_NET: Networking support: built-in (pass)
    CONFIG_INET: TCP/IP networking: built-in (pass)
      CONFIG_IPV6: The IPv6 protocol: built-in (pass)
    CONFIG_NETFILTER: Network packet filtering framework (Netfilter): built-in (pass)
      CONFIG_NETFILTER_ADVANCED: Advanced netfilter configuration: built-in (pass)
      CONFIG_NETFILTER_XTABLES: Netfilter Xtables support: module (pass)
        CONFIG_NETFILTER_XT_TARGET_REDIRECT: REDIRECT target support: module (pass)
        CONFIG_NETFILTER_XT_MATCH_COMMENT: "comment" match support: module (pass)
        CONFIG_NETFILTER_XT_MARK: nfmark target and match support: module (pass)
        CONFIG_NETFILTER_XT_SET: set target and match support: module (pass)
        CONFIG_NETFILTER_XT_TARGET_MASQUERADE: MASQUERADE target support: module (pass)
        CONFIG_NETFILTER_XT_NAT: "SNAT and DNAT" targets support: module (pass)
        CONFIG_NETFILTER_XT_MATCH_ADDRTYPE: "addrtype" address type match support: module (pass)
        CONFIG_NETFILTER_XT_MATCH_CONNTRACK: "conntrack" connection tracking match support: module (pass)
        CONFIG_NETFILTER_XT_MATCH_MULTIPORT: "multiport" Multiple port match support: module (pass)
        CONFIG_NETFILTER_XT_MATCH_RECENT: "recent" match support: module (pass)
        CONFIG_NETFILTER_XT_MATCH_STATISTIC: "statistic" match support: module (pass)
      CONFIG_NETFILTER_NETLINK: module (pass)
      CONFIG_NF_CONNTRACK: Netfilter connection tracking support: module (pass)
      CONFIG_NF_NAT: module (pass)
      CONFIG_IP_SET: IP set support: module (pass)
        CONFIG_IP_SET_HASH_IP: hash:ip set support: module (pass)
        CONFIG_IP_SET_HASH_NET: hash:net set support: module (pass)
      CONFIG_IP_VS: IP virtual server support: module (pass)
        CONFIG_IP_VS_NFCT: Netfilter connection tracking: built-in (pass)
      CONFIG_NF_CONNTRACK_IPV4: IPv4 connetion tracking support (required for NAT): unknown (warning)
      CONFIG_NF_REJECT_IPV4: IPv4 packet rejection: module (pass)
      CONFIG_NF_NAT_IPV4: IPv4 NAT: unknown (warning)
      CONFIG_IP_NF_IPTABLES: IP tables support: module (pass)
        CONFIG_IP_NF_FILTER: Packet filtering: module (pass)
          CONFIG_IP_NF_TARGET_REJECT: REJECT target support: module (pass)
        CONFIG_IP_NF_NAT: iptables NAT support: module (pass)
        CONFIG_IP_NF_MANGLE: Packet mangling: module (pass)
      CONFIG_NF_DEFRAG_IPV4: module (pass)
      CONFIG_NF_CONNTRACK_IPV6: IPv6 connetion tracking support (required for NAT): unknown (warning)
      CONFIG_NF_NAT_IPV6: IPv6 NAT: unknown (warning)
      CONFIG_IP6_NF_IPTABLES: IP6 tables support: module (pass)
        CONFIG_IP6_NF_FILTER: Packet filtering: module (pass)
        CONFIG_IP6_NF_MANGLE: Packet mangling: module (pass)
        CONFIG_IP6_NF_NAT: ip6tables NAT support: module (pass)
      CONFIG_NF_DEFRAG_IPV6: module (pass)
    CONFIG_BRIDGE: 802.1d Ethernet Bridging: module (pass)
      CONFIG_LLC: module (pass)
      CONFIG_STP: module (pass)
  CONFIG_EXT4_FS: The Extended 4 (ext4) filesystem: built-in (pass)
  CONFIG_PROC_FS: /proc file system support: built-in (pass)

What happened?

I have a 3-node cluster that is comprised of 3 nodes with the Controller+Worker roles, and just tried out the relatively new node local loadbalancing feature. I see my first node is the current "leader" looking at my current leases in the kube-node-lease namespace. And I see that a single envoy Pod was deployed in kube-system for the third node in my cluster.

So I just shut down the 3rd node to test this out, which of course made envoy completely unreachable. And after about 15 minutes of waiting, the envoy loadbalancer Pod is still stuck in Terminating according to kubectl, without a new Pod being deployed. But I'm currently of the belief, looking at the documentation, that what was intended here was for all 3 of my Controller+Worker nodes to deploy their own envoy Pod. As the documentation states that all Worker nodes are meant to deploy one.

I'm not sure if this is at all relevant, but I was originally using an externalAddress loadbalancer for this cluster, and transitioned to envoy, in case that is the tiny detail that leads to what I believe is an unintended state.

Steps to reproduce

  1. Deploy a 3 node HA cluster with Controller+Worker nodes, with node local load balancing
  2. Watch it deploy a single Pod for envoy
  3. Shut down the node that envoy is deployed to
  4. Watch as nothing happens

Expected behavior

I'd have expected all 3 of my "Workers", though they also serve the Controller role, to deploy an Envoy Pod.

Actual behavior

Only the 3rd node in my cluster has the Envoy Pod even though the other two nodes are also workers.

Screenshots and logs

No response

Additional context

I checked /etc/k0s/k0s.yaml on all 3 nodes and found the nodeLocalLoadBalancing setting configured in them.

Starttoaster commented 10 months ago

In case it is useful, here is my k0sctl config (note that I do not believe this is an error with k0sctl though):

apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
  name: cluster1
spec:
  hosts:
  - openSSH:
      address: 100.85.216.39
      user: bb
      port: 22
    role: controller+worker
    installFlags:
      - --no-taints
  - openSSH:
      address: 100.72.143.21
      user: bb
      port: 22
    role: controller+worker
    installFlags:
      - --no-taints
  - openSSH:
      address: 100.81.77.109
      user: bb
      port: 22
    role: controller+worker
    installFlags:
      - --no-taints
  k0s:
    config:
      spec:
        network:
          nodeLocalLoadBalancing:
            enabled: true
            type: EnvoyProxy
    version: 1.26.7+k0s.0
    dynamicConfig: false
Starttoaster commented 10 months ago

Ah nevermind, it looks like this is actually solved in a newer version of k0s. Closing.

twz123 commented 10 months ago

As a quick side note: Wasn't able to reproduce:

$ kubectl get node,po -owide -A
NAME                         STATUS   ROLES           AGE   VERSION       INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
node/k0s-3957-controller-0   Ready    control-plane   14m   v1.26.7+k0s   172.28.170.48    <none>        Alpine Linux v3.18   6.1.62-0-virt    containerd://1.6.21
node/k0s-3957-controller-1   Ready    control-plane   13m   v1.26.7+k0s   172.28.170.205   <none>        Alpine Linux v3.18   6.1.62-0-virt    containerd://1.6.21
node/k0s-3957-controller-2   Ready    control-plane   13m   v1.26.7+k0s   172.28.170.236   <none>        Alpine Linux v3.18   6.1.62-0-virt    containerd://1.6.21

NAMESPACE     NAME                                  READY   STATUS      RESTARTS      AGE     IP               NODE                    NOMINATED NODE   READINESS GATES
kube-system   pod/coredns-7bf57bcbd8-5bl2j          0/1     Completed   0             4m24s   10.244.0.5       k0s-3957-controller-0   <none>           <none>
kube-system   pod/coredns-7bf57bcbd8-6g5rf          1/1     Running     0             13m     10.244.1.3       k0s-3957-controller-1   <none>           <none>
kube-system   pod/coredns-7bf57bcbd8-qrkvz          1/1     Running     0             4m17s   10.244.2.2       k0s-3957-controller-2   <none>           <none>
kube-system   pod/coredns-7bf57bcbd8-wctjk          0/1     Completed   0             14m     10.244.0.4       k0s-3957-controller-0   <none>           <none>
kube-system   pod/konnectivity-agent-5mz6v          1/1     Running     0             13m     172.28.170.236   k0s-3957-controller-2   <none>           <none>
kube-system   pod/konnectivity-agent-8nxm2          1/1     Running     0             13m     172.28.170.48    k0s-3957-controller-0   <none>           <none>
kube-system   pod/konnectivity-agent-kll7t          1/1     Running     0             13m     172.28.170.205   k0s-3957-controller-1   <none>           <none>
kube-system   pod/kube-proxy-8f2dn                  1/1     Running     0             13m     172.28.170.205   k0s-3957-controller-1   <none>           <none>
kube-system   pod/kube-proxy-nwhrm                  1/1     Running     0             14m     172.28.170.48    k0s-3957-controller-0   <none>           <none>
kube-system   pod/kube-proxy-phj5c                  1/1     Running     0             13m     172.28.170.236   k0s-3957-controller-2   <none>           <none>
kube-system   pod/kube-router-gdndt                 1/1     Running     0             13m     172.28.170.236   k0s-3957-controller-2   <none>           <none>
kube-system   pod/kube-router-j4b9w                 1/1     Running     0             13m     172.28.170.205   k0s-3957-controller-1   <none>           <none>
kube-system   pod/kube-router-tfmql                 1/1     Running     0             14m     172.28.170.48    k0s-3957-controller-0   <none>           <none>
kube-system   pod/metrics-server-7446cc488c-qfswk   1/1     Running     1 (12m ago)   14m     10.244.0.3       k0s-3957-controller-0   <none>           <none>
kube-system   pod/nllb-k0s-3957-controller-0        1/1     Running     0             12m     172.28.170.48    k0s-3957-controller-0   <none>           <none>
kube-system   pod/nllb-k0s-3957-controller-1        1/1     Running     0             12m     172.28.170.205   k0s-3957-controller-1   <none>           <none>
kube-system   pod/nllb-k0s-3957-controller-2        1/1     Running     0             12m     172.28.170.236   k0s-3957-controller-2   <none>           <none>