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): bundle kubectl, helm and awscli instead of SAR app #12129

Merged
merged 19 commits into from
Dec 24, 2020

Conversation

eladb
Copy link
Contributor

@eladb eladb commented Dec 17, 2020

The EKS module uses the AWS CLI, kubectl and helm in order to interact with the Kubernetes cluster. These tools were consumed from a SAR app maintained by @pahud as an AWS Sample (see repo).

This dependency on sample code introduces an operational and maintenance risk and as part of productizing the EKS module, we need to break it. The dependency on SAR is not required, and adds a few unnecessary layers (a nested stack, SAR regional availability, etc).

To that end, this change bundles the AWS CLI and the Kubernetes tools (kubectl and helm) into the AWS CDK. These layers are maintained in two new CDK modules called @aws-cdk/lambda-layer-awscli and @aws-cdk/lambda-layer-kubectl respectively. These are normal CDK modules that export a lambda.LayerVersion resource that can be mounted to any AWS Lambda function.

Since the s3-deployment module also needs the AWS CLI (and bundles it), we now reuse the AWS CLI layer in there as well.

Module sizes:

  • lambda-layer-awscli: 10MiB
  • lambda-layer-kubectl: 24MiB

This change increases the total module size of the MonoCDK by 24MiB (10MiB are reused with s3-deployment which was already bundled). In the future we are planning to remove these bundles from the library and publish them externally so they can be consumed at deploy-time but this is out of scope for this PR (see aws/aws-cdk-rfcs#39).

Resolves #11874

BREAKING CHANGE: the @aws-cdk/eks.KubectlLayer layer class has been moved to @aws-cdk/lambda-layer-kubectl.KubectlLayer.


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

Bundle the AWS Lambda layer zip bundle as part of the EKS module and upload as an asset to the destination account in order to remove the dependency on the [aws-lambda-layer-kubectl](https://github.com/aws-samples/aws-lambda-layer-kubectl) SAR app.

The dependency on the SAR app introduces an operational and maintenance risk, and increases deploy time due to an additional nested stack introduced by SAR.

This also ensures that the EKS module can be deployed to any environment, regardless of whether the SAR app is avaialble in that location.

This change increases the module size by ~40MiB.

Fixes #11874
@gitpod-io
Copy link

gitpod-io bot commented Dec 17, 2020

@eladb eladb requested a review from iliapolo December 17, 2020 09:18
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 17, 2020
@github-actions github-actions bot added the @aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service label Dec 17, 2020
@eladb eladb marked this pull request as draft December 17, 2020 13:39
@eladb eladb added the pr/do-not-merge This PR should not be merged at this time. label Dec 17, 2020
@eladb eladb marked this pull request as ready for review December 23, 2020 17:42
@eladb eladb removed the pr/do-not-merge This PR should not be merged at this time. label Dec 23, 2020
@eladb eladb requested a review from iliapolo December 23, 2020 17:42
@mergify
Copy link
Contributor

mergify bot commented Dec 24, 2020

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

@mergify
Copy link
Contributor

mergify bot commented Dec 24, 2020

Thank you for contributing! Your pull request will be updated from master 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 63bc98f into master Dec 24, 2020
@mergify mergify bot deleted the benisrae/kubectl-layer branch December 24, 2020 09:06
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 5afdff4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

eladb pushed a commit that referenced this pull request Dec 24, 2020
The change in #12129 accidentally deleted the unit tests for the s3-deployment lambda function. This change restores them.

In order to allow tests to stub the `aws` CLI, I've added an environment variable TEST_AWSCLI_PATH. If it is defined, it will be determine the path to the CLI. Otherwise, `/opt/awscli/aws` will be used.
mergify bot pushed a commit that referenced this pull request Dec 24, 2020
The change in #12129 accidentally deleted the unit tests for the s3-deployment lambda function. This change restores them.

Since tests are written in python, run them inside a docker image derived from public.ecr.aws/lambda/python.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
flochaz pushed a commit to flochaz/aws-cdk that referenced this pull request Jan 5, 2021
)

The EKS module uses the AWS CLI, `kubectl` and `helm` in order to interact with the Kubernetes cluster. These tools were consumed from a SAR app maintained by @pahud as an AWS Sample (see [repo](https://github.com/aws-samples/aws-lambda-layer-kubectl)).

This dependency on sample code introduces an operational and maintenance risk and as part of productizing the EKS module, we need to break it. The dependency on SAR is not required, and adds a few unnecessary layers (a nested stack, SAR regional availability, etc).

To that end, this change bundles the AWS CLI and the Kubernetes tools (`kubectl` and `helm`) into the AWS CDK. These layers are maintained in two new CDK modules called `@aws-cdk/lambda-layer-awscli` and `@aws-cdk/lambda-layer-kubectl` respectively. These are normal CDK modules that export a `lambda.LayerVersion` resource that can be mounted to any AWS Lambda function.

Since the s3-deployment module also needs the AWS CLI (and bundles it), we now reuse the AWS CLI layer in there as well.

Module sizes:
- lambda-layer-awscli: 10MiB
- lambda-layer-kubectl: 24MiB

This change increases the total module size of the MonoCDK by 24MiB (10MiB are reused with s3-deployment which was already bundled). In the future we are planning to remove these bundles from the library and publish them externally so they can be consumed at deploy-time but this is out of scope for this PR (see aws/aws-cdk-rfcs#39).



Resolves aws#11874

BREAKING CHANGE: the `@aws-cdk/eks.KubectlLayer` layer class has been moved to `@aws-cdk/lambda-layer-kubectl.KubectlLayer`.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
flochaz pushed a commit to flochaz/aws-cdk that referenced this pull request Jan 5, 2021
The change in aws#12129 accidentally deleted the unit tests for the s3-deployment lambda function. This change restores them.

Since tests are written in python, run them inside a docker image derived from public.ecr.aws/lambda/python.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-eks Related to Amazon Elastic Kubernetes Service contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-eks): Adopt ownership on the kubectl SAR app
5 participants