- Newest
- Most votes
- Most comments
When configuring Karpenter with Security Groups for Pods enabled, you need to ensure that only instance types supporting ENI trunking are selected. While there isn't a direct trunking-specific selector in Karpenter, you can use a combination of instance category and generation requirements to target compatible instances.
In your Karpenter NodePool configuration, you can specify requirements that will help filter for more modern instance types that typically support trunking:
apiVersion: karpenter.sh/v1 kind: NodePool metadata: name: example spec: template: spec: requirements: - key: karpenter.k8s.aws/instance-category operator: In values: ["c", "m", "r"] # Select compute, memory, or general purpose optimized - key: karpenter.k8s.aws/instance-generation operator: Gt values: ["2"] # Select newer generation instances nodeClassRef: group: karpenter.k8s.aws kind: EC2NodeClass name: example
This approach filters for newer generation instances that are more likely to support trunking capabilities. You can further refine this by adjusting the instance categories and minimum generation number.
For more precise control, you could use the EC2 instance selector tool to identify specific trunk-compatible instances and then explicitly list them in your configuration. While this is more manual, it gives you certainty about the instances being selected.
Monitoring your node resource usage regularly with tools like kubectl top nodes will help you verify that the selected instances are meeting your workload requirements while supporting the trunking capabilities needed for Security Groups for Pods.
Sources
Kubernetes Data Plane - Amazon EKS
Karpenter Support - Eksctl User Guide
Optimizing Karpenter for Resource Constraints: Resolving CPU and Storage Issues in Kubernetes | AWS re:Post
answered a year ago

I've found this way more efficient to work with spot instances
apiVersion: karpenter.sh/v1beta1 kind: NodePool metadata: name: trunk-compatible-family-exclusion spec:
Define your limits (e.g., maximum total CPU or memory for the nodepool)
limits: cpu: "1000"
Specify the consolidation configuration
consolidation: enabled: true
template: spec: # Define the common provisioner/nodepool requirements requirements: # Exclude all the instance families that are not ENI trunk compatible - key: karpenter.k8s.aws/instance-family operator: NotIn values: - c1 - c3 - c4 - d2 - f1 - g3 - h1 - i2 - i3 - i4i - m1 - m2 - m3 - m4 - p2 - p3 - r3 - r4 - t1 - t2 - t3 - t3a - t4g # Specific U-series prefixes - u-6tb1 - u-9tb1 - u-12tb1 - u-18tb1 - u-24tb1 - x1 - x1e