-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(eks): add support of Helm charts located in ECR of AWS CN region #29778
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
Exemption Request: This change is related to custom resources handler. Test is separated and no test file can be provided in code repo. |
Thank you for your PR. Can you write a simple CDK App like |
Hi, I have added integrated testing for this PR. Unfortunately I can't put it into repository due to it contains my AWS account info. So I'll describe my testing procedure here. I added a sample stack /// !cdk-integ pragma:disable-update-workflow
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
import { App, Stack } from 'aws-cdk-lib';
import * as integ from '@aws-cdk/integ-tests-alpha';
import { getClusterVersionConfig } from './integ-tests-kubernetes-version';
import * as eks from 'aws-cdk-lib/aws-eks';
class EksClusterStack extends Stack {
private cluster: eks.Cluster;
private vpc: ec2.IVpc;
constructor(scope: App, id: string) {
super(scope, id);
// allow all account users to assume this role in order to admin the cluster
const mastersRole = new iam.Role(this, 'AdminRole', {
assumedBy: new iam.AccountRootPrincipal(),
});
// just need one nat gateway to simplify the test
this.vpc = new ec2.Vpc(this, 'Vpc', { natGateways: 1, restrictDefaultSecurityGroup: false });
// create the cluster with a default nodegroup capacity
this.cluster = new eks.Cluster(this, 'Cluster', {
vpc: this.vpc,
mastersRole,
defaultCapacity: 2,
...getClusterVersionConfig(this),
tags: {
foo: 'bar',
},
});
this.assertHelmChartAsset();
}
private assertHelmChartAsset() {
// get helm chart from Asset
this.cluster.addHelmChart('test-oci-cn-chart', {
chart: 'hello-world',
release: 'hello-world-chart',
repository: 'oci://<REDACTED>.dkr.ecr.cn-northwest-1.amazonaws.com.cn/charts/hello-world',
version: '0.1.0',
namespace: 'default',
createNamespace: true,
});;
}
}
const app = new App();
const stack = new EksClusterStack(app, 'aws-cdk-eks-helm-test');
new integ.IntegTest(app, 'aws-cdk-eks-helm', {
testCases: [stack],
// Test includes assets that are updated weekly. If not disabled, the upgrade PR will fail.
diffAssets: false,
});
app.synth(); Then I run integration testing command against the stack: yarn integ integ.eks-helm-asset-oci-cn.js --force --directory ./test/aws-eks/test/ --update-on-failed --no-clean --parallel-regions cn-north-1 and get the following output:
The screenshot of deployed CFN stack shows
These screenshot can confirm the deployment is succeed with a helm chart hosted on ECR of AWS China (Beijing) region (cn-north-1). I also tested on China (Ningxia) region (cn-northwest-1) with a success. Here are the screenshots: CFN stack: Helm: |
OK. I have successfully deployed the following code into import {
App, Stack,
aws_eks as eks,
aws_ec2 as ec2,
aws_iam as iam,
} from 'aws-cdk-lib';
import { KubectlV29Layer } from '@aws-cdk/lambda-layer-kubectl-v29';
const app = new App();
const stack = new Stack(app, 'my-test-stack4');
const mastersRole = new iam.Role(stack, 'AdminRole', {
assumedBy: new iam.AccountRootPrincipal(),
});
const vpc = new ec2.Vpc(stack, 'Vpc', { natGateways: 1 });
const cluster = new eks.Cluster(stack, 'Cluster', {
vpc,
mastersRole,
version: eks.KubernetesVersion.V1_29,
kubectlLayer: new KubectlV29Layer(stack, 'KubectlLayer'),
defaultCapacity: 2,
});
cluster.addHelmChart('test-oci-cn-chart', {
chart: 'helm-test-chart',
release: 'helm-test-chart-chart',
repository: 'oci://<deducted>.dkr.ecr.cn-north-1.amazonaws.com.cn/helm-test-chart',
version: '0.1.0',
namespace: 'default',
createNamespace: true,
});; And verified the ConfigMap of the Helm chart with
I can confirm this works in both China regions now. And the following code in import {
App, Stack,
aws_eks as eks,
aws_ec2 as ec2,
aws_iam as iam,
} from 'aws-cdk-lib';
import { KubectlV29Layer } from '@aws-cdk/lambda-layer-kubectl-v29';
const app = new App();
const stack = new Stack(app, 'my-test-stack4');
const mastersRole = new iam.Role(stack, 'AdminRole', {
assumedBy: new iam.AccountRootPrincipal(),
});
const vpc = new ec2.Vpc(stack, 'Vpc', { natGateways: 1 });
const cluster = new eks.Cluster(stack, 'Cluster', {
vpc,
mastersRole,
version: eks.KubernetesVersion.V1_29,
kubectlLayer: new KubectlV29Layer(stack, 'KubectlLayer'),
defaultCapacity: 2,
});
cluster.addHelmChart('test-oci-chart', {
chart: 'helm-test-chart',
release: 'helm-test-chart-chart',
repository: 'oci://<deducted>.dkr.ecr.us-east-1.amazonaws.com/helm-test-chart',
version: '0.1.0',
namespace: 'default',
createNamespace: true,
});; And I have verified successful deployments in I think this PR is safe to ship. |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
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). |
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). |
@Mergifyio update |
❌ Mergify doesn't have permission to updateFor security reasons, Mergify can't update this pull request. Try updating locally. |
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
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. |
Issue # (if applicable)
Closes #28460.
Reason for this change
Current implementation will not identity helm charts stored in ECR on AWS CN regions, and will treat ECR as simple, unauthorized repository.
Description of changes
This change add support of ECR on AWS CN region by adding a optional suffix of .cn to the regex.
Description of how you validated changes
Run the affected regex against helm repo in ECR China (123456789012.dkr.ecr.cn-northwest-1.amazonaws.com.cn)
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license