Skip to content

Make kubernetes dns addon more configurable #55834

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

Merged
merged 1 commit into from
Mar 9, 2019

Conversation

juselius
Copy link
Contributor

@juselius juselius commented Feb 15, 2019

Motivation for this change

Sometimes there is need to have greater control over the cluster DNS, for example augmenting it with additional service discovery (i.e. Consul), or adding DNS records for internal subdomains. With mode Reconcile, all local changes to the maps are instantly overwritten. Changing the Deployment and ConfigMap to EnsureExists allows the user the change the maps after installation.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@juselius juselius requested a review from infinisil as a code owner February 15, 2019 14:55
@srhb
Copy link
Contributor

srhb commented Feb 15, 2019

Wouldn't this make any subsequent changes in Nix be ignored silently?
cc @johanot

@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Feb 15, 2019
@juselius juselius changed the title Make kubernetes addons more configurable Make kubernetes dns addon more configurable Feb 15, 2019
@juselius
Copy link
Contributor Author

@srhb Probably yes, but that's what you want if you have local changes. It's quite easy to track upstream changes:

  1. Save the relevant maps
  2. Delete them
  3. Let addon-manager recreate them
  4. Merge in local changes

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Feb 15, 2019
@srhb
Copy link
Contributor

srhb commented Feb 15, 2019

I just worry that it's unintuitive from the perspective of NixOS. I'll let @johanot chime in though, since he's actually using Kubernetes in production, and I'm not. :)

@juselius
Copy link
Contributor Author

@srhb I'm running kubernetes in production, and I spent quite a few hours trying to come up with a sensible and stable workaround (like using dnsmasq on the host(s)) which would not require messing with the defaults. Nothing really worked out. So unfortunately this was the only practical solution left in the end.

@johanot
Copy link
Contributor

johanot commented Feb 15, 2019

@juselius Isn't your usecase an argument for opting out of the kubernetes.dns module completely, i.e. services.kubernetes.addons.dns.enable = false and then deploy the dns service manually or add a custom addon to the addon manager with EnsureExists? I'd argue that Reconcile is the intuitive choice from a declarative point of view.

@juselius
Copy link
Contributor Author

@johanot Well, yes and no. It's much easier to track nixos when a) all you have to do is delete the deployment and configmap to get the new defaults b) ad you have a patch yaml for local changes. But I see the problem now. Everybody without local modifications end up in dire straits. Would a an option e.g. "allowLocalChanges" make the patch more palatable?

@johanot
Copy link
Contributor

johanot commented Feb 15, 2019

Well yes - especially if the default behavior is preserved.

I think it would be slightly prettier with e.g. mode, type = enum [ "Reconcile" "EnsureExists" ];, default = "Reconcile", but that's just opinion. :)

@juselius
Copy link
Contributor Author

@johanot Good idea! I'll post a new PR.

@GrahamcOfBorg GrahamcOfBorg added 10.rebuild-linux: 1-10 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Feb 16, 2019
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.

The more generic option, I think should have a more generic description as well. Consider something along the lines of:

description = ''
  Controls the addon manager reconciliation mode for the DNS addon.
  See: <link
  xlink:href="https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/addon-manager/README.md"/>
'';

@juselius
Copy link
Contributor Author

Thanks @johanot!

@srhb
Copy link
Contributor

srhb commented Feb 16, 2019

@GrahamcOfBorg eval

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 now. Thanks @juselius

@johanot
Copy link
Contributor

johanot commented Feb 16, 2019

@juselius Can you please squash the entire changeset down to one commit?

@juselius
Copy link
Contributor Author

@johanot done!

@johanot
Copy link
Contributor

johanot commented Feb 17, 2019

Oh.. Sorry I didn't see this before. The commit message should be prefixed with nixos/kubernetes:, instead of kubernetes:, since it involves changes to the NixOS module, not the package.

reconcileMode = mkOption {
description = ''
Controls the addon manager reconciliation mode for the DNS addon.
See: <link xlink:href="https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/addon-manager/README.md"/>
Copy link
Member

Choose a reason for hiding this comment

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

Mini-nitpick: Descriptions should end with a .

@juselius juselius force-pushed the k8s-coredns branch 2 times, most recently from 55c07e4 to 83d6447 Compare February 19, 2019 07:27
@danbst
Copy link
Contributor

danbst commented Mar 4, 2019

I find usecases in PR description more compelling than current option description. For a new guy like me, it is not clear why this once setting is exported as NixOS option, but others are not.

Another problem is that only some of "addons" allow this override. That looks a bit ad-hoc. Maybe note about that in option description as well? Otherwise it would require looking into module code to find out what this is for.

Allow coredns ConfigMap and Depolyment to be editable by the user. An use
case is augmenting the default, generated dns records with local services.
@juselius
Copy link
Contributor Author

juselius commented Mar 9, 2019

@danbst Good suggestion! I have added a line in the description about a use case. My opinion regarding the "ad-hocness" of the override, is that if you need it in the future, do it in the future. There is little point in adding options for things nobody will ever need, just for symmetry's sake.

@johanot Shall we try to get this merged in, before it goes stale again?

@johanot
Copy link
Contributor

johanot commented Mar 9, 2019

@juselius Fine by me, but I don't have merge access :-)
@srhb Do you have any further comments? If not, will you please assist in merging and back-porting?

@danbst danbst merged commit 279716c into NixOS:master Mar 9, 2019
@johanot
Copy link
Contributor

johanot commented Mar 9, 2019

Thanks @danbst !

@danbst
Copy link
Contributor

danbst commented Mar 9, 2019

@juselius as for me PR description is still more clear about what this option is for. But maybe you k8s guys use some other language, so 🤷‍♂️ problem with me I guess.

danbst pushed a commit that referenced this pull request Mar 9, 2019
Allow coredns ConfigMap and Depolyment to be editable by the user. An use
case is augmenting the default, generated dns records with local services.
@danbst
Copy link
Contributor

danbst commented Mar 9, 2019

backported

@juselius
Copy link
Contributor Author

juselius commented Mar 9, 2019

First NixOS PR! Time to celebrate :)

@johanot Oh, I thought you had merge access.

@danbst Thanks! Perhaps you are right regarding the description. But the PR description is just one of many uses. This is nonetheless not an option a k8s newbie normally would find useful (I believe).

@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants