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

Add configuration item to allow kubeadm join to use a dns name pointing to control plane #59288

Merged
merged 2 commits into from
Feb 22, 2018

Conversation

stevesloka
Copy link
Contributor

This adds a new flag (--apiserver-advertise-dns-address) to kubeadm which is used in node kubelet.confg to point to API server allowing users to define a DNS entry instead of an IP address.

Fixes kubernetes/kubeadm#411

Adds new flag `--apiserver-advertise-dns-address` which is used in node kubelet.confg to point to API server

// @timothysc @craigtracey

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 2, 2018
@timothysc
Copy link
Member

/cc @kubernetes/sig-cluster-lifecycle-pr-reviews

@k8s-ci-robot k8s-ci-robot added the sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. label Feb 3, 2018
@@ -145,6 +145,7 @@ func getAddonsSubCommands() []*cobra.Command {

if properties.use == "all" || properties.use == "kube-proxy" {
cmd.Flags().StringVar(&cfg.API.AdvertiseAddress, "apiserver-advertise-address", cfg.API.AdvertiseAddress, `The IP address or DNS name the API server is accessible on`)
cmd.Flags().StringVar(&cfg.API.AdvertiseDNSAddress, "apiserver-advertise-dns-address", cfg.API.AdvertiseDNSAddress, `The DNS name the API server is accessible on`)
Copy link
Member

Choose a reason for hiding this comment

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

I think I've turned a blind eye to some of the flag proliferation, this seems awfully redundant.

/cc @errordeveloper

Copy link

Choose a reason for hiding this comment

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

part of the issue is the previous advertiseaddress was actually a listen address not an advertise.

@timothysc timothysc removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 3, 2018
@timothysc timothysc self-assigned this Feb 3, 2018
@stevesloka
Copy link
Contributor Author

stevesloka commented Feb 3, 2018

Need a way to allow users to specify dns name for API server as well as the ip address in the event the API server host machine has multiple.

There are the San certs, however multiple can be passed so which one would you choose.

@jamiehannaford
Copy link
Contributor

Any reason why we can't just use --apiserver-cert-extra-sans? We'd also need to make sure the bootstrap config files are using the DNS name provided by join cmd (rather than IP which seems to currently be the case unless I'm mistaken).

@stevesloka
Copy link
Contributor Author

I started there when I began thinking through this PR to use --apiserver-cert-extra-sans, but you can pass multiple sans, so which one should I use? We could have a convention that the first one passed is the one to use, but thought that might be more confusing.

Copy link
Contributor

@craigtracey craigtracey left a comment

Choose a reason for hiding this comment

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

I think this is a pretty important change, and this will really help us close this gap. Thanks, @stevesloka!

@@ -57,7 +57,7 @@ func SetupMasterConfigurationFile(t *testing.T, tmpdir string, cfg *kubeadmapi.M
kind: MasterConfiguration
certificatesDir: {{.CertificatesDir}}
api:
advertiseAddress: {{.API.AdvertiseAddress}}
advertiseAddress: {{.API.AdvertiseDNSAddress}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change intentional? AdvertiseAddress should not be the same as AdvertiseDNSAddress

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope that's a mistake, thanks for catching.

AdvertiseAddress string `json:"advertiseAddress"`
// AdvertiseDNSAddress sets the DNS address for the API server to advertise.
AdvertiseDNSAddress string `json:"advertiseDNSAddress"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this naming a bit confusing as I don't think anything is being "advertised." While the kubelet uses the terminology of advertiseAddress to specify which IP the server is listening on, this new argument is being used only to indicate where a node should register itself. Perhaps a more descriptive argument would be controlPlaneEndpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think controlPlane make sense, I'll move to that, take out the args, and do a verify it works via the config.

@timothysc timothysc added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 6, 2018
@timothysc
Copy link
Member

per sig conversation, we should leverage the config object to allow for updates and try not to proliferate cmd line flags b/c anything we do will have to be maintained post GA.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 7, 2018
@stevesloka stevesloka force-pushed the apiServerDNS branch 2 times, most recently from e082520 to e58598b Compare February 7, 2018 15:46
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 7, 2018
@stevesloka stevesloka changed the title Add new flag for api-server-dns-name / use for client kubelet.conf Add configuration item to allow kubeadm join to use a dns name pointing to control plane Feb 7, 2018
@stevesloka
Copy link
Contributor Author

@timothysc @craigtracey I updated to only use the config, also rebased and pushed.

@@ -143,7 +143,7 @@ func getControlPlaneSubCommands(outDir, defaultKubernetesVersion string) []*cobr
cmd.Flags().StringVar(&cfg.KubernetesVersion, "kubernetes-version", cfg.KubernetesVersion, `Choose a specific Kubernetes version for the control plane`)

if properties.use == "all" || properties.use == "apiserver" {
cmd.Flags().StringVar(&cfg.API.AdvertiseAddress, "apiserver-advertise-address", cfg.API.AdvertiseAddress, "The IP address or DNS name the API server is accessible on")
cmd.Flags().StringVar(&cfg.API.AdvertiseAddress, "apiserver-advertise-address", cfg.API.AdvertiseAddress, "The IP address of the API server is accessible on")
Copy link
Member

Choose a reason for hiding this comment

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

So I need to look through history here. I think other changes that crib'd hostIP from self-hosting affected this. Sorry it's taking a while but we want the original intent to be preserved. @kad if you have a moment could you dig the change, otherwise i'll have to search for it tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually a defect. The kube-apiserver only accepts an IP for --advertise-address.
https://kubernetes.io/docs/reference/generated/kube-apiserver/

I believe what @stevesloka has here is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just for reference: Yes this can only be an IP and #56956 was just merged to validate this.

@stevesloka
Copy link
Contributor Author

Does anyone have time this week to review? Curious if the implementation is acceptable or if anyone has any additional comments.

@timothysc
Copy link
Member

/approve

@kubernetes/sig-cluster-lifecycle-pr-reviews - For transparency I'd prefer someone non-heptio to lgtm

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 13, 2018
@timothysc timothysc removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2018
Copy link
Member

@kad kad left a comment

Choose a reason for hiding this comment

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

small nit: may I suggest to split autogenerated changes to separate commit ?

if len(cfg.API.ControlPlaneEndpoint) > 0 {
errs := validation.IsDNS1123Subdomain(cfg.API.ControlPlaneEndpoint)
if len(errs) > 0 {
return "", fmt.Errorf("error parsing `ControlPlaneEndpoint` to valid dns subdomain")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe here we want to provide to user more information about error ? e.g. what is wrong with domain provided.

@stevesloka
Copy link
Contributor Author

@kad I spit the commits into 2, one for code and the other for autogen bazel deps. Also, I have the validation of the DNS address return the errors from validation method, and updated the error message to show those errors which get returned.

@kad
Copy link
Member

kad commented Feb 15, 2018

@stevesloka Thanks. Changes in cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go seems to be still in first commit. The rest looks good for me.

@stevesloka
Copy link
Contributor Author

@kad I've moved the zz_generated over to the 2nd commit

@stevesloka
Copy link
Contributor Author

Does anyone have any additional comments on this PR?

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.

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: stevesloka, 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-github-robot
Copy link

/test all

Tests are more than 96 hours old. Re-running tests.

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

@k8s-github-robot k8s-github-robot merged commit d7cadf5 into kubernetes:master Feb 22, 2018
@stevesloka stevesloka deleted the apiServerDNS branch February 22, 2018 14:36
k8s-ci-robot pushed a commit to kubernetes/website that referenced this pull request Apr 12, 2018
First-time kubeadm user here: The v1.10.0 docs indicate that config file use is experimental, but judging from the comments on kubernetes/kubernetes#59288 it looks like new features are beginning to be supported only in the config file. controlPlaneEndpoint is super useful for us and while I suspect the kubeadm init docs will ultimately be re-written to emphasize the config file options rather than flags (with appropriate examples and descriptions as the flags have now), it would've saved us some time today if we'd seen controlPlaneEndpoint in the config file example.
discordianfish added a commit to itskoko/kubecfn that referenced this pull request Apr 12, 2018
This switches kubeadm to use the new ControlPlaneEndpoint options
introduced in kubernetes/kubernetes#59288
zacharysarah pushed a commit to kubernetes/website that referenced this pull request Apr 16, 2018
First-time kubeadm user here: The v1.10.0 docs indicate that config file use is experimental, but judging from the comments on kubernetes/kubernetes#59288 it looks like new features are beginning to be supported only in the config file. controlPlaneEndpoint is super useful for us and while I suspect the kubeadm init docs will ultimately be re-written to emphasize the config file options rather than flags (with appropriate examples and descriptions as the flags have now), it would've saved us some time today if we'd seen controlPlaneEndpoint in the config file example.
@Sebi2020
Copy link

Is this merge request included in the last kubeadm release? If I try to use this flag, kubeadm complains
unknown flag: --apiserver-advertise-dns-address

@ATP-55
Copy link

ATP-55 commented Nov 16, 2022

Same here? How to use this flag? @stevesloka
unknown flag: --apiserver-advertise-dns-address
To see the stack trace of this error execute with --v=5 or higher

@ATP-55
Copy link

ATP-55 commented Nov 16, 2022

Or are we allowing to pass DNS name under this flag? "--apiserver-advertise-address"

@ATP-55
Copy link

ATP-55 commented Nov 24, 2022

Can someone update please?

@neolit123
Copy link
Member

you should use --control-plane-endpoint / ControlPlaneEndpoint (in config) which is a kubeadm construct / concept. it's the endpoint that sits in front of API servers.
the api server advertise "endpoint" does not allow using DNS names so only IPs are used.

controlPlaneEndpoint sets a stable IP address or DNS name for the control plane. It can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port. In case the controlPlaneEndpoint is not specified, the advertiseAddress + bindPort are used; in case the controlPlaneEndpoint is specified but without a TCP port, the bindPort is used. Possible usages are:

In a cluster with more than one control plane instances, this field should be assigned the address of the external load balancer in front of the control plane instances.
In environments with enforced node recycling, the controlPlaneEndpoint could be used for assigning a stable DNS to the control plane.

https://kubernetes.io/docs/reference/config-api/kubeadm-config.v1beta3/

for more questions please use #kubeadm on k8s slack.

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/kubeadm 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 Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. 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.

join w/ master dns name writes ip to kubelet config