Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNI Portmap Plugin issue with Talos 1.7+, breaking pod-to-service communication #9883

Closed
Tracked by #9825
donch opened this issue Dec 5, 2024 · 7 comments · Fixed by #9888
Closed
Tracked by #9825

CNI Portmap Plugin issue with Talos 1.7+, breaking pod-to-service communication #9883

donch opened this issue Dec 5, 2024 · 7 comments · Fixed by #9888
Assignees

Comments

@donch
Copy link

donch commented Dec 5, 2024

Bug Report

Description

Since Talos 1.7.0, there's an inconsistency between the iptables mode used by kubelet (nft) and the one available for CNI plugins (legacy) when using the portmap plugin. This affects setups using CNIs that rely on the portmap plugin chaining.

A critical issue has been identified where pods using hostPort 443 prevent all cluster pods from accessing any Service IP on port 443, including the Kubernetes API server.

While we suspect this is related to the missing iptables-nft binary on the Talos host, we cannot confirm this is the root cause. However, the bug is consistently reproducible.

Environment

  • Talos version: 1.7.0+ and 1.8.0
  • Kubernetes version: v1.25+
  • CNI: kube-router with portmap plugin
  • Previous working version: Talos 1.6.x

Workaround

We have found a temporary workaround for clusters running Talos 1.7+ with kube-router:

  • Remove all hostPort configurations from DaemonSets and other workloads
  • For ingress controllers specifically:
    • Switch from hostPort to hostNetwork: true
  • This workaround allows clusters to maintain functionality
  • Note: This is not a solution but a temporary mitigation until the root cause is fixed
@smira
Copy link
Member

smira commented Dec 5, 2024

I wonder if that's also the issue behind #9814 (or related).

@smira
Copy link
Member

smira commented Dec 5, 2024

Do you have a reproducing configuration we could test with?

@donch
Copy link
Author

donch commented Dec 5, 2024

Yes sure, the setup is quite simple :

  • Deploy a Talos cluster with kube-proxy enabled in v1.7.0 with ipvs mode
  • Install Kube-router from our chart we have tested with version 2.3.0 of the kube-router binary without success
  • Deploy an nginx-ingress with hostPort enabled

You should see in the kube-router logs that it can't connect to the apiserver.

@smira
Copy link
Member

smira commented Dec 5, 2024

If you have that as a series of shell commands and patches to Talos, that'd be perfect. E.g. I guess you disable Flannel.

A way for us to reproduce would make fixing this way easier.

@donch
Copy link
Author

donch commented Dec 6, 2024

Yes sure, we use talhelper to generate Talos configuration :

clusterName: k8s
talosVersion: v1.8.3
kubernetesVersion: v1.28.15
endpoint: https://10.1.22.10:6443
domain: k8s.custom
clusterPodNets:
  - 10.1.128.0/20
clusterSvcNets:
  - 10.1.200.0/24
cniConfig:
  name: none
patches:
  - "@./nodes.patch.yaml"
controlPlane:
  patches:
    - "@./etcd.patch.yaml"
    - "@./cp.patch.yaml"
  schematic:
    customization:
      systemExtensions:
        officialExtensions:
          - siderolabs/qemu-guest-agent
          - siderolabs/zfs
worker:
  patches:
    - "@./workers.patch.yaml"
  schematic:
    customization:
      systemExtensions:
        officialExtensions:
          - siderolabs/qemu-guest-agent
          - siderolabs/zfs
nodes:
...

and the interesting patches

machine:
  features:
    kubePrism:
      port: 7443
  kernel:
    modules:
      - name: zfs
  sysctls:
    user.max_user_namespaces: "11255"
  systemDiskEncryption:
    ephemeral:
      provider: luks2
      keys:
        - nodeID: {}
          slot: 0
    state:
      provider: luks2
      keys:
        - nodeID: {}
          slot: 0
cluster:
  coreDNS:
    disabled: true
  apiServer:
    admissionControl:
      - name: PodSecurity
        configuration:
          exemptions:
            namespaces:
              - qemu-guest-agent
  proxy:
    mode: ipvs

The others are about system-reserved resources. We also disable CoreDNS since we use a custom configuration

For the kube-router install, the following would be enough :
helm upgrade --install --namespace kube-system kube-router kube-router --repo https://charts.enix.io/ --set kubeRouter.cni.install=true

At this point, all should be working since there is not yet any workloads with hostPort enabled.
You can install an ingress-nginx :
helm upgrade --install --create-namespace --namespace ingress-nginx ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --set controller.hostPort.enabled=true

Once deployed the bug happen, you can try to restart kube-router pods and see connection failure to the apiserver in the logs

smira added a commit to smira/pkgs that referenced this issue Dec 6, 2024
Build iptables with nftables support, and force to use
nft version.

See siderolabs/talos#9883

Signed-off-by: Andrey Smirnov <[email protected]>
@smira
Copy link
Member

smira commented Dec 6, 2024

Thanks for detailed configuration, I confirmed that siderolabs/pkgs#1106 fixes ingress-nginx (it doesn't start without this fix properly).

@smira
Copy link
Member

smira commented Dec 6, 2024

This doesn't fix #9814 though.

smira added a commit to smira/talos that referenced this issue Dec 6, 2024
These are used by CNI plugins.

Fixes siderolabs#9883

See siderolabs/pkgs#1106

Signed-off-by: Andrey Smirnov <[email protected]>
@smira smira self-assigned this Dec 6, 2024
smira added a commit to smira/pkgs that referenced this issue Dec 9, 2024
Build iptables with nftables support, and force to use
nft version.

See siderolabs/talos#9883

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 9cf35be)
smira added a commit to smira/pkgs that referenced this issue Dec 9, 2024
Build iptables with nftables support, and force to use
nft version.

See siderolabs/talos#9883

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 9cf35be)
smira added a commit to smira/talos that referenced this issue Dec 9, 2024
These are used by CNI plugins.

Fixes siderolabs#9883

See siderolabs/pkgs#1106

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 07220fe)
smira added a commit to smira/pkgs that referenced this issue Dec 11, 2024
Build iptables with nftables support, and force to use
nft version.

See siderolabs/talos#9883

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 9cf35be)
smira added a commit to smira/talos that referenced this issue Dec 12, 2024
These are used by CNI plugins.

Fixes siderolabs#9883

See siderolabs/pkgs#1106

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 07220fe)
smira added a commit to smira/talos that referenced this issue Dec 12, 2024
These are used by CNI plugins.

Fixes siderolabs#9883

See siderolabs/pkgs#1106

Signed-off-by: Andrey Smirnov <[email protected]>
(cherry picked from commit 07220fe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants