-
Notifications
You must be signed in to change notification settings - Fork 19
[ON HOLD] Modify kubelet with flags using Helm chart and jq during validation phase to improve node pressure management #1034
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
Open
pdamianov-dev
wants to merge
33
commits into
main
Choose a base branch
from
pdamianov-dev/k8s-pressure
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
ed237de
new daemonset for kubelet flag change
pdamianov-dev e1d140c
testing pipeline param
pdamianov-dev 9dc534c
adding daemonset support with passed in string param
pdamianov-dev b388403
full e2e workflow of getting kubelet flags and applying them to kubel…
pdamianov-dev 1e7f30c
testing convertToJson
pdamianov-dev 5f08dde
test fixes
pdamianov-dev f9b41ab
modify to pass in json from object in params
pdamianov-dev 39e417b
Merge branch 'pdamianov-dev/k8s-pressure' of https://github.com/Azure…
pdamianov-dev ae7f32a
fix string syntax error in utils.py
pdamianov-dev 2c78447
fix unbound python path error
pdamianov-dev 03c6fb5
moved pythonpath to separate line
pdamianov-dev 2113fc6
remove -u as its not anywhere else
pdamianov-dev 013ab43
re-add imports
pdamianov-dev a6812f6
re add kubectl apply
pdamianov-dev 7b5526b
pylint errors
pdamianov-dev 1f97096
yaml lint errors
pdamianov-dev 7ee9cfc
Apply suggestions from code review
pdamianov-dev 534ad42
Update execute.yml
pdamianov-dev bf219bf
use helm chart and jq for json processing in validation yml
pdamianov-dev 5917491
stop using cri-pressure engine
pdamianov-dev 747b72e
Merge branch 'pdamianov-dev/k8s-pressure' of https://github.com/Azure…
pdamianov-dev 98a6b8a
ensure full string for flags
pdamianov-dev e5ad660
temporary comment out for testing
pdamianov-dev 8557191
more fixes
pdamianov-dev 37cd36c
Merge branch 'pdamianov-dev/k8s-pressure' of https://github.com/Azure…
pdamianov-dev e515461
check pod status after helm upgrade
pdamianov-dev df0da52
steps/topology/k8s-resource-pressure/validate-resources.yml
pdamianov-dev 0d33331
try with file
pdamianov-dev 5ba9069
switch to rel path
pdamianov-dev 4237ad2
fixed kubelet flags issue
pdamianov-dev 1b4d651
revert all python changes
pdamianov-dev e4b9bd1
Remove modify_kubelet_clusterloader2 function
pdamianov-dev e3166e0
Remove trailing newline from utils.py
pdamianov-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v2 | ||
| name: kubelet-config-updater | ||
| description: Deploy a DaemonSet to update kubelet flags on nodes | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "1.0" |
76 changes: 76 additions & 0 deletions
76
steps/topology/k8s-resource-pressure/chart/templates/daemonset.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| apiVersion: apps/v1 | ||
| kind: DaemonSet | ||
| metadata: | ||
| name: kubelet-config-updater | ||
| namespace: kube-system | ||
| labels: | ||
| app: kubelet-config-updater | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| app: kubelet-config-updater | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: kubelet-config-updater | ||
| spec: | ||
| hostPID: true | ||
| nodeSelector: | ||
| cri-resource-consume: "true" | ||
| tolerations: | ||
| - key: cri-resource-consume | ||
| operator: "Equal" | ||
| value: "true" | ||
| effect: "NoSchedule" | ||
| - key: cri-resource-consume | ||
| operator: "Equal" | ||
| value: "true" | ||
| effect: "NoExecute" | ||
| containers: | ||
| - name: kubelet-config-updater | ||
| image: ghcr.io/containerd/busybox:1.36 | ||
| securityContext: | ||
| privileged: true | ||
| command: | ||
| - /bin/sh | ||
| - -c | ||
| - | | ||
| echo "Updating kubelet configuration..." | ||
| export CUSTOM_EVICTION_FLAGS="{{ .Values.kubeletFlags }}" | ||
| export kubelet_flags_eof_key="--node-ip" | ||
| for kvp in $CUSTOM_EVICTION_FLAGS; do | ||
| key=${kvp%%=*} | ||
| value=${kvp#*=} | ||
| esc_key=$(printf '%s' "${key}" | sed -e 's/[][\/.^$*+?()|]/\\&/g') | ||
| esc_value=$(printf '%s' "${value}" | sed -e 's/[][\/.^$*+?()|]/\\&/g') | ||
| echo "Processing key: ${esc_key} with value: ${esc_value}" | ||
| if grep -q -E "(^|[[:space:]])${esc_key}=[^[:space:]]+" /etc/default/kubelet; then | ||
| echo "Found ${esc_key} in /etc/default/kubelet" | ||
| sed -i -r -E "s/(^|[[:space:]])(${esc_key})=[^[:space:]]*/\1\2=${esc_value}/g" "/etc/default/kubelet" | ||
| else | ||
| echo "Adding ${esc_key}=${esc_value} to /etc/default/kubelet" | ||
| repl=$(printf ' %s=%s' "${esc_key}" "${esc_value}") | ||
| sed -i -r -E "s/(${kubelet_flags_eof_key}=[^[:space:]]+)/\1${repl}/g" "/etc/default/kubelet" | ||
| export kubelet_flags_eof_key="${esc_key}" | ||
| fi | ||
| done | ||
| echo "Checking Updated kubelet configuration:" | ||
| cat /etc/default/kubelet | ||
| echo "Restarting kubelet..." | ||
| nsenter --mount=/proc/1/ns/mnt -- systemctl restart kubelet || true | ||
| echo "Done. Sleeping indefinitely to keep the pod running." | ||
| sleep infinity | ||
| volumeMounts: | ||
| - name: systemd | ||
| mountPath: /run/systemd | ||
| - name: kubelet-config | ||
| mountPath: /etc/default | ||
| volumes: | ||
| - name: kubelet-config | ||
| hostPath: | ||
| path: /etc/default | ||
| type: Directory | ||
| - name: systemd | ||
| hostPath: | ||
| path: /run/systemd | ||
| restartPolicy: Always |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Provide a single string with kubelet flags to add, example: | ||
| # "--eviction-hard=memory.available<100Mi --system-reserved=cpu=100m,memory=200Mi" | ||
| kubeletFlags: "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need parameters , simply enable them in your test
in validate-resources
can call
$KUBELET_CONFIG_TYPE
if KUBELET_CONFIG_TYPE == ëviction-hard :
else if
else if
so on and so on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we want to pass in different flags with each run without changing the pipeline definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our intention may not be to schedule this pipeline, we will most likely do it manually or have a separate pipeline trigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if i set a queue time variable instead?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this pipeline guideline where all additional variables must be stored in the matrix format, we recommend all pipelines to follow this format.

Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable group are usually for secret key values like credentials and masked value of aks_custom_header. Since you only care about manual run, you can have 3 stages eviction-hard, eviction-soft. eviction-soft-grace-period. And you can select only the one which you want to trigger. Another option is to use the test branch and you can override whatever values you want for manual testing. And when you are sure of the values, you can submit schedule PR to the main branch
