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

validate AdvertiseAddress in kubeadm init and other case #56956

Merged
merged 1 commit into from
Apr 11, 2018
Merged

validate AdvertiseAddress in kubeadm init and other case #56956

merged 1 commit into from
Apr 11, 2018

Conversation

Lion-Wei
Copy link

@Lion-Wei Lion-Wei commented Dec 8, 2017

What this PR does / why we need it:

When using kubeadm init --apiserver-advertise-address=****, apiserver-advertise-address` can only be ipv4 or ipv6 address, if people use domain name in this field, will not use it and silently get hostIP.

Add a warning in this case.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes kubernetes/kubeadm#590

Special notes for your reviewer:

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 8, 2017
@Lion-Wei
Copy link
Author

Lion-Wei commented Dec 8, 2017

/sig kubeadm
/cc @luxas
@discordianfish

@cblecker
Copy link
Member

cblecker commented Dec 8, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 8, 2017
@fabriziopandini
Copy link
Member

@Lion-Wei, thanks for this PR!
Before reviewing it, I was wandering if, instead of giving users an advice that kubeadm used the hostIP instead of the given dns name, we can:

  1. improve --apiserver-advertise-address in order to handle dns names as well (if this is a use case we want to support)
    or
  2. block the init sequence before it starts if a dns name is passed to --apiserver-advertise-address (basically raise an error in validation phase)

What do you think about?
/cc @luxas

@Lion-Wei
Copy link
Author

@fabriziopandini Thanks for replying. I'm not sure if make --apiserver-advertise-address accept dns name is a good idea, it's lots work, and I don't know weather there are other consideration, maybe need some discuss.
Add validation for --apiserver-advertise-address is a good idea for now, I think. There don't have any validate tight now, you can pass any string to this flag.

@discordianfish
Copy link
Contributor

@Lion-Wei I'm not completely sure where apiserver-advertise-address is used. I know it's used in the kube-proxy config where supporting a DNS name should be trivial and is required to connect to a ELB on AWS since they don't have static IPs. The apiserver-advertise-address might be used in other place where it's harder to support this. If that's the case, maybe we should have a different flag for 'everything it can use a DNS name'?

@discordianfish
Copy link
Contributor

discordianfish commented Dec 13, 2017

So this is a requirement for HA and probably blocking kubernetes/kubeadm#261 /cc @luxas

@petergardfjall
Copy link

@discordianfish : you're refering to kubernetes/kubeadm#261, right?

@discordianfish
Copy link
Contributor

@petergardfjall Oops, right. Thanks, fixed it!

@fabriziopandini
Copy link
Member

@Lion-Wei @discordianfish
I propose to discuss this at the next sig-meeting

Even if the advertise address is used in few parts of the kubeadm codebase, in the majority of cases no change are required because the value is used as a string.
However there are two tricky cases that should be addressed:

  • ipv4 or ipv6 tests
  • api server probe address

@Lion-Wei
Copy link
Author

Lion-Wei commented Dec 16, 2017

@fabriziopandini Thanks.

@fabriziopandini
Copy link
Member

@Lion-Wei as discussed in SIG-meeting today, we should go for raising a validation error if a dns name is passed to --apiserver-advertise-address; the apiserver-advertise-address should be a valid ipv4 or ipv6 address.

If the user should use dns names he can always use APIServerCertSANs.

Thanks again for your availability to change the PR in this direction; if you need additional info or help in changing the PR feel free to ping me on slack.

@discordianfish
Copy link
Contributor

@fabriziopandini Should I open a new issue for a option to set the kube-proxy endpoint?

@Lion-Wei
Copy link
Author

@fabriziopandini Thanks for your attention. I will do that ASAP.
@discordianfish I'm not very familiar with APIServerCertSANs, I will look into it, to see if this flag can solve the problem.

@discordianfish
Copy link
Contributor

discordianfish commented Dec 21, 2017

To clarify this:

  • --apiserver-advertise-address is the bind address. So it needs to be an IP on some interface or 0.0.0.0 to listen on all. Validating this was decided 👍
  • APIServerCertSANs specifies for which names the certificates generated are valid for. I'm already using this and it works fine 👍
  • TBD new flag would specify where kube-proxy is suppose to connect to (and this should support DNS names to use a ELB on AWS for example). Without this it's not possible to just run kubeadm init on every new master in a multi master setup, since it will always put in the IP of the last provisioned server in the kube-proxy configmap. 👎

@fabriziopandini
Copy link
Member

@discordianfish please open a issue for the the kube-proxy endpoint in https://github.com/kubernetes/kubeadm/issues

@Lion-Wei
Copy link
Author

@fabriziopandini , I found it's little complicated. Because we will set cfg.API.AdvertiseAddress to default in SetInitDynamicDefaults before pre-flight check. And need this args for http proxy check and other thins.
I think maybe use should check this args in SetInitDynamicDefaults part

@fabriziopandini
Copy link
Member

@Lion-Wei
I think that checking this arg in SetInitDynamicDefaults is acceptable (by the way we are already doing this for KubernetesVersion); please check that this apply to all the commands with --advetise-address in input.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 25, 2017
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

Thanks!

One final question to be addressed: it is really necessary to validate parameters inside each phases or it is enough to implement the validation in SetInitDynamicDefaults (which is execute before each phases)?

@@ -51,6 +52,10 @@ func EnsureProxyAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Inte
return fmt.Errorf("error when creating kube-proxy service account: %v", err)
}

// validate cfg.API.AdvertiseAddress.
if err := validation.ValidateApiserverAdvertiseAddress(cfg.API.AdvertiseAddress); err != nil {
Copy link
Member

@fabriziopandini fabriziopandini Dec 27, 2017

Choose a reason for hiding this comment

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

The addon phase is called by three commands: init, upgrade, and phase addon; all this command executes
SetInitDynamicDefaults (that executes a first validation of the apiserver) before invoking EnsureProxyAddon (that execute a second validation)
If possible, please remove the second validation; the same apply to other phases as well

Copy link
Author

Choose a reason for hiding this comment

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

That't true, thanks, sorry didn't notice. : (
Then I guess there don't have other case to validate this flag.

Copy link
Author

Choose a reason for hiding this comment

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

@fabriziopandini Besides, need I add unit test of this case? Seems like masterconfig.go don't have any unit test.

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 8, 2018
@Lion-Wei
Copy link
Author

Lion-Wei commented Feb 8, 2018

@fabriziopandini , kindly ping, need another /lgtm. : )

@fabriziopandini
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 11, 2018
@cblecker
Copy link
Member

ping @krousey @luxas @timothysc for approval

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 24, 2018
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 24, 2018
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 24, 2018
@Lion-Wei
Copy link
Author

Friendly ping @fabriziopandini @krousey . Since this has been ready for a while.

@fabriziopandini
Copy link
Member

@Lion-Wei sorry I missed the lgtm removed
/lgtm
/CC @kubernetes/sig-cluster-lifecycle-pr-reviews for approval

@k8s-ci-robot k8s-ci-robot added sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 26, 2018
@cblecker
Copy link
Member

/test pull-kubernetes-typecheck

@Lion-Wei
Copy link
Author

/test all

@Lion-Wei
Copy link
Author

Lion-Wei commented Apr 9, 2018

friendly ping @jbeda @timothysc ,looking forward for approve. : )

@timothysc
Copy link
Member

/test all

Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini, Lion-Wei, timothysc

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 Apr 11, 2018
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Apr 11, 2018

@Lion-Wei: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-gke eeaa524e29b445c9aa6b4db55a7491d7a6d53139 link /test pull-kubernetes-e2e-gke

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

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. 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. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-proxy configmap not using apiserver-advertise-address