Skip to content

Commit 2791017

Browse files
author
Elad Ben-Israel
authored
feat(eks): deprecate "kubectlEnabled: false" (#9454)
When specifying `kubectlEnabled: false`, it _implicitly_ meant that the underlying resource behind the construct would be the stock `AWS::EKS::Cluster` resource instead of the custom resource used by default. This means that many new capabilities of EKS would not be supported (e.g. Fargate profiles). Clusters backed by the custom-resource have all the capabilities (and more) of clusters backed by `AWS::EKS::Cluster`. Therefore, we decided that going forward we are going to support only the custom-resource backed solution. To that end, after this change, defining an `eks.Cluster` with `kubectlEnabled: false` will throw an error with the following message: The "eks.Cluster" class no longer allows disabling kubectl support. As a temporary workaround, you can use the drop-in replacement class `eks.LegacyCluster` but bear in mind that this class will soon be removed and will no longer receive additional features or bugfixes. See #9332 for more details Resolves #9332 BREAKING CHANGE: The experimental `eks.Cluster` construct no longer supports setting `kubectlEnabled: false`. A temporary drop-in alternative is `eks.LegacyCluster`, but we have plans to completely remove support for it in an upcoming release since `eks.Cluster` has matured and should provide all the needed capabilities. Please comment on #9332 if there are use cases that are not supported by `eks.Cluster`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent b80c271 commit 2791017

File tree

11 files changed

+1184
-344
lines changed

11 files changed

+1184
-344
lines changed

packages/@aws-cdk/aws-eks/README.md

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cluster.addResource('mypod', {
4848
```
4949

5050
In order to interact with your cluster through `kubectl`, you can use the `aws
51-
eks update-kubeconfig` [AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/eks/update-kubeconfig.html) command
51+
eks update-kubeconfig` [AWS CLI command](https://docs.aws.amazon.com/cli/latest/reference/eks/update-kubeconfig.html)
5252
to configure your local kubeconfig.
5353

5454
The EKS module will define a CloudFormation output in your stack which contains
@@ -411,8 +411,6 @@ Furthermore, when auto-scaling capacity is added to the cluster (through
411411
of the auto-scaling group will be automatically mapped to RBAC so nodes can
412412
connect to the cluster. No manual mapping is required any longer.
413413

414-
> NOTE: `cluster.awsAuth` will throw an error if your cluster is created with `kubectlEnabled: false`.
415-
416414
For example, let's say you want to grant an IAM user administrative privileges
417415
on your cluster:
418416

@@ -467,68 +465,6 @@ If you want to SSH into nodes in a private subnet, you should set up a
467465
bastion host in a public subnet. That setup is recommended, but is
468466
unfortunately beyond the scope of this documentation.
469467

470-
### kubectl Support
471-
472-
When you create an Amazon EKS cluster, the IAM entity user or role, such as a
473-
[federated user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html)
474-
that creates the cluster, is automatically granted `system:masters` permissions
475-
in the cluster's RBAC configuration.
476-
477-
In order to allow programmatically defining **Kubernetes resources** in your AWS
478-
CDK app and provisioning them through AWS CloudFormation, we will need to assume
479-
this "masters" role every time we want to issue `kubectl` operations against your
480-
cluster.
481-
482-
At the moment, the [AWS::EKS::Cluster](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-cluster.html)
483-
AWS CloudFormation resource does not support this behavior, so in order to
484-
support "programmatic kubectl", such as applying manifests
485-
and mapping IAM roles from within your CDK application, the Amazon EKS
486-
construct library uses a custom resource for provisioning the cluster.
487-
This custom resource is executed with an IAM role that we can then use
488-
to issue `kubectl` commands.
489-
490-
The default behavior of this library is to use this custom resource in order
491-
to retain programmatic control over the cluster. In other words: to allow
492-
you to define Kubernetes resources in your CDK code instead of having to
493-
manage your Kubernetes applications through a separate system.
494-
495-
One of the implications of this design is that, by default, the user who
496-
provisioned the AWS CloudFormation stack (executed `cdk deploy`) will
497-
not have administrative privileges on the EKS cluster.
498-
499-
1. Additional resources will be synthesized into your template (the AWS Lambda
500-
function, the role and policy).
501-
2. As described in [Interacting with Your Cluster](#interacting-with-your-cluster),
502-
if you wish to be able to manually interact with your cluster, you will need
503-
to map an IAM role or user to the `system:masters` group. This can be either
504-
done by specifying a `mastersRole` when the cluster is defined, calling
505-
`cluster.awsAuth.addMastersRole` or explicitly mapping an IAM role or IAM user to the
506-
relevant Kubernetes RBAC groups using `cluster.addRoleMapping` and/or
507-
`cluster.addUserMapping`.
508-
509-
If you wish to disable the programmatic kubectl behavior and use the standard
510-
AWS::EKS::Cluster resource, you can specify `kubectlEnabled: false` when you define
511-
the cluster:
512-
513-
```ts
514-
new eks.Cluster(this, 'cluster', {
515-
kubectlEnabled: false
516-
});
517-
```
518-
519-
**Take care**: a change in this property will cause the cluster to be destroyed
520-
and a new cluster to be created.
521-
522-
When kubectl is disabled, you should be aware of the following:
523-
524-
1. When you log-in to your cluster, you don't need to specify `--role-arn` as
525-
long as you are using the same user that created the cluster.
526-
2. As described in the Amazon EKS User Guide, you will need to manually
527-
edit the [aws-auth ConfigMap](https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html)
528-
when you add capacity in order to map the IAM instance role to RBAC to allow nodes to join the cluster.
529-
3. Any `eks.Cluster` APIs that depend on programmatic kubectl support will fail
530-
with an error: `cluster.addResource`, `cluster.addChart`, `cluster.awsAuth`, `props.mastersRole`.
531-
532468
### Helm Charts
533469

534470
The `HelmChart` construct or `cluster.addChart` method can be used

0 commit comments

Comments
 (0)