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

Generate and approve CSRs for conntrol-plane and static workers nodes #1750

Merged
merged 2 commits into from
Jan 26, 2022

Conversation

kron4eg
Copy link
Member

@kron4eg kron4eg commented Jan 23, 2022

What this PR does / why we need it:
Fixes the issue that kubelets on control-plane and static workers nodes are service requests under self-signed certificates.

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 #1093

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Generate and approve CSRs for conntrol-plane and static workers nodes

@kubermatic-bot kubermatic-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. labels Jan 23, 2022
@kubermatic-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubermatic-bot kubermatic-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 23, 2022
@kron4eg kron4eg force-pushed the cp-csrs branch 4 times, most recently from 2110551 to 2a0e7ca Compare January 25, 2022 16:33
@kubermatic-bot kubermatic-bot 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 Jan 25, 2022
@kron4eg kron4eg marked this pull request as ready for review January 25, 2022 16:47
@kubermatic-bot kubermatic-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 25, 2022
Signed-off-by: Artiom Diomin <kron82@gmail.com>
Signed-off-by: Artiom Diomin <kron82@gmail.com>
@kron4eg
Copy link
Member Author

kron4eg commented Jan 26, 2022

/assign @xmudrii

Copy link
Member

@ahmedwaleedmalik ahmedwaleedmalik left a comment

Choose a reason for hiding this comment

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

Great work

/lgtm
/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2022
@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahmedwaleedmalik, kron4eg

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

@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: f75eb598de77f6ea6107ce63d37516893d313453

@kubermatic-bot kubermatic-bot merged commit d55cc58 into kubermatic:master Jan 26, 2022
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.4 milestone Jan 26, 2022
@kron4eg kron4eg deleted the cp-csrs branch January 26, 2022 10:09
Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

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

Retroactive reveiw.

Comment on lines +187 to +188
// Need to wait for the second CSR to appear
time.Sleep(20 * time.Second)
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 we should leave a log message that KubeOne is waiting 20 seconds for CSRs to appear. We already do that when we wait for other tasks (e.g. for the control plane instance to come up).

Comment on lines +237 to +249
if fmt.Sprintf("%s:%s", nodeUser, node.Hostname) != spec.Username {
return errors.New("")
}

if !sets.NewString(spec.Groups...).HasAll(groupNodes, groupAuthenticated) {
return errors.New("")
}

for _, usage := range spec.Usages {
if !isUsageInUsageList(usage, allowedUsages) {
return errors.New("")
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Why is this returning empty errors?

Comment on lines +251 to +258
csrBlock, rest := pem.Decode(spec.Request)
if csrBlock == nil {
return fmt.Errorf("no certificate request found for the given CSR")
}

if len(rest) != 0 {
return fmt.Errorf("found more than one PEM encoded block in the result")
}
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we use errors.New() here?

@kron4eg kron4eg mentioned this pull request Jan 27, 2022
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. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm 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. 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.

Kubelets on Control Plane hosts serve a invalid certificate with configuration defaults
4 participants