(eks): (Allow adding CDK8s manifests to a cluster as S3 assets) #31902
Labels
@aws-cdk/aws-eks
Related to Amazon Elastic Kubernetes Service
feature-request
A feature should be added or improved.
p2
Describe the feature
CDK8s charts (
cluster.addCdk8sChart
), and direct 'in-code' manifests (cluster.addManifest
), are embedded within the CloudFormation template and sent to thekubectl
Lambda to apply to the cluster as part of the Lambda JSON payload.Helm charts (
cluster.addHelmChart
) are bundled as an CDK S3Asset
, which are pushed to S3 and pulled down and extracted by thekubectl
Lambda before being applied to the EKS cluster usinghelm
.We need the option to be able to have CDK8s charts ('in-code' manifests would be nice as well, but as we don't use them it doesn't affect us) bundled as a CDK S3
Asset
that is pushed by CDK and pulled by the Lambda before applying, in the same way that Helm charts are.Use Case
We have a number of custom resource definition (CRD) manifests that we need to apply to our clusters through CI using CDK. Helm explicitly does not provide any route for updating existing CRDs, only for installing new CRDs where no custom resource of that type already exists on the cluster. As such, we are using CDK8s
Include
to load the raw manifests and thencluster.addCdk8sChart
to apply them. In the case ofcert-manager
specifically, the CRDs in the last few versions have been so large that even loading a single custom resource as an individual chart, and then attempting to update it with a new version, breaches the 256KB Lambda async invocation payload limit. We are therefore unable to update these CRDs through CI at all.Bundling the CRDs as an
Asset
would allow us to update these charts through our CI pipeline using CDK. Even better, we could push all CRDs as a singleAsset
exactly as provided by thecert-manager
team, instead of having to split the provided file into individual assets to get even the initial create below the Lambda payload limit.Additionally, these CRDs contain a small number of non-ascii characters in descriptions which CloudFormation cannot embed and thus CDK always sees as a needed change/deployment (or we have to edit the CRDs to strip those characters). Bypassing the CloudFormation embed would remove that issue.
We also have a number of CloudFormation stacks where each individual CDK8s chart is fine, but they contain a number of charts such that we're approaching the limits of the maximum size of a CloudFormation template. This is mostly because of the size of the embedded K8s manifests, so pushing them to S3 would also resolve this issue.
Proposed Solution
KubernetesManifest
should have bothmanifest
andmanifestAsset
as optional arguments. Exactly one must be specified.cluster.addCdk8sChart
should have, in theoptions
, an additional optional boolean propertyasAsset
. If this istrue
, instead of the function creating aKubernetesManifest
object containingmanifest: chart.toJson()
, it should write thechart.toJson()
output to an S3Asset
and provide the asset asmanifestAsset: asset
. The asset details should be encoded and passed through to thekubectl
Lambda in the same way that they are for Helm charts.kubectl
Lambda receives a payload withmanifestAsset
details instead of a directly-embedded manifest, it should use the same codepath as for Helm (abstracted out into a shared collection of functions) to pull that asset, then run the normalkubectl create|apply
action on the resulting file.Other Information
No response
Acknowledgements
CDK version used
2.162.1
Environment details (OS name and version, etc.)
MacOS Sequoia (15.0.1) [local], Ubuntu Noble (24.04) [CI]
The text was updated successfully, but these errors were encountered: