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

nixos/services.kubernetes.kubelet: handle non-lower case chars in hostname #315144

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

mattpolzin
Copy link
Contributor

@mattpolzin mattpolzin commented May 27, 2024

Description of changes

I discovered when enabling a minimally configured kubernetes master + node cluster on my computer that uppercase letters in the networking.hostName result in kubelet being unauthorized to set a node up. The node name ends up being a lowercased version of the hostname and that mismatch causes problems.

Errors are of the form:

leases.coordination.k8s.io "mattpolzin-scrappy" is forbidden: User "system:node:MattPolzin-Scrappy" cannot get resource "leases" in API group "coordination.k8s.io" in the namespace "kube-node-lease": can only access node lease with the same name as the requesting node

It seems like the most straight forward answer is to lowercase the system hostname when using it as a default kubelet.hostname. I also considered applying the lowercase function specifically where the kubelet.hostname is used as part of the CN for the relevant cert but seeing as how hostnames will always resolve as case insensitive there seems to be no reason not to apply it to the kubelet.hostname which is then most likely to prevent any similar problems in the future regardless of where the hostname is used.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@mattpolzin
Copy link
Contributor Author

@johanot @cafkafk would either of you be up for giving this one a look?

@mattpolzin
Copy link
Contributor Author

cc @jonpulsifer @vdemeester for potentially taking a look at this PR.

@johanot
Copy link
Contributor

johanot commented Jun 1, 2024

I approve of this. I just wonder if it could potentially break anything for others that rely on the old behavior. Maybe a rel note is in order?

@mattpolzin
Copy link
Contributor Author

Good idea. I can push a release note later today. Thanks.

Copy link
Contributor

@johanot johanot left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐯

@mattpolzin
Copy link
Contributor Author

@SuperSandro2000 I saw you reviewed as a committer on a recent PR in this module; can I ping you for a potential commit here as well?

@mattpolzin
Copy link
Contributor Author

Looks like I better re-request review now that I fixed a merge conflict with the release notes so I can claim the approvals label.

@mattpolzin
Copy link
Contributor Author

Apologies @vdemeester @johanot but could I bother either of you to re-up approval? I had to fix merge conflicts with the changelog update but everything else has remained the same.

@SuperSandro2000 SuperSandro2000 merged commit 3176d6f into NixOS:master Jun 25, 2024
21 checks passed
@mattpolzin mattpolzin deleted the default-nodename-fix branch June 25, 2024 20:46
@mattpolzin
Copy link
Contributor Author

Ah, appreciate that Sandro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants