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

fix(eks): fargateCluster compatibility with AuthenticationMode.API #31267

Merged
merged 16 commits into from
Sep 11, 2024

Conversation

pahud
Copy link
Contributor

@pahud pahud commented Aug 30, 2024

Issue # (if applicable)

This PR ensures the eks fargateCluster compatibility with AuthenticationMode.API

Closes #30888

Reason for this change

The FargateCluster assumes the authentication mode is always config map and create the podExectionRole mapping using props.cluster.awsAuth.addRoleMapping(). This won't work when authenticationMode is API because in this mode, config map is not supported and this statement would just fail.

We need to add an conditional check, only when the cluster supports configmap will it run the addRoleMapping() statement. At this moment, the following authenticationMode would support configmap:

  1. undefined
  2. CONFIG_MAP
  3. API_AND_CONFIG_MAP

Description of changes

Description of how you validated changes

  • update the integ test
  • manual deployments

Checklist


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

@github-actions github-actions bot added the p2 label Aug 30, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team August 30, 2024 12:46
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Aug 30, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review August 30, 2024 16:15

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@pahud pahud marked this pull request as ready for review August 31, 2024 01:33
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1 and removed p2 labels Aug 31, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Aug 31, 2024
mergify bot pushed a commit that referenced this pull request Sep 4, 2024
…ode (#31258)

### Issue # (if applicable)

This PR improve the compatibility for `albController` with `authenticationMode.API`

related to #30888

We will address Fargate compatibility in #31267

### Reason for this change

- When `authenticationMode.API` is specified, no aws-auth configMap should be created
- albController should not depend on `cluster.awsAuth` because that would create aws-auth configmap, which is not required in `API` mode.



### Description of changes



### Description of how you validated changes

**unit tests**
- validate the behavior in all conditions of the `authenticationMode`

**integ test**
- add a new integ test with API mode to ensure successful deployment


## debugger

```js
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Jest",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
      "cwd": "${workspaceFolder}/packages/aws-cdk-lib",
      "args": [
        "--verbose",
        "-i",
        "--no-cache",
        "test/alb-controller.test.ts",
      ],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "outFiles": [
        "${workspaceFolder}/**/*.(m|c|)js",
        "!**/node_modules/**"
      ],
    }
  ]
}
```



### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
rix0rrr
rix0rrr previously requested changes Sep 4, 2024
Comment on lines 204 to 205
const supportConfigMap = props.cluster.authenticationMode !== AuthenticationMode.API ? true : false;
if (supportConfigMap) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me like something that was unconditional is now conditional, and PR body doesn't tell me anything about what the problem was or why this is the fix.

That's leaving me to wonder: what are the backwards compatibility implications of this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Just fixed.

'system:node-proxier',
],
});
const supportConfigMap = props.cluster.authenticationMode !== AuthenticationMode.API ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concluding support for something by exclusion works in a closed world, but I'm not sure the world is actually closed. If a 4th authentication method is added in the future, will this condition have to be updated? Isn't is safer to inclusively check for one of the CONFIG_MAP options?

@@ -1142,6 +1142,37 @@ You can disable granting the cluster admin permissions to the cluster creator ro

> **Note** - Switching `bootstrapClusterCreatorAdminPermissions` on an existing cluster would cause cluster replacement and should be avoided in production.

When a `FargateCluster` is created with `AuthenticationMode.API`, by default the cluster creator role would be added into the AccessEntry with `AmazonEKSClusterAdminPolicy` unless `bootstrapClusterCreatorAdminPermissions` is disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this line is trying to tell me, exactly.

Isn't the behavior of adding the creator user, except when you set a flag, the same as the behavior describer 2 sentences above? What does the qualification about the AuthenticationMode add? Why is this a separate line and not integrated into the previous description?

Please refrain from using non-present tenses like "would". It's not the Amazon docs writing style, and is unnecessarily indirect. We can just say "will".

I can spot it just above this change as well. I know you didn't change it in this PR, but improving the overall writing style and condensing/rewriting bad or redundant docs will be a help overall. Better than endlessly adding standalone lines just to have covered the new feature, that will make the docs unreadable over time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Yes it is redundant after reviewing the description. I just removed it from the README.

@rix0rrr rix0rrr self-assigned this Sep 4, 2024
@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Sep 4, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@pahud pahud changed the title feat(eks): fargateCluster compatibility with AuthenticationMode.API chore(eks): fargateCluster compatibility with AuthenticationMode.API Sep 9, 2024
@pahud pahud changed the title chore(eks): fargateCluster compatibility with AuthenticationMode.API fix(eks): fargateCluster compatibility with AuthenticationMode.API Sep 9, 2024
@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Sep 9, 2024
@pahud pahud force-pushed the fargatecluster-api-mode branch 2 times, most recently from 56f1a72 to ddf65bb Compare September 9, 2024 23:58
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 9, 2024 23:59

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@pahud pahud force-pushed the fargatecluster-api-mode branch from 10c58a4 to 75cb15a Compare September 10, 2024 00:33
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a 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.

@aws-cdk-automation aws-cdk-automation dismissed their stale review September 10, 2024 01:21

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@pahud pahud requested a review from rix0rrr September 10, 2024 02:29
@pahud
Copy link
Contributor Author

pahud commented Sep 10, 2024

Hi @rix0rrr , all addressed. Thank you.

Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think Pahud has addressed Rico's feedback. Approving on behalf for Rico. In summary, this shouldn't be a breaking change because the original code won't work when authenticationMode is API because in this mode, config map is not supported and this statement would just fail.

@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@GavinZZ GavinZZ added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Sep 11, 2024
@GavinZZ
Copy link
Contributor

GavinZZ commented Sep 11, 2024

@mergify update

Copy link
Contributor

mergify bot commented Sep 11, 2024

update

❌ Mergify doesn't have permission to update

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/github-merit-badger.yml without workflows permission

@GavinZZ GavinZZ removed pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr/needs-cli-test-run This PR needs CLI tests run against it. labels Sep 11, 2024
@GavinZZ GavinZZ dismissed rix0rrr’s stale review September 11, 2024 21:08

Dismissing stale review as I believe Rico's comments are addressed.

Copy link
Contributor

mergify bot commented Sep 11, 2024

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 960ff89
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify mergify bot merged commit 4d12833 into aws:main Sep 11, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Sep 11, 2024

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).

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-eks: albController and FargateCluster compatibility with AuthenticationMode.API mode
4 participants