Skip to content

Commit

Permalink
feat(eks): support eks with k8s 1.32 (#33339)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

Closes #33254

### Reason for this change

- Similar to #31707, this PR adds 1.32 support.
- Update all existing integ tests for V1_31 and make sure they deploy with V1_32.

### Description of changes



### Describe any new or updated permissions being added




### Description of how you validated changes

```ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
import { App, Stack, StackProps } from 'aws-cdk-lib';
import { KubectlV32Layer } from '@aws-cdk/lambda-layer-kubectl-v32';
import * as eks from 'aws-cdk-lib/aws-eks';
import { Construct } from 'constructs';

export class EksClusterLatestVersion extends Stack {
  constructor(scope: Construct, id: string, props: StackProps) {
    super(scope, id, props);

    const vpc = new ec2.Vpc(this, 'Vpc', { natGateways: 1 });
    const mastersRole = new iam.Role(this, 'Role', {
      assumedBy: new iam.AccountRootPrincipal(),
    });

    new eks.Cluster(this, 'Cluster', {
      vpc,
      mastersRole,
      version: eks.KubernetesVersion.V1_32,
      kubectlLayer: new KubectlV32Layer(this, 'KubectlLayer'),
      defaultCapacity: 1,
    });
  }
}

const app = new App();
new EksClusterLatestVersion(app, 'v32-stack', {
  env: {
    account: process.env.CDK_DEFAULT_ACCOUNT,
    region: process.env.CDK_DEFAULT_REGION,
  },
});

app.synth();
```

verify

```
pahud@MBP framework-integ % kubectl get no
NAME                           STATUS   ROLES    AGE     VERSION
ip-172-31-3-173.ec2.internal   Ready    <none>   5m21s   v1.32.0-eks-aeac579

 % kubectl get po -n kube-system
NAME                       READY   STATUS    RESTARTS        AGE
aws-node-r6jw8             2/2     Running   2 (9m35s ago)   12m
coredns-6b9575c64c-75csr   1/1     Running   1 (9m35s ago)   16m
coredns-6b9575c64c-hwpdd   1/1     Running   1 (9m35s ago)   16m
kube-proxy-9w95h           1/1     Running   1 (9m35s ago)   12m
```


### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
pahud authored Feb 7, 2025
1 parent 2637d46 commit 3490d2e
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 61 deletions.
5 changes: 3 additions & 2 deletions packages/@aws-cdk-testing/framework-integ/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@
"@aws-sdk/client-acm": "3.632.0",
"@aws-sdk/client-rds": "3.632.0",
"@aws-sdk/client-s3": "3.632.0",
"delay": "5.0.0",
"axios": "1.7.8"
"axios": "1.7.8",
"delay": "5.0.0"
},
"dependencies": {
"@aws-cdk/integ-tests-alpha": "0.0.0",
"@aws-cdk/lambda-layer-kubectl-v24": "^2.0.242",
"@aws-cdk/lambda-layer-kubectl-v29": "^2.1.0",
"@aws-cdk/lambda-layer-kubectl-v30": "^2.0.1",
"@aws-cdk/lambda-layer-kubectl-v31": "^2.0.0",
"@aws-cdk/lambda-layer-kubectl-v32": "^2.0.1",
"aws-cdk-lib": "0.0.0",
"cdk8s": "2.69.10",
"cdk8s-plus-27": "2.9.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { KubectlV24Layer } from '@aws-cdk/lambda-layer-kubectl-v24';
import { KubectlV29Layer } from '@aws-cdk/lambda-layer-kubectl-v29';
import { KubectlV30Layer } from '@aws-cdk/lambda-layer-kubectl-v30';
import { KubectlV31Layer } from '@aws-cdk/lambda-layer-kubectl-v31';
import { KubectlV32Layer } from '@aws-cdk/lambda-layer-kubectl-v32';
import { Construct } from 'constructs';
import * as eks from 'aws-cdk-lib/aws-eks';

Expand All @@ -15,6 +16,7 @@ const versionMap: { [key: string]: new (scope: Construct, id: string) => lambda.
'1.29': KubectlV29Layer,
'1.30': KubectlV30Layer,
'1.31': KubectlV31Layer,
'1.32': KubectlV32Layer,
};

export function getClusterVersionConfig(scope: Construct, version?: eks.KubernetesVersion) {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "f3c812b299b0759c937b41e39d3451f5cc61279c2ec9ee791fac08ba1e56508b.zip"
"S3Key": "2e670e0c40dc05a34d602c35c948edefcb81afaeea05b9f6240341173af6164e.zip"
},
"Description": "/opt/kubectl/kubectl 1.31.0; /opt/helm/helm 3.16.1",
"Description": "/opt/kubectl/kubectl 1.32.0; /opt/helm/helm 3.17.0",
"LicenseInfo": "Apache-2.0"
}
},
Expand Down Expand Up @@ -755,7 +755,7 @@
]
},
"Config": {
"version": "1.31",
"version": "1.32",
"roleArn": {
"Fn::GetAtt": [
"ClusterRoleFA261979",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EksClusterStack extends Stack {
vpc: this.vpc,
mastersRole,
defaultCapacity: 0,
...getClusterVersionConfig(this, eks.KubernetesVersion.V1_31),
...getClusterVersionConfig(this, eks.KubernetesVersion.V1_32),
});

// create nodegroup with AL2023_X86_64_STANDARD
Expand Down
Loading

0 comments on commit 3490d2e

Please sign in to comment.