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 node-name flag to init phase #48594

Merged
merged 1 commit into from
Jul 12, 2017
Merged

Add node-name flag to init phase #48594

merged 1 commit into from
Jul 12, 2017

Conversation

GheRivero
Copy link
Contributor

@GheRivero GheRivero commented Jul 7, 2017

What this PR does / why we need it: Allow to specify a node-name instead of relaying in os.Hostname()
This is useful where kubelet use the name given by the cloud-provider to
register the node.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): Partially fix: kubernetes/kubeadm#64

Release note:

Added new flag to `kubeadm init`: --node-name, that lets you specify the name of the Node object that will be created

@k8s-ci-robot k8s-ci-robot added 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 Jul 7, 2017
@k8s-ci-robot
Copy link
Contributor

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

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. I understand the commands that are listed here.

@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-label-needed 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 Jul 7, 2017
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.

There is more than this needed to be done.
Default cfg.NodeName in cmd/kubeadm/app/cmd/defaults.go to the hostname.
Then only use cfg.NodeName for that purpose.

Replace all os.Hostname() and node.GetHostname("") instances with cfg.NodeName.

@luxas
Copy link
Member

luxas commented Jul 7, 2017

/ok-to-test
/release-note

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note-label-needed labels Jul 7, 2017
@timothysc timothysc added this to the v1.7 milestone Jul 7, 2017
@timothysc timothysc added cherrypick-candidate sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. labels Jul 7, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 7, 2017
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 7, 2017
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.

Thanks @GheRivero!

/lgtm

cc @caesarxuchao @wojtek-t for cherrypick-candidate

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2017
@luxas
Copy link
Member

luxas commented Jul 7, 2017

/retest

@dmmcquay
Copy link
Contributor

dmmcquay commented Jul 7, 2017

/lgtm

@luxas
Copy link
Member

luxas commented Jul 7, 2017 via email

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 8, 2017
@luxas
Copy link
Member

luxas commented Jul 8, 2017

/retest

@wojtek-t
Copy link
Member

@luxas - thanks a lot for providing the rationale. This sounds reasonable to me.

@luxas @GheRivero - please add a release note to the PR (explaining what user problem it is fixing) and I will approve the cherrypick.

@luxas
Copy link
Member

luxas commented Jul 10, 2017

/retest

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 10, 2017
@luxas
Copy link
Member

luxas commented Jul 10, 2017

@wojtek-t Release note added, should be good to go

@dmmcquay
Copy link
Contributor

/test pull-kubernetes-e2e-kops-aws

@dmmcquay
Copy link
Contributor

/lgtm

@luxas
Copy link
Member

luxas commented Jul 11, 2017

/retest

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 11, 2017
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.

Minor nits from latest push -- thanks for adding a validation function!
The presubmits are broken anyway, so it makes sense to fix the nits while waiting.

}{
{"", nil, false}, // ok if not provided
{"1234", nil, true}, // supported
{hostname, nil, true}, // supported
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 hard coding the value here makes sense instead of getting something from os.Hostname as that might depend on the env. What about if you run the unit test on a node with an upper-case hostname?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -177,6 +203,7 @@ func TestValidateIPNetFromString(t *testing.T) {
}

func TestValidateMasterConfiguration(t *testing.T) {
nodename, _ := os.Hostname()
Copy link
Member

Choose a reason for hiding this comment

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

Just have something static here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -71,5 +72,13 @@ func setInitDynamicDefaults(cfg *kubeadmapi.MasterConfiguration) error {
}
}

if cfg.NodeName == "" {
Copy link
Member

Choose a reason for hiding this comment

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

This can actually be trimmed down to cfg.NodeName = node.GetHostname(cfg.NodeName)

Copy link
Member

Choose a reason for hiding this comment

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

Please do this same thing in join.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

func ValidateNodeName(nodename string, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if node.GetHostname(nodename) != nodename {
allErrs = append(allErrs, field.Invalid(fldPath, nodename, "nodename is not valid"))
Copy link
Member

Choose a reason for hiding this comment

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

nit: nodename is not valid, must be lower case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2017
Allow to specify a node-name instead of relaying in `os.Hostname()`
This is useful where kubelet use the name given by the cloud-provider to
register the node.

Partially fix: kubernetes/kubeadm#64
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2017
@GheRivero
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 12, 2017
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.

Very well. Thanks for rebasing @GheRivero

/lgtm

@luxas
Copy link
Member

luxas commented Jul 12, 2017

/retest

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GheRivero, dmmcquay, luxas

Associated issue: 64

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 80531cc into kubernetes:master Jul 12, 2017
k8s-github-robot pushed a commit that referenced this pull request Jul 13, 2017
…48538-upstream-release-1.7

Automatic merge from submit-queue

Automated cherry pick of #48594 #48538

Cherry pick of #48594 #48538 on release-1.7.

#48594: Add node-name flag to `init` phase
#48538: Add node-name flag to `join` phase
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

k8s-github-robot pushed a commit that referenced this pull request Aug 5, 2017
Automatic merge from submit-queue

kubeadm: Implementing the kubeconfig phase fully

**What this PR does / why we need it:**
This contains implementation of kubeconfig phases in kubeadm, which is part of the wider effort of implementing phases in kubeadm, previously in alpha stage.

The original proposal for this activity can be found [here](https://github.com/kubernetes/kubeadm/pull/156/files) and related comments.

Kubeadm phase implementation checklist is defined [here](kubernetes/kubeadm#267)

Common implementation guidelines and principles for all phases are defined [here](https://docs.google.com/document/d/1VQMyFIVMfRGQPP3oCUpfjiWtOr3pLxp4g7cP-hXQFXc/edit?usp=sharing)

This PR implements:

- [x] kubeadm phase kubeconfig
  - [x] kubeadm phase kubeconfig all
  - [x] kubeadm phase kubeconfig admin
  - [x] kubeadm phase kubeconfig kubelet
  - [x] kubeadm phase kubeconfig scheduler
  - [x] kubeadm phase kubeconfig controller-manager
  - [x] kubeadm phase kubeconfig user

**Which issue this PR fixes:**
kubernetes/kubeadm#350

**Special notes for your reviewer:**

This PR implements the second phases of kubeadm init; implementation of this PR follow the same approach already used for #48196 (cert phases).

Please note that:
- the API - phase\kubeconfig.go - is now totally free by any UX concerns, and implements only the core logic for kubeconfig generation.
- the UX - cmd\phase\kubeconfig.go - now takes charge of UX commands and kubeadm own's rules for kubeconfig files in /etc/kubernetes folder (e.g. create only if not already exists)
- The PR includes also a fix for a regression on a unit test for phase certs introduced by #48594 and few minor code changes in phase certs introduced to avoid code duplication between the two phases.
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 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.

kubeadm should not assume that hostname == nodename
9 participants