kubernetes-sigs / kubespray

Deploy a Production Ready Kubernetes Cluster
Apache License 2.0
16.2k stars 6.49k forks source link

Fix pretty-printing of coredns and nodelocaldns configmaps #11694

Closed VannTen closed 4 days ago

VannTen commented 2 weeks ago

What type of PR is this? /kind bug

What this PR does / why we need it: When using

dns_upstream_forward_extra_opts:
  prefer_udp: "" # the option as no value so use empty string to just
                 # put the key

This is rendered in the dns configmap as ($ for end-of-line)

... prefer_udp $ ...

Note the trailing space. This triggers https://github.com/kubernetes/kubernetes/issues/36222, which makes the configmap hardly readable when editing them manually or simply putting them in a yaml file for inspection.

Trim the concatenation of option + value to get rid of any trailing space. Example of kubectl edit on such a configmap:

  Corefile: ".:53 {\n    errors {\n    }\n    health {\n        lameduck 5s\n    }\n
    \   rewrite name suffix <redacted> cluster.local answer auto\n    ready\n    kubernetes
    cluster.local in-addr.arpa ip6.arpa {\n      pods insecure\n      fallthrough
    in-addr.arpa ip6.arpa\n    }\n    prometheus :9153\n    forward . <redacted>
    <redacted> {\n      prefer_udp\n      max_concurrent 1000\n      prefer_udp
    \n    }\n    cache 30\n\n    loop\n    reload\n    loadbalance\n}\n"

Special notes for your reviewer: This is pretty minor, but pretty annoying !

Does this PR introduce a user-facing change?:

Fix pretty-printing (in kubectl) of nodelocaldns and coredns configmap when using `dns_upstream_forward_extra_opts` with an empty value option.
VannTen commented 2 weeks ago

/ok-to-test

VannTen commented 2 weeks ago

/cherrypick release-2.26 /cherrypick release-2.25 /cherrypick release-2.24

k8s-infra-cherrypick-robot commented 2 weeks ago

@VannTen: once the present PR merges, I will cherry-pick it on top of release-2.24, release-2.25, release-2.26 in new PRs and assign them to you.

In response to [this](https://github.com/kubernetes-sigs/kubespray/pull/11694#issuecomment-2461908443): >/cherrypick release-2.26 >/cherrypick release-2.25 >/cherrypick release-2.24 > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
VannTen commented 6 days ago

/cc @tico88612

k8s-ci-robot commented 4 days ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tico88612, VannTen

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: - ~~[OWNERS](https://github.com/kubernetes-sigs/kubespray/blob/master/OWNERS)~~ [VannTen] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
k8s-infra-cherrypick-robot commented 4 days ago

@VannTen: new pull request created: #11721

In response to [this](https://github.com/kubernetes-sigs/kubespray/pull/11694#issuecomment-2461908443): >/cherrypick release-2.26 >/cherrypick release-2.25 >/cherrypick release-2.24 > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
k8s-infra-cherrypick-robot commented 4 days ago

@VannTen: new pull request created: #11722

In response to [this](https://github.com/kubernetes-sigs/kubespray/pull/11694#issuecomment-2461908443): >/cherrypick release-2.26 >/cherrypick release-2.25 >/cherrypick release-2.24 > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
k8s-infra-cherrypick-robot commented 4 days ago

@VannTen: new pull request created: #11723

In response to [this](https://github.com/kubernetes-sigs/kubespray/pull/11694#issuecomment-2461908443): >/cherrypick release-2.26 >/cherrypick release-2.25 >/cherrypick release-2.24 > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.