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

Allow configurable backend modes for aws-iam-authenticator #9500

Merged
merged 1 commit into from
Aug 7, 2020

Conversation

WarpRat
Copy link
Contributor

@WarpRat WarpRat commented Jul 5, 2020

This is a small configuration change to allow configuring a custom list of backend modes for aws-iam-authenticator (#9468) The available options are MountedFile, EKSConfigMap, or CRD. Any number of these can be selected in order of preference in a comma separated list. The default is still MountedFile.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 5, 2020
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 5, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @WarpRat!

It looks like this is your first PR to kubernetes/kops 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kops has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @WarpRat. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 5, 2020
@k8s-ci-robot k8s-ci-robot requested review from hakman and mikesplain July 5, 2020 22:21
@WarpRat
Copy link
Contributor Author

WarpRat commented Jul 5, 2020

I signed it

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 5, 2020
@rifelpet
Copy link
Member

rifelpet commented Jul 5, 2020

/ok-to-test

you'll need to run make apimachinery crds too

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 5, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 5, 2020
@WarpRat WarpRat marked this pull request as ready for review July 5, 2020 23:15
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 5, 2020
@hakman
Copy link
Member

hakman commented Jul 8, 2020

@fred-vogt could you take a look at this? Thanks!

@fred-vogt
Copy link

@hakman, @WarpRat - will do.

@fred-vogt
Copy link

fred-vogt commented Jul 8, 2020

@WarpRat, @hakman - had to update my KOPS custom build instructions to work for a Mac.

Good news - got builds / uploads working from my Mac

Test plan:

  • default - should result in previous behavior (MountedFile)
  • custom - try some combos of CRD,EKSConfigMap,MountedFile

@hakman
Copy link
Member

hakman commented Jul 8, 2020

No worries. Thanks! :)

@fred-vogt
Copy link

fred-vogt commented Jul 8, 2020

@WarpRat, @hakman - I did the first test - it doesn't work.

Looks like aws-iam-authenticator isn't working in v1.19.0-alpha.1 - unrelated to this PR.

kubectl:

error: You must be logged in to the server (Unauthorized)
$ aws-iam-authenticator token -i <cluster-name>  # works

kube-api-server:

Unable to authenticate the request due to an error: [
  invalid bearer token, 
  Post https://127.0.0.1:21362/authenticate?timeout=30s: 
    x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs
]

backend-mode is being passed

...
  containers:
  - args:
    - server
    - --config=/etc/aws-iam-authenticator/config.yaml
    - --state-dir=/var/aws-iam-authenticator
    - --kubeconfig-pregenerated=true
    - --backend-mode=MountedFile
...

@rifelpet
Copy link
Member

rifelpet commented Jul 8, 2020

I think there are a couple changes we should make here:

  1. The image should be upgraded to 0.5.1. --backend-mode was introduced in 0.5.0 and this manifest is still on 0.4.0. We can probably just pull the changes from Update AWS IAM Authenticator to 0.5.0 #8423 and Switch AWS IAM Authenticator to use non-scratch image #8555 back in as well as bump to 0.5.1 (they were reverted in Revert AWS IAM Authenticator upgrade to 0.5.0 on master #8670 ) but its worth double checking the recommended manifest in 0.5.1 to pick up any other changes.
  2. Since we allow a configurable image, it's possible for someone to pin it to a <0.5.0 version in which case upgrading to this version of kops will add the --backend-mode flag which will cause their setup to break. I think we can avoid that by having the default behavior be no --backend-mode argument rather than --backend-mode=MountedFile

The cert issue might be related to @johngmyers's recent cert issuance refactoring. I wish we had automated test coverage for this feature but the prerequisite AWS setup is nontrivial for our prow jobs. It's probably worth upgrading to 0.5.1 first before we continue with any cert troubleshooting though.

@rdrgmnzs
Copy link
Contributor

rdrgmnzs commented Jul 9, 2020

+1 what @rifelpet said, if someone has the --backend-mode flag set with a version of the authenticator < 0.5.0 it'll just cause the authentication to fail with unknown flag: --backend-mode

@WarpRat WarpRat requested a review from rifelpet July 29, 2020 07:12
@WarpRat
Copy link
Contributor Author

WarpRat commented Jul 30, 2020

Thanks for pointing me in the right direction on those tests @rifelpet

I also noticed that we were going to hit this issue with the cluster-id if a user didn't have a mounted file as one of the backend options, since normally the user defines that in config.yaml:

data:
config.yaml: |
# a unique-per-cluster identifier to prevent replay attacks
# (good choices are a random token or a domain name that will be unique to your cluster)
clusterID: my-dev-cluster.example.com

I added the same conditional around mounting that config file to remove the config cli flag and set the cluster-id to the master's public API DNS address.

@@ -37,9 +37,16 @@ spec:
image: {{ or .Authentication.Aws.Image "602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-iam-authenticator:v0.4.0" }}
args:
- server
{{- if or (not .Authentication.Aws.BackendMode) (contains "MountedFile" .Authentication.Aws.BackendMode) }}
Copy link
Member

Choose a reason for hiding this comment

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

We have two version of the the addon manifest (two template files) one for k8s 1.10+ and one for k8s 1.12+. Given that we only updated the 1.12+ manifest to authenticator 0.5.1: eae3fd8#diff-49ab9104184d27772708fb0ecd00e0aa we dont need to add BackendMode functionality to the 1.10+ manifest, so we can probably remove all the changes to this file.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. area/provider/aws Issues or PRs related to aws provider and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 6, 2020
@WarpRat WarpRat force-pushed the 9468 branch 2 times, most recently from 16e2cdf to bdf6014 Compare August 6, 2020 07:46
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 6, 2020
Copy link
Member

@rifelpet rifelpet left a comment

Choose a reason for hiding this comment

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

Looks good overall, a few documentation nits and youll need to rerun ./hack/updated-expected.sh since some of the outputs changed due to the recent 1.19 alpha release.

/assign @rdrgmnzs
in case you have any additional feedback.

docs/authentication.md Outdated Show resolved Hide resolved
docs/authentication.md Outdated Show resolved Hide resolved
@rdrgmnzs
Copy link
Contributor

rdrgmnzs commented Aug 6, 2020

Just reviewed, I think you guys covered everything. LGTM for landing once the expected test results are fixed.

@WarpRat
Copy link
Contributor Author

WarpRat commented Aug 7, 2020

/retest

@rifelpet
Copy link
Member

rifelpet commented Aug 7, 2020

/lgtm
/approve

thanks for sticking with it! looking forward to using these new fields

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 7, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rifelpet, WarpRat

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 7, 2020
@rifelpet
Copy link
Member

rifelpet commented Aug 7, 2020

/test pull-kops-e2e-cni-kuberouter

@k8s-ci-robot k8s-ci-robot merged commit b940224 into kubernetes:master Aug 7, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/addons area/api area/documentation area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants