aws / aws/aws-cdk

eks: TaintEffect Enum has unsupported values

Open
#34,780 6 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-eks @aws-cdk/aws-eks-v2-alpha bug effort/small p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When trying to use the [TaintEffect Enum](https://github.com/aws/aws-cdk/blob/v2.202.0/packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts#L160) for a kubernetes manifest describing a Karpenter `NodePool`, the string value is all uppercase and does not seem to match what a taint is as a string in [k8s docs](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) so the validation fails. This however does work for k8s nodegroups.

From the [python docs](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_eks/TaintEffect.html) it looks like the python lib uses the proper values for the `TaintEffect` Enum. I am not sure why that is, if TS is the source.

As a workaround I would need to specify it as a string and not use the `TaintSpec` interface or `TaintEffect` enum when using the TypeScript lib.

When using CDK to create a Karpenter nodepool manifest in the eks cluster I am seeing this error:
`Error: b'The NodePool "default-nodepool" is invalid: \n* spec.template.spec.taints[0].effect: Unsupported value: "NO_EXECUTE": supported values: "NoSchedule", "PreferNoSchedule", "NoExecute"\n*`

(P.S. Prompted a song for fun: https://suno.com/s/8JD1CY0RmFeOjSBJ)

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Library Version

N/A

### Expected Behavior

I expect to not have an error when using the `TaintEffect` enum to configure a karpenter nodepool manifest with the NoExecute taint.

### Current Behavior

`| Custom::AWSCDK-EKS-KubernetesResource | rKarpenter/rNodeClass-default-nodeclass/rNodePool-default-nodepool/rNodePool-default-nodepool/Resource/Default (rKarpenterrNodeClassdefaultnodeclassrNodePooldefaultnodepoolDC25F7A7) Received response status [FAILED] from custom resource. Message returned: Error: b'The NodePool "default-nodepool" is invalid: \n* spec.template.spec.taints[0].effect: Unsupported value: "NO_EXECUTE": supported values: "NoSchedule", "PreferNoSchedule", "NoExecute"\n* : Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation\n'`

### Reproduction Steps

I believe this is a short enough example that can explain what I am trying to accomplish and be copied and reused. However if you need a larger, more complete, example I can try to work on a sample test stack and upload it to a public repo.

```typescript
import { Nodegroup, KubernetesManifest, TaintEffect, TaintSpec } from 'aws-cdk-lib/aws-eks';

const ciliumTaint: TaintSpec = {
key: 'node.cilium.io/agent-not-ready',
value: 'true',
effect: TaintEffect.NO_EXECUTE
}

// NodeGroups
const nodeGroup = new Nodegroup(this, id, {
cluster: cluster,
subnets: subnets,
taints: [ciliumTaint]
};
}

// NodePool
const chart = new KubernetesManifest(this, id, {
cluster: cluster,
manifest: [{
apiVersion: `karpenter.sh/${apiVersion}`,
kind: 'NodePool',
metadata: {
name: name
},
spec: {
template: {
spec: {
taints: [ciliumTaint]
}
}
}
}]
});
```

### Possible Solution

Update the enum to match k8s taint values.
```typescript
export enum TaintEffect {
/**
* NoSchedule
*/
NO_SCHEDULE = 'NoSchedule',
/**
* PreferNoSchedule
*/
PREFER_NO_SCHEDULE = 'PreferNoSchedule',
/**
* NoExecute
*/
NO_EXECUTE = 'NoExecute',
}
```

### Additional Information/Context

EKS Version: 1.32
Cilium Version: 1.17.2
Karpenter-crd Version: 1.5.1
Karpenter Version: 1.5.1

Addons:
- addonName: coredns
addonVersion: v1.11.4-eksbuild.2
preserveOnDelete: false
- addonName: aws-ebs-csi-driver
addonVersion: v1.41.0-eksbuild.1
preserveOnDelete: false
- addonName: aws-mountpoint-s3-csi-driver
addonVersion: v1.13.0-eksbuild.1
preserveOnDelete: false

### AWS CDK Library version (aws-cdk-lib)

aws-cdk-lib@2.195.0

### AWS CDK CLI version

2.1016.0 (build 66e0b2d)

### Node.js Version

v22.13.1

### OS

Windows 10 22H2 (19045.3930)

### Language

TypeScript

### Language Version

5.8.3

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in packages/aws-cdk-lib/aws-eks/lib/managed-nodegroup.ts around the TaintEffect enum referenced in the issue, then reproduce the KubernetesManifest example with a Karpenter NodePool. Done means the enum values serialize as NoSchedule, PreferNoSchedule, and NoExecute so the manifest passes Kubernetes validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.