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

failed to assign an IP address to container #2749

Closed
AlissonRS opened this issue Jan 10, 2024 · 24 comments
Closed

failed to assign an IP address to container #2749

AlissonRS opened this issue Jan 10, 2024 · 24 comments

Comments

@AlissonRS
Copy link

What happened:

I enabled prefix delegation to get more pods per node following the steps here but it seems like this is not working well. I'm using Karpenter (not sure if that is relevant), the error message in pod is as below:

(combined from similar events): Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "7a06aebe8f02365c3e78f0c58a5b8f9cbde85e5ee15b5ef8df1d32d1c17291bf": plugin type="aws-cni" name="aws-cni" failed (add): add cmd: failed to assign an IP address to container

I searched for this error, went through other posts (e.g. #1480, #2411) but it doesn't seem like that's my issue. This is a brand new instance, and my subnets are used exclusively for this EKS cluster, from which all nodes are provisioned by Karpenter using the CNI setup with max-pods, so I don't think there could be a subnet IP fragmentation (but I'm also not sure how to debug this).

The relevant env vars are set:

kubectl -n kube-system describe pod aws-node-bdzwn | grep -i prefix
      AWS_VPC_K8S_CNI_VETHPREFIX:             eni
      ENABLE_PREFIX_DELEGATION:               true
      WARM_PREFIX_TARGET:                     1

My subnet has enough IPs:

image

I c onfigured max pods:

kubectl describe node ip-10-0-10-34.ec2.internal | grep 'pods\|PrivateIPv4Address'
                    karpenter.k8s.aws/instance-pods=110
  pods:               110
  pods:               110

The max pods calculator suggests the instance type (c6a.large) should have 29 pods, or 110 with prefix delegation:

./max-pods-calculator.sh --instance-type c6a.large --cni-version 1.16.0-eksbuild.1 --cni-prefix-delegation-enabled
110

Which is funny, as the node seems to have 32 IPs assigned rather than 29, so it's unclear whether the prefix delegation is working here or not.

I ran /opt/cni/bin/aws-cni-support.sh on the node and sent it via email to [email protected].

Also run this:

[root@ip-10-0-10-34 aws-routed-eni]# curl http://localhost:61679/v1/enis | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12129    0 12129    0     0  11.5M      0 --:--:-- --:--:-- --:--:-- 11.5M
{
    "AssignedIPs": 32,
    "ENIs": {
        "eni-0c55f88c3e7409059": {
            "AvailableIPv4Cidrs": {
                "10.0.10.160/28": {
                    "AddressFamily": "",
                    "Cidr": {
                        "IP": "10.0.10.160",
                        "Mask": "////8A=="
                    },
                    "IPAddresses": {
                        "10.0.10.160": {
                            "Address": "10.0.10.160",
                            "AssignedTime": "2024-01-10T13:12:36.50106405Z",
                            "IPAMKey": {
                                "containerID": "8f4f7e817d896179de73dcf75e6fded89024009395978b9a751ef75c1f4078df",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "flokifi-sync-vaults-worker-6f47bbfcb6-sbwxv",
                                "k8sPodNamespace": "flokifi-backend"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.161": {
                            "Address": "10.0.10.161",
                            "AssignedTime": "2024-01-10T03:22:01.52714387Z",
                            "IPAMKey": {
                                "containerID": "f9ee67bbea0bd1ee9392efa2e662fb879990c1f5deb382e51f1892f75c58d5c8",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-tempo-compactor-8577687df7-t5rvn",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.162": {
                            "Address": "10.0.10.162",
                            "AssignedTime": "2024-01-10T03:22:01.544011298Z",
                            "IPAMKey": {
                                "containerID": "91bee35f8b40e078ba1458fd738debe9959fdd2f0d892facc93fcdd0a8ffafb4",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-kube-prometheus-operator-7d544dd55b-fb94t",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.163": {
                            "Address": "10.0.10.163",
                            "AssignedTime": "2024-01-10T03:25:12.506107347Z",
                            "IPAMKey": {
                                "containerID": "369ca5a23a37cb054ad3ee1cf4c23c8e19f79b81188e40d67244276b95f163af",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "argocd-server-c9bc98549-ljmzg",
                                "k8sPodNamespace": "argocd"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.164": {
                            "Address": "10.0.10.164",
                            "AssignedTime": "2024-01-10T03:22:02.570447031Z",
                            "IPAMKey": {
                                "containerID": "a2cb236324633edf2ea74899f86b2fad9148440cffe865c89f2eaa21042e2c87",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "external-secrets-cert-controller-5dd4bc9d64-khnwp",
                                "k8sPodNamespace": "external-secrets"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.165": {
                            "Address": "10.0.10.165",
                            "AssignedTime": "2024-01-10T03:22:02.579200416Z",
                            "IPAMKey": {
                                "containerID": "7baee3de4322ae27b435f589a51ee6766755a15e6515f4731093ccc0ccb00e5c",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "floki-lps-78799bb785-c77ms",
                                "k8sPodNamespace": "floki-lps"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.166": {
                            "Address": "10.0.10.166",
                            "AssignedTime": "2024-01-10T03:22:02.601621264Z",
                            "IPAMKey": {
                                "containerID": "90e395182b8e0dfd1816c311a5e5b6252d9904917f42a861ec0ae778303683ca",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "tokenfi-flokipad-577d555d48-gsfdn",
                                "k8sPodNamespace": "tokenfi-flokipad"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.167": {
                            "Address": "10.0.10.167",
                            "AssignedTime": "2024-01-10T03:22:02.654292255Z",
                            "IPAMKey": {
                                "containerID": "36bc90f5e1bc6cdd6ac4ca608bcdab4a4f36b83001fd3298189b1d1d8e2dcdb0",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "upbound-provider-family-aws-a21eb1597cf1-8575d6b9f7-s5nhg",
                                "k8sPodNamespace": "crossplane-system"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.168": {
                            "Address": "10.0.10.168",
                            "AssignedTime": "2024-01-10T03:22:03.598161871Z",
                            "IPAMKey": {
                                "containerID": "ed579c5479b123d1da993e0703cbd54b9514a0d1b1e04c8f8d56f6b8720f8093",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-grafana-agent-operator-6468dd7796-zxkln",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.169": {
                            "Address": "10.0.10.169",
                            "AssignedTime": "2024-01-10T03:22:03.673819891Z",
                            "IPAMKey": {
                                "containerID": "0e4a723b743141a5517a88eeffd4f89a9d1bff7c08ee536ef5635c4f2205fbc4",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "floki-university-backend-api-7884c47c9-wrd4m",
                                "k8sPodNamespace": "floki-university-backend"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.170": {
                            "Address": "10.0.10.170",
                            "AssignedTime": "2024-01-10T03:22:03.793097563Z",
                            "IPAMKey": {
                                "containerID": "2e754ab366dc32f2d17e775c7ee10ff9f8805c0e803b00fc98b42d17504f6d3f",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "argocd-repo-server-75bcc85496-twc28",
                                "k8sPodNamespace": "argocd"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.171": {
                            "Address": "10.0.10.171",
                            "AssignedTime": "2024-01-10T03:22:05.025138893Z",
                            "IPAMKey": {
                                "containerID": "1788a45b669b5204e660d5cb07c056de199df116f698c3fe41abe4ace1678b7f",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "tokenfi-flokipad-9bd74bc68-pzh5h",
                                "k8sPodNamespace": "tokenfi-flokipad"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.172": {
                            "Address": "10.0.10.172",
                            "AssignedTime": "2024-01-10T14:06:10.498360598Z",
                            "IPAMKey": {
                                "containerID": "7cbf64a223d79d3498f4051f0ca24ce64aa7e2ce7e2fccf3ba63984d753434c7",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "flokifi-fetch-prices-worker-799c54594d-gxmz4",
                                "k8sPodNamespace": "flokifi-backend"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.173": {
                            "Address": "10.0.10.173",
                            "AssignedTime": "2024-01-10T03:22:08.895174574Z",
                            "IPAMKey": {
                                "containerID": "3ef57d3c5c85b84a7ea25ced2e2279429b9c093a0268c2f4412add517f8e7ec8",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-kube-state-metrics-74f4d8858f-b4nl7",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.174": {
                            "Address": "10.0.10.174",
                            "AssignedTime": "2024-01-10T03:22:09.036991546Z",
                            "IPAMKey": {
                                "containerID": "5d6bd07e79166216d0f06bbc9a4629e64f2d53960c7aad3325a8c4a5a7e80e66",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "loki-canary-rgkmf",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.175": {
                            "Address": "10.0.10.175",
                            "AssignedTime": "2024-01-10T03:22:09.078877432Z",
                            "IPAMKey": {
                                "containerID": "b269787c54954b58e0e6c70765060c7666efb29cb87be487248ba8ed49121ea2",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "rabbitmq-rabbitmq-messaging-topology-operator-8dfd84cc4-j56gz",
                                "k8sPodNamespace": "rabbitmq"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        }
                    },
                    "IsPrefix": true
                },
                "10.0.10.176/28": {
                    "AddressFamily": "",
                    "Cidr": {
                        "IP": "10.0.10.176",
                        "Mask": "////8A=="
                    },
                    "IPAddresses": {
                        "10.0.10.176": {
                            "Address": "10.0.10.176",
                            "AssignedTime": "2024-01-10T03:22:08.930432188Z",
                            "IPAMKey": {
                                "containerID": "c02a10661a03596f95029cbc68af736e9a45ff138651c80721aa823585562e92",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-tempo-query-frontend-6897c868d6-snmwz",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.177": {
                            "Address": "10.0.10.177",
                            "AssignedTime": "2024-01-10T03:22:09.189365798Z",
                            "IPAMKey": {
                                "containerID": "07914e64109f297238df9ac49f14239e59e213f52ba6223933a2100b3ddb13fe",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "argocd-applicationset-controller-5c4944cf58-8fflc",
                                "k8sPodNamespace": "argocd"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.178": {
                            "Address": "10.0.10.178",
                            "AssignedTime": "2024-01-10T03:22:09.560657571Z",
                            "IPAMKey": {
                                "containerID": "6d308c67690e013a1d438b4445655f02151f6e676328b9915b8700e689253d3b",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "rabbitmq-rabbitmq-cluster-operator-5c8467c668-bbgvw",
                                "k8sPodNamespace": "rabbitmq"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.179": {
                            "Address": "10.0.10.179",
                            "AssignedTime": "2024-01-10T03:22:09.56962872Z",
                            "IPAMKey": {
                                "containerID": "276037bb16da56b2d1dcb9d1e24704018456062a8fa96979bd03df4ebd642815",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "external-secrets-6977b958d4-s696t",
                                "k8sPodNamespace": "external-secrets"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.180": {
                            "Address": "10.0.10.180",
                            "AssignedTime": "2024-01-10T03:22:10.274437894Z",
                            "IPAMKey": {
                                "containerID": "b9c8a9edbcd1658a2cf2058b823bcb3f59cae74aa954e73ecb1babc79864420a",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "floki-github-app-659d5d888c-tj8bz",
                                "k8sPodNamespace": "floki-github-app"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.181": {
                            "Address": "10.0.10.181",
                            "AssignedTime": "2024-01-10T03:22:10.276230289Z",
                            "IPAMKey": {
                                "containerID": "06d3efafb51006bf4307a1c2b3734a5366c7977dd4c1440e2224ad03424cd089",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "argocd-dex-server-59ccd9b499-chqc7",
                                "k8sPodNamespace": "argocd"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.182": {
                            "Address": "10.0.10.182",
                            "AssignedTime": "2024-01-10T03:22:10.301838761Z",
                            "IPAMKey": {
                                "containerID": "6c8f2e5f9c1c8167ccb58b012eed54b5f26422c5c9df150e7423d61a6c327c71",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "crossplane-86dd5d68bd-wpkjj",
                                "k8sPodNamespace": "crossplane-system"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.183": {
                            "Address": "10.0.10.183",
                            "AssignedTime": "2024-01-10T03:22:10.375291216Z",
                            "IPAMKey": {
                                "containerID": "afc352dfe985729205401fe114eacb3c273b1d582dc62729c8a4a812a790e06b",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "ebs-csi-node-j4nd4",
                                "k8sPodNamespace": "kube-system"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.184": {
                            "Address": "10.0.10.184",
                            "AssignedTime": "2024-01-10T03:22:10.390596253Z",
                            "IPAMKey": {
                                "containerID": "ac48d1b680204e373da79efe53342717fc2d220fd08aedf80aa41308571fa46c",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "crossplane-rbac-manager-645d8d7f4d-f5lqw",
                                "k8sPodNamespace": "crossplane-system"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.185": {
                            "Address": "10.0.10.185",
                            "AssignedTime": "2024-01-10T03:22:15.119929681Z",
                            "IPAMKey": {
                                "containerID": "bcfb306151bb4f4b20755a7a1e9c71b3e242fb8f9de82923ee3b22596cafbac8",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-grafana-846f5d4557-49kbc",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.186": {
                            "Address": "10.0.10.186",
                            "AssignedTime": "2024-01-10T03:22:15.131883289Z",
                            "IPAMKey": {
                                "containerID": "383c8411a3844534cf45365507abf55d99ac846e010fb029398d6ca61dd80c3e",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "default-dbc7f981d81f-86c7cb99b9-hm8vd",
                                "k8sPodNamespace": "crossplane-system"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.187": {
                            "Address": "10.0.10.187",
                            "AssignedTime": "2024-01-10T03:22:15.380198068Z",
                            "IPAMKey": {
                                "containerID": "4d2700db08a9a24a402995cf9c528eaa2fa6ce12a58319fd90a76caeb061e5b4",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-promtail-sn5wx",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.188": {
                            "Address": "10.0.10.188",
                            "AssignedTime": "2024-01-10T03:22:15.407014523Z",
                            "IPAMKey": {
                                "containerID": "4520b831c067c49e6aa17605485fd4fc927dc196e9d9d97e55e2586ca26aa1b0",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-loki-logs-btqs9",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.189": {
                            "Address": "10.0.10.189",
                            "AssignedTime": "2024-01-10T03:25:53.504038148Z",
                            "IPAMKey": {
                                "containerID": "87fb1094bc4c38185f59355f8c62742f3ab17e9bdbac5ad8e68fee63d613785e",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "argocd-notifications-controller-84588546bf-g8c7n",
                                "k8sPodNamespace": "argocd"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.190": {
                            "Address": "10.0.10.190",
                            "AssignedTime": "2024-01-10T03:22:16.02836366Z",
                            "IPAMKey": {
                                "containerID": "35017b56d79dbce94dbe6846394c5402c1c59018ba3e8a42dda2cd5672810c47",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "loki-gateway-68b5c4f49d-gq8cn",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        },
                        "10.0.10.191": {
                            "Address": "10.0.10.191",
                            "AssignedTime": "2024-01-10T03:22:16.114681623Z",
                            "IPAMKey": {
                                "containerID": "e71d8569799a6d8d7e28498ec8bdd8361e5ce6d537a5fad2bf5c39475094a5a6",
                                "ifName": "eth0",
                                "networkName": "aws-cni"
                            },
                            "IPAMMetadata": {
                                "k8sPodName": "monitoring-opentelemetry-collector-7bb98ff5f7-wbk6n",
                                "k8sPodNamespace": "monitoring"
                            },
                            "UnassignedTime": "0001-01-01T00:00:00Z"
                        }
                    },
                    "IsPrefix": true
                }
            },
            "DeviceNumber": 0,
            "ID": "eni-0c55f88c3e7409059",
            "IPv6Cidrs": {},
            "IsEFA": false,
            "IsPrimary": true,
            "IsTrunk": false
        }
    },
    "TotalIPs": 32
}

image

Environment:

  • Kubernetes version (use kubectl version):
Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.4-eks-8cb36c9
  • CNI Version: v1.16.0-eksbuild.1
  • OS (e.g: cat /etc/os-release):
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
SUPPORT_END="2025-06-30"
  • Kernel (e.g. uname -a): Linux ip-10-0-10-34.ec2.internal 5.10.201-191.748.amzn2.x86_64 #1 SMP Mon Nov 27 18:28:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

@AlissonRS we will take a look at the node logs soon and update you with what we find

@AlissonRS
Copy link
Author

@jdn5126 I was taking at look at the logs, under var_log/user_data.log I found this line:

2024-01-10T02:59:33+0000 [eks-bootstrap] INFO: --container-runtime='containerd'
2024-01-10T02:59:33+0000 [eks-bootstrap] INFO: --dns-cluster-ip='172.20.0.10'
2024-01-10T02:59:33+0000 [eks-bootstrap] INFO: --use-max-pods='false'
2024-01-10T02:59:33+0000 [eks-bootstrap] INFO: --kubelet-extra-args='--node-labels="karpenter.sh/capacity-type=spot,karpenter.sh/provisioner-name=default" --max-pods=110'
2024-01-10T02:59:34+0000 [eks-bootstrap] INFO: Using kubelet version 1.28.3
2024-01-10T02:59:34+0000 [eks-bootstrap] INFO: Using containerd as the container runtime

Could --use-max-pods='false' be the issue? And if yes, how can I fix it?

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

Kubelet seems fine. From the latest IPAMD logs, I see that all IPs are in use:

{"level":"debug","ts":"2024-01-10T20:47:34.235Z","caller":"ipamd/ipamd.go:2141","msg":"Prefix pool stats: Total IPs/Prefixes = 32/2, AssignedIPs/CooldownIPs: 32/0, c.maxIPsPerENI = 144"}

So IPAM is trying to increase the IP pool through this chain:

{"level":"debug","ts":"2024-01-10T20:46:28.541Z","caller":"ipamd/ipamd.go:632","msg":"IP pool is too low: available (0) < ENI target (1) * addrsPerENI (16)"}
{"level":"debug","ts":"2024-01-10T20:46:28.541Z","caller":"ipamd/ipamd.go:2141","msg":"Prefix pool stats: Total IPs/Prefixes = 32/2, AssignedIPs/CooldownIPs: 32/0, c.maxIPsPerENI = 144"}
{"level":"debug","ts":"2024-01-10T20:46:28.541Z","caller":"ipamd/ipamd.go:633","msg":"Starting to increase pool size"}
{"level":"debug","ts":"2024-01-10T20:46:28.541Z","caller":"ipamd/ipamd.go:756","msg":"Prefix target is 1, short of 1 prefixes, free 0 prefixes"}
{"level":"debug","ts":"2024-01-10T20:46:28.541Z","caller":"ipamd/ipamd.go:767","msg":"Node found \"ip-10-0-10-34.ec2.internal\" - no of taints - 0"}
{"level":"debug","ts":"2024-01-10T20:46:28.542Z","caller":"ipamd/ipamd.go:881","msg":"Prefix target is 1, short of 1 prefixes, free 0 prefixes"}
{"level":"debug","ts":"2024-01-10T20:46:28.542Z","caller":"ipamd/ipamd.go:2207","msg":"Prefix target is 1, short of 1 prefixes, free 0 prefixes"}
{"level":"debug","ts":"2024-01-10T20:46:28.542Z","caller":"ipamd/ipamd.go:994","msg":"ToAllocate: 1"}
{"level":"debug","ts":"2024-01-10T20:46:28.542Z","caller":"ipamd/ipamd.go:997","msg":"Found ENI eni-0c55f88c3e7409059 that has less than the maximum number of IP/Prefixes addresses allocated: cur=2, max=9"}
{"level":"info","ts":"2024-01-10T20:46:28.542Z","caller":"ipamd/ipamd.go:1001","msg":"Trying to allocate 1 IP addresses on ENI eni-0c55f88c3e7409059"}
{"level":"debug","ts":"2024-01-10T20:46:28.542Z","caller":"ipamd/ipamd.go:1001","msg":"PD enabled - true"}
{"level":"info","ts":"2024-01-10T20:46:28.543Z","caller":"rpc/rpc.pb.go:731","msg":"Received DelNetwork for Sandbox a4be6366434ddfc1790a26a89d5e23cab6513bdb42fbb576dd4a33b6b6fe14ee"}
{"level":"debug","ts":"2024-01-10T20:46:28.543Z","caller":"rpc/rpc.pb.go:731","msg":"DelNetworkRequest: K8S_POD_NAME:\"flokifi-upkeep-locker-cronjob-28414280-v4gwd\"  K8S_POD_NAMESPACE:\"flokifi-backend\"  K8S_POD_INFRA_CONTAINER_ID:\"a4be6366434ddfc1790a26a89d5e23cab6513b
{"level":"debug","ts":"2024-01-10T20:46:28.543Z","caller":"ipamd/rpc_handler.go:260","msg":"UnassignPodIPAddress: IP address pool stats: total 32, assigned 32, sandbox aws-cni/a4be6366434ddfc1790a26a89d5e23cab6513bdb42fbb576dd4a33b6b6fe14ee/eth0"}
{"level":"debug","ts":"2024-01-10T20:46:28.543Z","caller":"ipamd/rpc_handler.go:260","msg":"UnassignPodIPAddress: Failed to find IPAM entry under full key, trying CRI-migrated version"}
{"level":"warn","ts":"2024-01-10T20:46:28.543Z","caller":"ipamd/rpc_handler.go:260","msg":"UnassignPodIPAddress: Failed to find sandbox _migrated-from-cri/a4be6366434ddfc1790a26a89d5e23cab6513bdb42fbb576dd4a33b6b6fe14ee/unknown"}
{"level":"info","ts":"2024-01-10T20:46:28.543Z","caller":"rpc/rpc.pb.go:731","msg":"Send DelNetworkReply: IPv4Addr , DeviceNumber: 0, err: datastore: unknown pod"}
{"level":"error","ts":"2024-01-10T20:46:28.890Z","caller":"ipamd/ipamd.go:1001","msg":"Failed to allocate a private IP/Prefix addresses on ENI eni-0c55f88c3e7409059: InsufficientCidrBlocks: The specified subnet does not have enough free cidr blocks to satisfy the request.\
{"level":"warn","ts":"2024-01-10T20:46:28.890Z","caller":"ipamd/ipamd.go:891","msg":"failed to allocate all available IPv4 Prefixes on ENI eni-0c55f88c3e7409059, err: InsufficientCidrBlocks: The specified subnet does not have enough free cidr blocks to satisfy the request.
{"level":"info","ts":"2024-01-10T20:46:28.890Z","caller":"ipamd/ipamd.go:1005","msg":"Trying to allocate 1 IP addresses on ENI eni-0c55f88c3e7409059"}
{"level":"debug","ts":"2024-01-10T20:46:28.890Z","caller":"ipamd/ipamd.go:1005","msg":"PD enabled - true"}
{"level":"error","ts":"2024-01-10T20:46:29.214Z","caller":"ipamd/ipamd.go:1005","msg":"Failed to allocate a private IP/Prefix addresses on ENI eni-0c55f88c3e7409059: InsufficientCidrBlocks: The specified subnet does not have enough free cidr blocks to satisfy the request.\
{"level":"debug","ts":"2024-01-10T20:46:29.214Z","caller":"ipamd/ipamd.go:780","msg":"Insufficient IP Addresses due to: InsufficientCidrBlocks\n"}
{"level":"error","ts":"2024-01-10T20:46:29.214Z","caller":"ipamd/ipamd.go:633","msg":"Unable to attach IPs/Prefixes for the ENI, subnet doesn't seem to have enough IPs/Prefixes. Consider using new subnet or carve a reserved range using create-subnet-cidr-reservation"}

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

Wait a minute, what do you have WARM_IP_TARGET set to in the daemonset?

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

I recently improved the logging in this area, but I think you are hitting the same case as #2650, where WARM_IP_TARGET is set to 0, so no new ENIs are being allocated

@AlissonRS
Copy link
Author

@jdn5126 WARM_IP_TARGET is not set.

From the logs, does that mean the subnet is fragmented, thus it cannot allocate a prefix for the node?

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

Hmm ok, what WARM/MINIMUM env vars do you have set on the daemonset? This does seem to be implying that the subnet the node was launched in is fragmented to the point where we cannot carve out another prefix, but I am still digging

@AlissonRS
Copy link
Author

AlissonRS commented Jan 10, 2024

@jdn5126 it turns out I have WARM_PREFIX_TARGET set to 1, but I don't have WARM_IP_TARGET.

I'll remove WARM_PREFIX_TARGET and add WARM_IP_TARGET.

This is the env section for the aws-node daemonset:


          env:
            - name: ADDITIONAL_ENI_TAGS
              value: '{}'
            - name: ANNOTATE_POD_IP
              value: 'false'
            - name: AWS_VPC_CNI_NODE_PORT_SUPPORT
              value: 'true'
            - name: AWS_VPC_ENI_MTU
              value: '9001'
            - name: AWS_VPC_K8S_CNI_CUSTOM_NETWORK_CFG
              value: 'false'
            - name: AWS_VPC_K8S_CNI_EXTERNALSNAT
              value: 'false'
            - name: AWS_VPC_K8S_CNI_LOGLEVEL
              value: DEBUG
            - name: AWS_VPC_K8S_CNI_LOG_FILE
              value: /host/var/log/aws-routed-eni/ipamd.log
            - name: AWS_VPC_K8S_CNI_RANDOMIZESNAT
              value: prng
            - name: AWS_VPC_K8S_CNI_VETHPREFIX
              value: eni
            - name: AWS_VPC_K8S_PLUGIN_LOG_FILE
              value: /var/log/aws-routed-eni/plugin.log
            - name: AWS_VPC_K8S_PLUGIN_LOG_LEVEL
              value: DEBUG
            - name: CLUSTER_NAME
              value: flokifi
            - name: DISABLE_INTROSPECTION
              value: 'false'
            - name: DISABLE_METRICS
              value: 'false'
            - name: DISABLE_NETWORK_RESOURCE_PROVISIONING
              value: 'false'
            - name: ENABLE_IPv4
              value: 'true'
            - name: ENABLE_IPv6
              value: 'false'
            - name: ENABLE_POD_ENI
              value: 'false'
            - name: ENABLE_PREFIX_DELEGATION
              value: 'true'
            - name: VPC_CNI_VERSION
              value: v1.16.0
            - name: VPC_ID
              value: vpc-092bc50c110843fee
            - name: WARM_ENI_TARGET
              value: '1'
            - name: WARM_PREFIX_TARGET
              value: '1'
            - name: MY_NODE_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: spec.nodeName
            - name: MY_POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

Hmm.. WARM_PREFIX_TARGET=1 should be fine, but it is typically easier to set WARM_IP_TARGET. Can you check if the subnet this node was launched in has 16 consecutive IPs available?

As a side note, our main focus right now is on massively improving this area so you never have to touch these environment variables again or worry about what subnet the node is launched in. #2714 is a start to that

@AlissonRS
Copy link
Author

AlissonRS commented Jan 10, 2024

@jdn5126 I ran this command:

aws ec2 describe-network-interfaces --filters "Name=subnet-id,Values=subnet-027e9e2eb3ce105bc" | jq -r '.Net
workInterfaces[].PrivateIpAddresses[].PrivateIpAddress' | sort

10.0.10.4
10.0.10.6
10.0.10.17
10.0.10.34
10.0.10.37
10.0.10.80

So I'm assuming it has 16 consecutive IPs available. I could also create CIDR reservations, though I'm not exactly sure how that works (e.g. do I just create it and AWS takes care of the rest?)

For example, my subnet is 10.0.10.0/24, so it means 254 - 5 (reserved for AWS), 249. So I'd guess that allows having 15 blocks of 16 consecutive IP addresses, starting on 10.0.10.4-10.0.10.19, then another one from 10.0.10.20-10.0.10.35 and so on. So I could in theory create 15 CIDR reservations within this subnet. Is my understanding correct?

Sorry I'm not very proficient with networking, but I'm trying to learn more about it.

@AlissonRS
Copy link
Author

I removed WARM_PREFIX_TARGET and added WARM_IP_TARGET=1, this seems to cause existing nodes to be replaced by new ones.

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

Right, the subnet does look like it has enough available IPs to carve a prefix from. To answer your question, you don't need to create a CIDR reservation, as that's what IPAMD is doing for you. From the best practices guide (https://aws.github.io/aws-eks-best-practices/networking/prefix-mode/index_linux/), I see it recommending WARM_PREFIX_TARGET=1, so your initial config seems to be the recommended one.

I cannot figure out why EC2 would be returning InsufficientCidrBlocks: The specified subnet does not have enough free cidr blocks to satisfy the request. I will keep digging into this with my team

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 10, 2024

The only thing I can think of to try, since this is a dev environment, is setting a higher WARM_PREFIX_TARGET, like setting it to 2, to try to force the IPAMD to allocate a new ENI, as it will not allocate a new ENI until it needs to.

For the comment about nodes being replaced, I assume that is Karpenter packing pods when the aws-node daemonset is restarted.

@AlissonRS
Copy link
Author

@jdn5126 thanks for helping with this. I readded WARM_PREFIX_TARGET with 2, and removed WARM_IP_TARGET.

I'll keep investigating myself, but please let me know if there is anything I can provide to further help debug.

I could also open a ticket on AWS but I don't have premium support available, so not sure if that's possible.

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 11, 2024

Hi @AlissonRS, I did some more digging, and here is what I found:

  1. The VPC CNI starts by trying to get a /28 prefix from a subnet CIDR reservation space. I see from https://docs.aws.amazon.com/eks/latest/userguide/cni-increase-ip-addresses.html that EKS does recommend carving out CIDR reservations in advance.
  2. If no CIDR reservation is found, the general subnet IP pool is tried, with the limitation that some range is reserved exclusively for node IPs.
  3. The error you got indicates that there is no contiguous /28 block anywhere in the subnet that VPC CNI is allowed to use. Unfortunately, EC2 does not provide visibility (to you or to me) into the fragmentation in the subnet.

Here is my conclusion from this:

  1. Using subnet CIDR reservations is the only effective way to use prefix delegation. It is the only way to handle the inevitable pod IP churn that arises in any cluster.
  2. Setting WARM_PREFIX_TARGET=1 (and not setting WARM_IP_TARGET) is the best setting for 99% of cases.
  3. Having larger subnets to begin with obviously helps, but that is not always an option.

My questions for you are:

  1. What is your motivation for using prefix delegation? My hope is that the in-progress improvements to pod IP management will render IPv4 Prefix Delegation and Custom Networking obsolete.

@AlissonRS
Copy link
Author

@jdn5126 thanks for the detailed output, I'll enable CIDR reservation for the subnets and delete all nodes so the IP addresses are released and not reassigned, Karpenter shall recreate the nodes. If that doesn't work, then I'll just recreate the subnets with larger CIDR ranges + reservation. I'll let you know if that works, otherwise share new logs here.

Is there a way for me to find the InsufficientCidrBlocks: The specified subnet does not have enough free cidr blocks to satisfy the request error via kubectl?

As for your question, I'm using prefix delegation to increase the number of pods per EC2 node, as the nodes were being underutilized, e.g. reaching max number of pods without requesting even half the CPU and Memory available, let alone actual consumption which is even lower than pod requests for CPU and Memory.

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 17, 2024

The InsufficientCidrBlocks log is only present in /var/log/aws-routed-eni/ipamd.log, so you would not be able to get it from kubelet, unfortunately.

And got it, using Prefix Delegation to increase pod density makes sense. After #2714 merges, this will be much easier.

@deadlysyn
Copy link

deadlysyn commented Jan 25, 2024

hesitate to pile on because i do not want to detract from OP issue, let me know if you prefer a new issue.

starting here because the error is the same "failed to assign an IP address to container" and was considering moving to prefix mode as a potential solve like OP but after reading this, other issues, docs, cni code...not sure it is the right answer for our context (and especially if features like #2714 talk about removing the need for it).

when updating our node groups we some times get "failed to assign an IP address" errors (logs attached). we are nowhere near max pods (234 on our m5.8xlarge instances), subnet exhaustion or fragmentation (/16 cluster subnet, /20s for each region, dedicated to EKS).

from this and other threads i understand prefix mode is primarily about increasing pod density, but originally looked at it based on various doc comments describing it as a way to improve scheduling delays (fewer EC2 API requests for IPs/ENIs). however, we also run security groups for pods which based on pod networking use cases we know is already the worst for density and launch time (security tradeoff)... we are looking to optimize this as much as possible.

docs clearly state when running pod security policies, you can schdule pods of various types (pod or node security group), and we have a mix of both types on each node. looping across nodes currently i see:

❯ ./count.sh      
 --> ip-10-160-36-226.ec2.internal
        PODS THIS NODE: 50
    MAX SUPPORTED PODS: 234
     CURRENT PODS ENIS: 36 (54 max)
 --> ip-10-160-38-61.ec2.internal
        PODS THIS NODE: 25
    MAX SUPPORTED PODS: 234
     CURRENT PODS ENIS: 19 (54 max)
 --> ip-10-160-55-36.ec2.internal
        PODS THIS NODE: 46
    MAX SUPPORTED PODS: 234
     CURRENT PODS ENIS: 39 (54 max)
 --> ip-10-160-60-47.ec2.internal
        PODS THIS NODE: 34
    MAX SUPPORTED PODS: 234
     CURRENT PODS ENIS: 28 (54 max)
 --> ip-10-160-72-134.ec2.internal
        PODS THIS NODE: 33
    MAX SUPPORTED PODS: 234
     CURRENT PODS ENIS: 27 (54 max)
 --> ip-10-160-73-230.ec2.internal
        PODS THIS NODE: 12
    MAX SUPPORTED PODS: 234
     CURRENT PODS ENIS: 2 (54 max)

so we are nowhere near max-pods but close enough to pod eni limits (if i understand this instance type can support 54 branch interfaces which is to say you can only have 54 pods with security groups per node).

what i don't yet understand is if/how pod-eni is used as scheduling input similar to max-pods. will pods with security groups get scheduled based on max-pods or pod-enis? the concern i am trying to either validate or invalidate is whether we need to reduce max-pods to avoid scheduling workloads on nodes with no remaining branch enis. best practices for pod security groups mention:

Branch interface capacity is additive to existing instance type limits for secondary IP addresses. Pods that use security groups are not accounted for in the max-pods formula and when you use security group for pods you need to consider raising the max-pods value or be ok with running fewer pods than the node can actually support.

A m5.large can have up to 9 branch network interfaces and up to 27 secondary IP addresses assigned to its standard network interfaces. As shown in the example below, the default max pods for a m5.large is 29, and EKS counts the Pods that use security groups towards the maximum Pods.

which to me could say we will loose some potential capacity if we don't bump max-pods (to max-pods + max branch enis?) which may imply max-pods is the only scheduling limit considered but if that were true i would expect blurbs in all the pod security group docs about setting max-pods == max branch enis or some other guidance. talk me off this ledge. 🙏

considered adjusting various WARM_* tuneables based on this and other threads (currently running defaults / typical best case per your comment above), but the pod networking use cases clearly call out those are not applicable for security groups with pods.

currently getting cni-metrics-helper going for easier visibility/trending. next step is to plan EKS (1.25) + CNI add-on (1.12.6) upgrades to eliminate some bugs and adjust config... but struggling to find the optimal settings when using security groups for pods.

eks.tgz

thank you for any guidance!

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 25, 2024

@deadlysyn so with Security Groups for pods, each node is limited by the number of branch ENIs it can support, correct. Which instance type corresponds with the 10.160.38.61 logs? I am seeing some errors like:

{"level":"info","ts":"2024-01-08T21:31:23.692Z","caller":"rpc/rpc.pb.go:713","msg":"Send AddNetworkReply: failed to get Branch ENI resource"}

, which would imply that no more branch ENIs can be allocated for this instance. Branch ENIs are allocated by the VPC Resource Controller, so we would need a support ticket to access the control plane logs.

The branch ENI limits come from https://github.com/aws/amazon-vpc-resource-controller-k8s/blob/master/pkg/aws/vpc/limits.go, in case you hadn't seen that yet.

As you mentioned, Kubernetes network policy is more scalable when it comes to pod density per node. We still want to investigate which limits you are hitting here, though.

For the scheduling decision, as I understand it, the Kubernetes scheduler will select a node to run the pod on, and then the VPC Resource Controller will try to allocate a branch ENI on that node: https://github.com/aws/amazon-vpc-resource-controller-k8s/blob/master/pkg/provider/branch/trunk/trunk.go#L332. If the node has already reached its branch ENI limit, then the allocation will fail. It doesn't look like the Kubernetes scheduler can pick nodes based on which has the largest number of branch ENI slots available.

If you can share the instance type and open a support case, I can involve some other teammates and do more digging.

@deadlysyn
Copy link

deadlysyn commented Jan 26, 2024

@jdn5126 thank you for your quick response and obliging my pile-on!

currently on basic support so can't open a case, but the instance type for 10.160.38.61 is m5.8xlarge. we have consistent instance types in each node group.

thanks for the code pointers and sharing your scheduling knowledge. since we are over provisioned it now makes sense to me that typical request/limit/affinity/etc scheduling would toss pods at random nodes regardless of branch eni limits and then stabilize once the new worker node becomes available (this always self-heals, it's just a few minutes of downtime for select pods).

i suppose low-tech fixes could be:

  • run a larger instance type (more branch enis)
  • add more worker nodes (spread pods out for more branch eni buffer)
  • get creative with node affinity

i looked at cloudwatch this morning, mostly going through kube-scheduler logs. since volume is high, i used a log insights query like (with time period matching attached logs):

fields @logStream, @timestamp, @message
| sort @timestamp desc
| filter @logStream like /kube-scheduler/
| filter @message like "ip-10-160-72-134.ec2.internal"

i just see a lot of "successfully bound pod to node" and a couple "added node in listed group to nodetree". nothing else. is there a better log to check?

thanks again for the work you do!

@jdn5126
Copy link
Contributor

jdn5126 commented Jan 26, 2024

No worries, happy to help! The Security Groups for Pods solution is great for migrating services that use EC2 security groups, and great for using the same EC2 concept across AWS services. Its main drawback is its impact on node scalability and its lack of integration with the Kubernetes scheduler.

For CloudWatch, assuming you have already enabled "Control Plane Logging" from your EKS console, you'll be able to see VPC Resource Controller logs with a query like:

fields @timestamp, @message, @logStream
| filter @logStream like "vpc-resource-controller"

and then you can filter for errors allocating branch ENIs, which should be visible from just:

fields @timestamp, @message, @logStream
| filter @logStream like "vpc-resource-controller"
| filter level == "error"

@deadlysyn
Copy link

deadlysyn commented Jan 26, 2024

we have control plane logging enables, but controller manager is set to off:

image

however your queries always return no results, presumably since there is not a matching logstream name. i've enabled "controller manager" logs on all clusters so we'll have more context next time.

@jdn5126
Copy link
Contributor

jdn5126 commented Feb 13, 2024

Closing this issue as there are no active threads. Please reopen if there is more information to add

@jdn5126 jdn5126 closed this as completed Feb 13, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants