Skip to content
Open
Show file tree
Hide file tree
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 Jan 21, 2026
e1d140c
testing pipeline param
pdamianov-dev Jan 21, 2026
9dc534c
adding daemonset support with passed in string param
pdamianov-dev Jan 23, 2026
b388403
full e2e workflow of getting kubelet flags and applying them to kubel…
pdamianov-dev Jan 23, 2026
1e7f30c
testing convertToJson
pdamianov-dev Jan 28, 2026
5f08dde
test fixes
pdamianov-dev Jan 28, 2026
f9b41ab
modify to pass in json from object in params
pdamianov-dev Jan 28, 2026
39e417b
Merge branch 'pdamianov-dev/k8s-pressure' of https://github.com/Azure…
pdamianov-dev Jan 28, 2026
ae7f32a
fix string syntax error in utils.py
pdamianov-dev Jan 28, 2026
2c78447
fix unbound python path error
pdamianov-dev Jan 29, 2026
03c6fb5
moved pythonpath to separate line
pdamianov-dev Jan 29, 2026
2113fc6
remove -u as its not anywhere else
pdamianov-dev Jan 29, 2026
013ab43
re-add imports
pdamianov-dev Jan 29, 2026
a6812f6
re add kubectl apply
pdamianov-dev Jan 30, 2026
7b5526b
pylint errors
pdamianov-dev Jan 30, 2026
1f97096
yaml lint errors
pdamianov-dev Jan 30, 2026
7ee9cfc
Apply suggestions from code review
pdamianov-dev Feb 2, 2026
534ad42
Update execute.yml
pdamianov-dev Feb 2, 2026
bf219bf
use helm chart and jq for json processing in validation yml
pdamianov-dev Feb 4, 2026
5917491
stop using cri-pressure engine
pdamianov-dev Feb 4, 2026
747b72e
Merge branch 'pdamianov-dev/k8s-pressure' of https://github.com/Azure…
pdamianov-dev Feb 4, 2026
98a6b8a
ensure full string for flags
pdamianov-dev Feb 5, 2026
e5ad660
temporary comment out for testing
pdamianov-dev Feb 5, 2026
8557191
more fixes
pdamianov-dev Feb 5, 2026
37cd36c
Merge branch 'pdamianov-dev/k8s-pressure' of https://github.com/Azure…
pdamianov-dev Feb 5, 2026
e515461
check pod status after helm upgrade
pdamianov-dev Feb 5, 2026
df0da52
steps/topology/k8s-resource-pressure/validate-resources.yml
pdamianov-dev Feb 5, 2026
0d33331
try with file
pdamianov-dev Feb 5, 2026
5ba9069
switch to rel path
pdamianov-dev Feb 5, 2026
4237ad2
fixed kubelet flags issue
pdamianov-dev Feb 5, 2026
1b4d651
revert all python changes
pdamianov-dev Feb 5, 2026
e4b9bd1
Remove modify_kubelet_clusterloader2 function
pdamianov-dev Feb 5, 2026
e3166e0
Remove trailing newline from utils.py
pdamianov-dev Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions modules/python/clusterloader2/cri/cri.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
setup_logging()
logger = get_logger(__name__)

MEMORY_SCALE_FACTOR = 0.95 # 95% of the total allocatable memory to account for error margin

# TODO: Refactor to use a config dataclass to reduce number of arguments
# Reference: modules/python/clusterloader2/job_controller/job_controller.py
def override_config_clusterloader2(
node_count, node_per_step, max_pods, repeats, operation_timeout,
load_type, scale_enabled, pod_startup_latency_threshold, provider,
registry_endpoint, os_type, scrape_kubelets, scrape_containerd, containerd_scrape_interval, host_network, override_file):
registry_endpoint, os_type, scrape_kubelets, scrape_containerd, containerd_scrape_interval, host_network, override_file, use_custom_kubelet = False):
MEMORY_SCALE_FACTOR = 0.95 # 95% of the total allocatable memory to account for error margin
if use_custom_kubelet:
MEMORY_SCALE_FACTOR = 1.00 # Allow full memory access for load testing
client = KubernetesClient(os.path.expanduser("~/.kube/config"))
nodes = client.get_nodes(label_selector="cri-resource-consume=true")
if len(nodes) == 0:
Expand Down
34 changes: 34 additions & 0 deletions pipelines/perf-eval/CRI Benchmark/k8s-resource-pressure.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
trigger: none

parameters:
Copy link
Contributor

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

            n1-p60-memory-managed:
              node_count: 1
              max_pods: 60
              repeats: 1
              operation_timeout: 3m
              load_type: memory
              pod_startup_latency_threshold: 23s
              kubernetes_version: "1.34"
              k8s_os_disk_type: Managed
              scrape_kubelets: True
              enable_custom_kubelet: false
              kubelet_config_type: "eviction-hard" # eviction-soft, eviction-soft-grace-period

in validate-resources

can call
$KUBELET_CONFIG_TYPE

if KUBELET_CONFIG_TYPE == ëviction-hard :

  • override the memory, nodefs and pid
    else if
    else if
    so on and so on

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Contributor

@vittoriasalim vittoriasalim Feb 8, 2026

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.
Image

Copy link
Contributor

@vittoriasalim vittoriasalim Feb 8, 2026

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
Image

- name: use_custom_kubelet
displayName: "Use Custom Kubelet Flags?"
type: boolean
default: true
- name: custom_kubelet_config
displayName: "Custom Kubelet Config Object"
type: object # The parameter type is object
default: # Default value is an object with nested properties
eviction-hard:
memory.available: "200Mi"
nodefs.available: "10%"
nodefs.inodesFree: "5%"
pid.available: "2000"
eviction-soft:
memory.available: "400Mi"
nodefs.available: "15%"
nodefs.inodesFree: "10%"
pid.available: "3000"
eviction-soft-grace-period:
memory.available: "1m"
nodefs.available: "1m"
nodefs.inodesFree: "1m"
pid.available: "1m"

variables:
SCENARIO_TYPE: perf-eval
SCENARIO_NAME: k8s-node-stress
custom_kubelet_config_json: ${{ convertToJson(parameters.custom_kubelet_config) }}

stages:
- stage: azure_westus2_stress_baseline_1_34
Expand All @@ -29,6 +55,8 @@ stages:
pod_startup_latency_threshold: 23s
kubernetes_version: "1.34"
scrape_kubelets: True
use_custom_kubelet: ${{ parameters.use_custom_kubelet }}
custom_kubelet_config: ${{ variables.custom_kubelet_config_json }}
n1-p60-memory-managed:
node_count: 1
max_pods: 60
Expand All @@ -39,6 +67,8 @@ stages:
kubernetes_version: "1.34"
k8s_os_disk_type: Managed
scrape_kubelets: True
use_custom_kubelet: ${{ parameters.use_custom_kubelet }}
custom_kubelet_config: ${{ variables.custom_kubelet_config_json }}
n1-p60-cpu-ephemeral:
node_count: 1
max_pods: 60
Expand All @@ -48,6 +78,8 @@ stages:
pod_startup_latency_threshold: 23s
kubernetes_version: "1.34"
scrape_kubelets: True
use_custom_kubelet: ${{ parameters.use_custom_kubelet }}
custom_kubelet_config: ${{ variables.custom_kubelet_config_json }}
n1-p60-cpu-managed:
node_count: 1
max_pods: 60
Expand All @@ -58,6 +90,8 @@ stages:
kubernetes_version: "1.34"
k8s_os_disk_type: Managed
scrape_kubelets: True
use_custom_kubelet: ${{ parameters.use_custom_kubelet }}
custom_kubelet_config: ${{ variables.custom_kubelet_config_json }}
max_parallel: 1
timeout_in_minutes: 120
credential_type: service_connection
Expand Down
6 changes: 6 additions & 0 deletions steps/topology/k8s-resource-pressure/chart/Chart.yaml
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"
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
3 changes: 3 additions & 0 deletions steps/topology/k8s-resource-pressure/chart/values.yaml
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: ""
35 changes: 35 additions & 0 deletions steps/topology/k8s-resource-pressure/validate-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,38 @@ steps:
- template: /steps/engine/clusterloader2/large-cluster/validate.yml
parameters:
desired_nodes: 3
- bash: |
set -euo pipefail
set -x

flags_string=$(echo "$CUSTOM_EVICTION_FLAGS" | jq -r '
def format_value(k; v):
if (v|type) == "object" then
(if (k == "eviction-hard") or (k == "eviction-soft") then "<"
else "=" end) as $delim
| (v | to_entries | map(.key + $delim + (.value|tostring)) | join(","))
elif (v|type) == "array" then
(v | map(tostring) | join(","))
else
(v | tostring)
end;

to_entries
| map("--" + .key + "=" + (format_value(.key; .value)))
| join(" ")
')

printf '%s' "$flags_string" > "kubelet_flags.txt"

helm upgrade --install kubelet-config-updater ./steps/topology/k8s-resource-pressure/chart \
--namespace kube-system --create-namespace \
--set-file kubeletFlags="kubelet_flags.txt"

sleep 5

kubectl get pods -A -o wide

env:
CUSTOM_EVICTION_FLAGS: $(CUSTOM_KUBELET_CONFIG)

displayName: "Validate Kubelet Custom Config Applied"
Loading