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: support kubeadm join --dry-run #103027

Merged

Conversation

Haleygo
Copy link
Contributor

@Haleygo Haleygo commented Jun 20, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

add --dry-run flag for "kubeadm join", run "kubeadm join --dry-run" to see what would be done

Which issue(s) this PR fixes:

Fixes kubernetes/kubeadm#2505

Special notes for your reviewer:

Does this PR introduce a user-facing change?

kubeadm: add support for dry running "kubeadm join". The new flag "kubeadm join --dry-run" is similar to the existing flag for "kubeadm init/upgrade" and allows you to see what changes would be applied.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 20, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @Haleygo. 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 area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 20, 2021
@Haleygo Haleygo force-pushed the feature/add-kubeadm-join-dryrun branch from 6eea44b to 2d87eb7 Compare June 21, 2021 03:38
@pacoxu
Copy link
Member

pacoxu commented Jun 21, 2021

/ok-to-test
thanks for taking this.

@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 Jun 21, 2021
@Haleygo Haleygo force-pushed the feature/add-kubeadm-join-dryrun branch from 2d87eb7 to fe349f6 Compare June 21, 2021 09:45
@Haleygo
Copy link
Contributor Author

Haleygo commented Jun 21, 2021

/retest

Comment on lines +190 to +198
// If we're dry-running, set CertificatesDir to default value to get the right cert path in static pod yaml
if data.DryRun() {
cfg.CertificatesDir = filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.DefaultCertificateDir)
}
Copy link
Member

@neolit123 neolit123 Jun 21, 2021

Choose a reason for hiding this comment

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

but during dryrun the directory where the certs were written is now data.CertificateWriteDir().
are you getting errors if this is not added here?

[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't get errors here, but if I don't change it, it will write tmp cert dir path to static pod yaml instead of "/etc/kubernetes/pki/".
And If I remake CreateStaticPodFiles() to accept path directly, GetStaticPodSpecs need to do the same and other places that use them.
any suggestion? @neolit123

Copy link
Member

@neolit123 neolit123 Jun 23, 2021

Choose a reason for hiding this comment

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

making these functions accept a directory seems like a good idea for dry-run / testing?
...that likely is going to make this change a lot bigger though.

Comment on lines +229 to +236
// If we're dry-running, download certs to tmp dir
if data.DryRun() {
cfg.CertificatesDir = data.CertificateWriteDir()
}
Copy link
Member

@neolit123 neolit123 Jun 21, 2021

Choose a reason for hiding this comment

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

related question to [1]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it's very tricky to set CertificatesDir during the whole dry-run process.
First, I need to download certs to the right tmp dir but I can't pass data.CertificateWriteDir() to copycerts.DownloadCerts and certsphase.CreatePKIAssets directly. And remake the args of those two func will be a big work.
Then, when it comes to CreateStaticPodFiles(), CertificatesDir should be set as "/etc/kubernetes/pki" cause it will be written into static pod yaml and printed later, so I change it again

@neolit123
Copy link
Member

neolit123 commented Jun 29, 2021

thank you very much for the efforts @Haleygo
this has become a big change and i need to find time to review it again.

one problem is code freeze (for 1.22) is next week (July 8th) and we need to make sure that if we are going to merge this it does not make regressions...so that is a bit of a concern.

in the meantime, more reviews from others are appreciated.

@Haleygo
Copy link
Contributor Author

Haleygo commented Jun 29, 2021

thank you very much for the efforts @Haleygo
this has become a big change and i need to find time to review it again.

one problem is code freeze (for 1.22) is next week (July 8th) and we need to make sure that if we are going to merge this it does not make regressions...so that is a bit of a concern.

in the meantime, more reviews from others are appreciated.

of course, in the meantime, I will do more test on this.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 5, 2021
@Haleygo Haleygo force-pushed the feature/add-kubeadm-join-dryrun branch from 2d0bbae to 3d6c2d5 Compare July 5, 2021 15:42
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 5, 2021
@neolit123
Copy link
Member

i will get back to reviewing this PR after code freeze for 1.22.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 6, 2021
@neolit123
Copy link
Member

would you have time to work on this again @Haleygo ?
PR needs rebase. looks mostly good to me, but i need to have another review pass.

@Haleygo Haleygo force-pushed the feature/add-kubeadm-join-dryrun branch from 3d6c2d5 to 25d209f Compare August 9, 2021 15:23
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2021
@Haleygo
Copy link
Contributor Author

Haleygo commented Aug 9, 2021

would you have time to work on this again @Haleygo ?
PR needs rebase. looks mostly good to me, but i need to have another review pass.

@neolit123 Sure thing, done.

@neolit123
Copy link
Member

^ found one potential problem.

about these comments:
#103027 (comment)
#103027 (comment)

i think it's still not ideal that we are mutating a cfg field during dry-run, but this PR is already quite big and i think it can be fixed separately.

@Haleygo
Copy link
Contributor Author

Haleygo commented Aug 10, 2021

^ found one potential problem.

about these comments:
#103027 (comment)
#103027 (comment)

i think it's still not ideal that we are mutating a cfg field during dry-run, but this PR is already quite big and i think it can be fixed separately.

+1, maybe create another task? and I would like to help with that.
so should I add some todo comment on it now?

@neolit123
Copy link
Member

+1, maybe create another task? and I would like to help with that.
so should I add some todo comment on it now?

sure, you can open an issue with some details in kubernetes/kubeadm and assign yourself.

@neolit123
Copy link
Member

/lgtm
/approve

thanks, let's see if we get some failures after the change.
our e2e tests should be able to catch them.

@neolit123
Copy link
Member

/retest

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Haleygo, neolit123

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 10, 2021
@k8s-ci-robot k8s-ci-robot merged commit 40c9066 into kubernetes:master Aug 10, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Aug 10, 2021
@Haleygo Haleygo deleted the feature/add-kubeadm-join-dryrun branch August 11, 2021 08:24
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/feature Categorizes issue or PR as related to a new feature. 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. priority/backlog Higher priority than priority/awaiting-more-evidence. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubeadm join: add support for dry-run
6 participants