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

kubeadm: Remove cluster name from JoinConfiguration #70757

Merged
merged 1 commit into from
Nov 9, 2018
Merged

kubeadm: Remove cluster name from JoinConfiguration #70757

merged 1 commit into from
Nov 9, 2018

Conversation

ereslibre
Copy link
Contributor

What type of PR is this?
/kind cleanup

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

Special notes for your reviewer:
None

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 7, 2018
@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. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 7, 2018
@timothysc
Copy link
Member

/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 Nov 7, 2018
@neolit123
Copy link
Member

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 7, 2018
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.

Same comment about failed conversion test.

@timothysc
Copy link
Member

/assign @fabriziopandini @luxas @timothysc

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 7, 2018
@ereslibre
Copy link
Contributor Author

I will add the conversion test tomorrow.

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.

@ereslibre thanks for this PR!

if I got this right, JoinConfiguration.ClusterName is used only to set the cluster name in the config map that gets returned from Discovery, and you are proposing to replace it with a constant.

I'm fine with this, even if I would use existing const DefaultClusterName instead of creating a new const & I will remove parameter passing this const along the chain of calls.

Now, what should be decided is if it is fine to keep the above constant as a clusterName when the above config will be saved into the bootstrap-kubelet.conf or if we want to replace the cluster name with ClusterConfiguration.ClusterName before saving bootstrap-kubelet.conf.

In other words:

Discovery --> TLSBootstrap kubeconfig with clusterName = Constants --> bootstrap-kubelet.conf

or

Discovery --> TLSBootstrap kubeconfig with clusterName = Constants --> Replace cluster name with ClusterConfiguration.ClusterName --> bootstrap-kubelet.conf

@ereslibre @luxas @timothysc @neolit123 opinions?

@neolit123
Copy link
Member

neolit123 commented Nov 7, 2018

Discovery --> TLSBootstrap kubeconfig with clusterName = Constants --> Replace cluster name with ClusterConfiguration.ClusterName --> bootstrap-kubelet.conf

+1 for this.
no strong opinions, but if we go for the other option it should be DefaultClusterName at least.

@ereslibre
Copy link
Contributor Author

Discovery --> TLSBootstrap kubeconfig with clusterName = Constants --> Replace cluster name with ClusterConfiguration.ClusterName --> bootstrap-kubelet.conf

+1 for this, will update the PR today.

cmd/kubeadm/app/cmd/join.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/constants/constants.go Outdated Show resolved Hide resolved
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.

@ereslibre
This version introduced a double second discovery, that is something we should avoid.
Could you kindly check if the approach I'm suggesting in comments is feasible for you?

cmd/kubeadm/app/apis/kubeadm/v1alpha3/defaults.go Outdated Show resolved Hide resolved
@@ -619,6 +619,12 @@ func fetchInitConfigurationFromJoinConfiguration(cfg *kubeadmapi.JoinConfigurati
return nil, nil, err
}

// Retrieve the final KubeConfig file with the cluster name discovered after fetching the cluster configuration
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should do discovery twice.
Instead I think we should change the TLS kubeconfig in place or create a new kubeconfig file from TLS kubeconfig but with a different cluster name (if you need prior art let me know)

This will allow to clean up the Discovery.For chain of calls from the clusterName field

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 changed the approach to generate a different one locally. Not resolving the conversation until you agree that is the best way.

@ereslibre
Copy link
Contributor Author

/retest

Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

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

LGTM apart from the comment

@@ -619,6 +619,16 @@ func fetchInitConfigurationFromJoinConfiguration(cfg *kubeadmapi.JoinConfigurati
return nil, nil, err
}

// Create the final KubeConfig file with the cluster name discovered after fetching the cluster configuration
clusterinfo := kubeconfigutil.GetClusterFromKubeConfig(tlsBootstrapCfg)
tlsBootstrapCfg = kubeconfigutil.CreateWithToken(
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work, as the client cert returned from TLS bootstrap would be overridden with the tls bootstrap token.
The way to do this is:

  1. Extract clusterinfo (like you do)
  2. Delete the existing cluster key and value in the .Clusters map
  3. Replace the current context's .Cluster value
  4. Add clusterinfo back to the .Clusters map with the new initConfiguration.ClusterName key

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luxas Out of curiosity, in the case you are mentioning, this is where discovery.For is supposed to return? (so len(cfg.Discovery.TLSBootstrapToken) == 0):

if len(cfg.Discovery.TLSBootstrapToken) == 0 {
return config, nil
}

@ereslibre
Copy link
Contributor Author

PR rebased.

@neolit123
Copy link
Member

/retest

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: ereslibre, 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 Nov 9, 2018
@fabriziopandini
Copy link
Member

@ereslibre thanks!
/lgtm
cleanup of clean up the Discovery.For chain of calls from the clusterName field can be addressed in another PR.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2018
@ereslibre
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit c3d05c8 into kubernetes:master Nov 9, 2018
@ereslibre ereslibre deleted the remove-cluster-name-from-join-configuration branch November 9, 2018 20:47
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants