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

feat(eks): support eks with k8s 1.32 #33339

Merged
merged 8 commits into from
Feb 7, 2025
Merged

feat(eks): support eks with k8s 1.32 #33339

merged 8 commits into from
Feb 7, 2025

Conversation

pahud
Copy link
Contributor

@pahud pahud commented Feb 7, 2025

Issue # (if applicable)

Closes #33254

Reason for this change

Description of changes

Describe any new or updated permissions being added

Description of how you validated changes

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


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

pahud added 2 commits February 6, 2025 13:07
Update various dependencies and test snapshots for EKS integration tests:
- Bump @aws-cdk/lambda-layer-kubectl-v32 to 2.0.1
- Refresh EKS integration test snapshots to version 39.0.0
- Update kubectl and helm versions in test assets

This commit includes updates to package dependencies and regenerated test snapshots for the AWS CDK EKS integration tests.
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 labels Feb 7, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team February 7, 2025 16:59
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Feb 7, 2025
@pahud
Copy link
Contributor Author

pahud commented Feb 7, 2025

For future reference:

The action plan I used for this PR

feat(eks): support eks with k8s 1.32

Similar to #31707 which added support for k8s 1.31, this PR adds support for k8s 1.32.

Changes Required

  1. Reference and import @aws-cdk/lambda-layer-kubectl-v32

    • This package requires the kubectl Lambda layer for k8s 1.32, which is provided from external
    • Similar structure to existing kubectl layer packages (v31, v30, etc.)
    • Add package reference in packages/@aws-cdk-testing/framework-integ/package.json:
      "@aws-cdk/lambda-layer-kubectl-v32": "2.0.0",
  2. Add V1_32 to KubernetesVersion enum in:

    • packages/aws-cdk-lib/aws-eks/lib/cluster.ts

    Note: Do not update anything under aws-eks-v2-alpha - we only focus on the aws-eks module.

  3. Update imports and documentation in both files to reference the new kubectl layer:

    import { KubectlV32Layer } from '@aws-cdk/lambda-layer-kubectl-v32';
/**
 * Kubernetes version 1.32
 * When creating a `Cluster` with this version, you need to also specify the
 * `kubectlLayer` property with a `KubectlV32Layer` from
 * `@aws-cdk/lambda-layer-kubectl-v32`.
 */
public static readonly V1_32 = KubernetesVersion.of('1.32');
  1. Update test files:

    • Add import in test files:
      import { KubectlV32Layer } from '@aws-cdk/lambda-layer-kubectl-v32';
    • Update version map in packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ-tests-kubernetes-version.ts:
      const versionMap: { [key: string]: new (scope: Construct, id: string) => lambda.ILayerVersion } = {
        '1.32': KubectlV32Layer,
        // ... existing versions
      };
    • Update test cases to use k8s 1.32 where appropriate
    • Update snapshot test files after changes
  2. Update integration test snapshots:

    • Run integration tests which will generate new snapshots
    • Review and commit the updated snapshot files

Testing

  1. Create new EKS cluster with k8s 1.32
  2. Verify kubectl operations work correctly
  3. Run integration tests
  4. Verify backward compatibility with existing versions

Documentation

Update relevant documentation to include k8s 1.32 support:

  • README files
  • API documentation
  • Example code snippets

Dependencies

This change requires:

  1. AWS EKS to support k8s 1.32
  2. kubectl v1.32.x binary for the Lambda layer

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (2637d46) to head (060a40b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33339   +/-   ##
=======================================
  Coverage   80.83%   80.83%           
=======================================
  Files         236      236           
  Lines       14251    14251           
  Branches     2490     2490           
=======================================
  Hits        11520    11520           
  Misses       2446     2446           
  Partials      285      285           
Flag Coverage Δ
suite.unit 80.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 79.56% <ø> (ø)
packages/aws-cdk-lib/core 82.20% <ø> (ø)

@pahud pahud marked this pull request as ready for review February 7, 2025 19:26
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 7, 2025
Copy link
Contributor

mergify bot commented Feb 7, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Feb 7, 2025
Copy link
Contributor

mergify bot commented Feb 7, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 060a40b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Feb 7, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 3490d2e into aws:main Feb 7, 2025
20 checks passed
Copy link

github-actions bot commented Feb 7, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(eks): EKS v1.32 support
3 participants