Skip to content

feat/static-pod-initialization (#125)#142

Open
GGh41th wants to merge 1 commit intokubernetes-sigs:mainfrom
GGh41th:feat/static-pods-initialization-for-proper-resource-accounting
Open

feat/static-pod-initialization (#125)#142
GGh41th wants to merge 1 commit intokubernetes-sigs:mainfrom
GGh41th:feat/static-pods-initialization-for-proper-resource-accounting

Conversation

@GGh41th
Copy link
Contributor

@GGh41th GGh41th commented Feb 28, 2026

Description

Integrate with npd using a custom problem daemon to ensure that static pods are mirrored before scheduling on the node.

Related Issue

Fixes #125

Type of Change

/kind feature

Testing

Checklist

  • [*] make test passes
  • [*] make lint passes

Does this PR introduce a user-facing change?


Doc #(issue)

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 28, 2026
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 28, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: GGh41th / name: Ghaith Gtari (02900fb)

@netlify
Copy link

netlify bot commented Feb 28, 2026

Deploy Preview for node-readiness-controller ready!

Name Link
🔨 Latest commit 02900fb
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/69b5646ba39d98000863b62b
😎 Deploy Preview https://deploy-preview-142--node-readiness-controller.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GGh41th
Once this PR has been reviewed and has the lgtm label, please assign mrunalp 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

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 28, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @GGh41th. 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.

Regular contributors should join the org to skip this step.

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.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 28, 2026
@GGh41th
Copy link
Contributor Author

GGh41th commented Feb 28, 2026

Seems like my local git config is messed , I'll fix it.

@GGh41th GGh41th force-pushed the feat/static-pods-initialization-for-proper-resource-accounting branch from 8b44391 to e0463ce Compare February 28, 2026 15:36
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 28, 2026
@GGh41th
Copy link
Contributor Author

GGh41th commented Feb 28, 2026

@ajaysundark I didn't go with the StaticPodsSynced condition name because NPD sets the status to False when the script is successful (0 exit code) , so i felt that i should go with a negative polarity condition (StaticPodsMissing,StaticPodsNotSynced,MirrorPodsMissing etc........).
Sure enough i can return 0 if the script wasn't successful and this way i will set the StaticPodsSynced to False , but i will lose control over the message field of the condition since it will be hardcoded in the conditons field of the custom plugin configuration.

@ajaysundark
Copy link
Contributor

Thanks for the PR, @GGh41th , I'll get to it this week.

# Exit code constants
readonly OK=0
readonly NONOK=1
readonly UNKOWN=2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
readonly UNKOWN=2
readonly UNKNOWN=2


### Standalone Mode

In this example, and since I have a 1-node Kind cluster, I will go the standalone way. Note that this is the default shipping method in GKE and AKS.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In this example, and since I have a 1-node Kind cluster, I will go the standalone way. Note that this is the default shipping method in GKE and AKS.
In this example, and since we have a 1-node Kind cluster, we will go the standalone way. Note that this is the default shipping method in GKE and AKS.


### Standalone Mode

In this example, and since I have a 1-node Kind cluster, I will go the standalone way. Note that this is the default shipping method in GKE and AKS.
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this is the default shipping method in GKE and AKS.

Little confused here, do we know why this is a default method for GKE and AKS and why not Helm? Just out of curiosity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not explicitly stated, but from my understanding they deploy it that way because you'll need to bake whatever dependencies your problem daemons might need into the npd image, which is inconvenient for a program you intend to ship as a default add on. So instead they deploy it as a systemd service and it's up to users to install whatever they need on the node.
If you feel that the comment is unecessary I can remove it.

if [ ! -f "$YQ_PATH" ]; then

echo "yq not found at $YQ_PATH, downloading..."
OS=$(uname -s | tr [:upper:] [:lower:])
Copy link
Contributor

Choose a reason for hiding this comment

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

this part looks redundant; can we make a common function and pass arguments to get similar behavior

parse_yaml_manifest() {

NAME=$($YQ_PATH -r '.metadata.name' $1 | head -1)
NAMESPACE=$($YQ_PATH -r '.metadata.namespace // "default"' $1 | head -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NAMESPACE=$($YQ_PATH -r '.metadata.namespace // "default"' $1 | head -1)
NAMESPACE=$($YQ_PATH -r '.metadata.namespace // "kube-system"' $1 | head -1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'm just parsing the static pods manifests, if a namespace wasn't specified then the pod will be created in the default namespace, that's why m defaulting to that.

# The yaml file might be a multi-document yaml , but given that kubelet
# only reads the first document we will skip the rest.
NAME=$($JQ_PATH -r '.metadata.name' $1)
NAMESPACE=$($JQ_PATH -r '.metadata.namespace // "default"' $1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NAMESPACE=$($JQ_PATH -r '.metadata.namespace // "default"' $1)
NAMESPACE=$($JQ_PATH -r '.metadata.namespace // "kube-system"' $1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

{
"type": "StaticPodsMissing",
"reason": "mirrorpodsfound",
"message": "all mirros pods were created"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"message": "all mirros pods were created"
"message": "all mirror pods were created"

{
"type": "StaticPodsMissing",
"reason": "mirrorpodsfound",
"message": "all mirros pods were created"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"message": "all mirros pods were created"
"message": "all mirror pods were created"

Copy link
Member

@Priyankasaggu11929 Priyankasaggu11929 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @GGh41th.

I have left a few in-line suggestions to make the example a bit more easy to test and consume (more like automating the many manual steps we have right now).

I was trying to test the PR locally, and was playing around with what I suggested in my comments. I've pushed them here (if you want to reference)- Priyankasaggu11929@6f0e788

helm install --generate-name deliveryhero/node-problem-detector -f values.yaml
```

> **Note:** For a more robust and reliable version of the shell script, you can check this [standalone binary](https://github.com/GGh41th/NPD-staticpods-syncer). No newline at end of file
Copy link
Member

@Priyankasaggu11929 Priyankasaggu11929 Mar 10, 2026

Choose a reason for hiding this comment

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

I suggest that we deploy NPD as a daemonset.

And store - (i) the NPD custom plugin (staticpods-syncer.json) content and (ii) the script with your actual logic for checking static/mirror pods, both inside a configmap maybe.

Right now, I see in the README documentation, you have suggested 2 ways of deploying NPD - IMO, we leave that to the NPD project documentation itself, and we can just include the above 2 "ready-to-use" yaml files in our example (will make it easier for the user)



# This script will check that all static pods are mirrored in the
# API server.
Copy link
Member

Choose a reason for hiding this comment

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

Similar to what I suggest here - https://github.com/kubernetes-sigs/node-readiness-controller/pull/142/changes#r2912619130, much of the logic of this script can go in the configmap yaml

And whatever extra tools (like from your example - kubectl, yq, jq) we need on top of the NPD container image, let's install them in an init container inside the daemonset.

Comment on lines +17 to +19
settings:
custom_monitor_definitions:
staticpods-syncer.json: |
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestions, we surely can automate a lot of this stuff, I'll use your commit as a reference.

@Priyankasaggu11929
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot 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 Mar 10, 2026
@GGh41th
Copy link
Contributor Author

GGh41th commented Mar 10, 2026

Thanks for the comments everyone, I will try to make the changes as soon as I can.

Integrate with npd using a custom problem daemon to ensure that
static pods are mirrored before scheduling on the node.
@GGh41th GGh41th force-pushed the feat/static-pods-initialization-for-proper-resource-accounting branch from e0463ce to 02900fb Compare March 14, 2026 13:36
@GGh41th
Copy link
Contributor Author

GGh41th commented Mar 14, 2026

cc @Priyankasaggu11929, I tried to automate the process a bit, I wanted to use NPD's helm chart for that, but since I couldn't override the initContainers via the Values.yaml I followed your suggestion.
In your reference you have pre-tainted the worker node which would prevent the NRC controller pod from getting scheduled, so instead I deployed NRC then i tainted the node, to avoid adding tolerations to the NRC deployment manifest.

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/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

static-pod initialization for proper resource accounting

5 participants