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

aws-eks v1.4.0 cluster creation with 'aws eks update-kubeconfig' #3664

Closed
1 of 5 tasks
pahud opened this issue Aug 15, 2019 · 1 comment · Fixed by #3669
Closed
1 of 5 tasks

aws-eks v1.4.0 cluster creation with 'aws eks update-kubeconfig' #3664

pahud opened this issue Aug 15, 2019 · 1 comment · Fixed by #3669
Assignees
Labels
needs-triage This issue or PR still needs to be triaged.

Comments

@pahud
Copy link
Contributor

pahud commented Aug 15, 2019

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    If the current behavior is a 🪲bug🪲: Please provide the steps to reproduce

In current README, the aws eks update-kubeconfig without specifying --role-arn will fail. We still need to specify the clusterAdmin IAM role ARN as --role-arn here,.

  • What is the expected behavior (or behavior of feature suggested)?

aws eks update-kubeconfig succefully executed.

  • What is the motivation / use case for changing the behavior or adding this feature?

To enhance the user experience.

Please check my sample:

export class CdkStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // first define the role
    const clusterAdmin = new iam.Role(this, 'AdminRole', {
      assumedBy: new iam.AccountRootPrincipal()
    });

    // eks cluster with nodegroup of 2x m5.large instances in dedicated vpc with default configuratrion
    const cluster = new eks.Cluster(this, 'hello-eks', {
      clusterName: 'cdk-eks',
      mastersRole: clusterAdmin
    });

    // output the clusterAdmin role arn
    new cdk.CfnOutput(this, 'clusterAdminRoleArn', {
      value: clusterAdmin.roleArn
    })
  }
}

please note I add clusterAdmin.roleArn in the Outputs.

And I got outputs like this

Outputs:
CdkEksStack.clusterAdminRoleArn = arn:aws:iam::903779448426:role/CdkEksStack-AdminRole38563C57-LKOPLK0P9GVJ
CdkEksStack.helloeksDefaultCapacityInstanceRoleARN57400C70 = arn:aws:iam::903779448426:role/CdkEksStack-helloeksDefaultCapacityInstanceRole4DA-1TA4SC2WWC9H1
CdkEksStack.helloeksClusterName12358BC8 = cdk-eks

So I can copy the value of CdkEksStack.clusterAdminRoleArn from above and run:

aws eks update-kubeconfig --name cdk-eks --role-arn arn:aws:iam::903779448426:role/CdkEksStack-AdminRole38563C57-LKOPLK0P9GVJ

this will be successfully executed with no error and I can immediately kubectl with my cluster like this

kubectl get no                                                                    
NAME                                         STATUS   ROLES    AGE     VERSION
ip-10-0-150-198.us-west-2.compute.internal   Ready    <none>   6m57s   v1.13.7-eks-c57ff8
ip-10-0-190-37.us-west-2.compute.internal    Ready    <none>   7m3s    v1.13.7-eks-c57ff8
  • Please tell us about your environment:

    • CDK CLI Version: 1.4.0 (build 175471f)
    • Module Version: 1.4.0
    • OS: OSX Mojave
    • Language: TypeScript
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

@pahud pahud added the needs-triage This issue or PR still needs to be triaged. label Aug 15, 2019
@eladb eladb self-assigned this Aug 15, 2019
@eladb eladb closed this as completed in 04d88fb Aug 15, 2019
eladb pushed a commit that referenced this issue Aug 15, 2019
Synthesize a CloudFormation output that shows the `aws eks update-kubeconfig`
that needs to be executed in order to connect to the cluster. This command will
include the IAM masters role ARN if applicable.

Disable all other outputs by default, but added `outputXxx` options to enable.

Fixes #3664

BREAKING CHANGE: cluster name output will not be synthesized by default. instead we synthesize an output that includes the full `aws eks update-kubeconfig` command. You can enable synthesis of the cluster name output using the `outputClusterName: true` options.
@eladb eladb reopened this Aug 15, 2019
@eladb
Copy link
Contributor

eladb commented Aug 15, 2019

Accidentally committed to master and reverted. Sorry!

@mergify mergify bot closed this as completed in #3669 Aug 15, 2019
mergify bot pushed a commit that referenced this issue Aug 15, 2019
* feat(eks): output update-kubeconfig command

Synthesize a CloudFormation output that shows the `aws eks update-kubeconfig`
that needs to be executed in order to connect to the cluster. This command will
include the IAM masters role ARN if applicable.

Disable all other outputs by default, but added `outputXxx` options to enable.

Fixes #3664

BREAKING CHANGE: cluster name output will not be synthesized by default. instead we synthesize an output that includes the full `aws eks update-kubeconfig` command. You can enable synthesis of the cluster name output using the `outputClusterName: true` options.

* update expectations

* update readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants