Skip to content

fix(kubernetes/preinstall): skip when dir is empty - #13424

Open
shaleenbathla wants to merge 1 commit into
kubernetes-sigs:masterfrom
shaleenbathla:fix/preinstall-emptymanifestdir
Open

fix(kubernetes/preinstall): skip when dir is empty#13424
shaleenbathla wants to merge 1 commit into
kubernetes-sigs:masterfrom
shaleenbathla:fix/preinstall-emptymanifestdir

Conversation

@shaleenbathla

@shaleenbathla shaleenbathla commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

useful especially for setting manifests dir as empty

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug

/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
allows setting kube_manifests dir as empty and we should rightfully skip when other dir are empty as well

Which issue(s) this PR fixes:

Fixes #13281

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

bugfix(preinstall): skip kube_manifest_dir dir creation when empty

@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 24, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from ErikJiang and guoard August 24, 2026 07:15
@kubernetes-prow kubernetes-prow Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 24, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @shaleenbathla. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

Details

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-sigs/prow repository.

@yankay

yankay commented Aug 25, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@kubernetes-prow kubernetes-prow Bot 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 Aug 25, 2026
Comment thread roles/kubernetes/preinstall/tasks/0050-create_directories.yml Outdated
@shaleenbathla
shaleenbathla force-pushed the fix/preinstall-emptymanifestdir branch from 5c1c918 to cf6c599 Compare August 26, 2026 03:58
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: neilamoore, shaleenbathla
Once this PR has been reviewed and has the lgtm label, please assign yankay for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@guoard

guoard commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

The change itself looks good, but it only fixes the dir creation. A few more things are needed before kube_manifest_dir: "" really works:

  • kubelet-config.v1beta1.yaml.j2 still renders staticPodPath: {{ kube_manifest_dir }} unconditionally. Empty var gives staticPodPath: (null), which kubelet happens to accept, but it should be wrapped in {% if kube_manifest_dir %} to make the intent explicit.
  • With the default localhost apiserver LB, workers get an nginx-proxy static pod written to {{ kube_manifest_dir }}/nginx-proxy.yml. With the var empty that becomes /nginx-proxy.yml and the pod never runs, so workers lose the apiserver. This setup only works with an external loadbalancer_apiserver.
  • Should also be documented that this must be set in worker group_vars only, control plane nodes still need the manifests dir for kubeadm.

Nit: release note says kube_manifests_dir, the variable is kube_manifest_dir.

Wrap staticPodPath in the kubelet config template with a conditional so an
empty kube_manifest_dir does not render `staticPodPath: (null)`, making the
intent explicit. Document kube_manifest_dir in vars.md and add a hardening
example, noting it must only be set to "" in worker group_vars (control plane
always needs the manifests dir for kubeadm) and is only supported with an
external loadbalancer_apiserver.

Signed-off-by: Shaleen Bathla <shaleen.bathla@servicenow.com>
@shaleenbathla
shaleenbathla force-pushed the fix/preinstall-emptymanifestdir branch from cf6c599 to dc18681 Compare September 3, 2026 06:54
@kubernetes-prow kubernetes-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 3, 2026
@shaleenbathla

Copy link
Copy Markdown
Contributor Author

The change itself looks good, but it only fixes the dir creation. A few more things are needed before kube_manifest_dir: "" really works:

  • kubelet-config.v1beta1.yaml.j2 still renders staticPodPath: {{ kube_manifest_dir }} unconditionally. Empty var gives staticPodPath: (null), which kubelet happens to accept, but it should be wrapped in {% if kube_manifest_dir %} to make the intent explicit.
  • With the default localhost apiserver LB, workers get an nginx-proxy static pod written to {{ kube_manifest_dir }}/nginx-proxy.yml. With the var empty that becomes /nginx-proxy.yml and the pod never runs, so workers lose the apiserver. This setup only works with an external loadbalancer_apiserver.
  • Should also be documented that this must be set in worker group_vars only, control plane nodes still need the manifests dir for kubeadm.

Nit: release note says kube_manifests_dir, the variable is kube_manifest_dir.

thanks for the review @guoard. updated release note, added explicit conditional, added docs
please re-review the latest changes

@guoard

guoard commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
/lgtm
Not sure about the release note though, would like a second opinion on that.

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 3, 2026
@VannTen

VannTen commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
  • With the default localhost apiserver LB, workers get an nginx-proxy static pod written to {{ kube_manifest_dir }}/nginx-proxy.yml. With the var empty that becomes /nginx-proxy.yml and the pod never runs, so workers lose the apiserver. This setup only works with an external loadbalancer_apiserver.
  • Should also be documented that this must be set in worker group_vars only, control plane nodes still need the manifests dir for kubeadm

The first can be asserted against, and IMO should be as this can do some damage on a cluster. (validate_inventory should be good enough for that).
I don't remember if assert are per-host , but if yes then the second is trivial to assert as well, so we should probably do it as well.
Except for that this looks good.
The release note should probably be something like "allow empty kube_manifest_dir on workers to disable static pods" or something like that.

Also, nit, but IMO item != "" is clearer on the intent than using length > 0.

@guoard

guoard commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

but IMO item != "" is clearer on the intent than using length > 0

what about when item is a list and not string?

@VannTen

VannTen commented Sep 3, 2026 via email

Copy link
Copy Markdown
Contributor

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to satisfy Kubernetes STIG requirement that worker nodes need to disable 'staticPodPath' kubelet option

5 participants