-
Notifications
You must be signed in to change notification settings - Fork 251
Expand file tree
/
Copy pathgenerate-kind-config.sh
More file actions
executable file
·108 lines (93 loc) · 3.04 KB
/
Copy pathgenerate-kind-config.sh
File metadata and controls
executable file
·108 lines (93 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Copyright 2025 NVIDIA CORPORATION
# SPDX-License-Identifier: Apache-2.0
#
# Generates a kind cluster config YAML for e2e testing.
# Usage: generate-kind-config.sh --feature-config <config> --k8s-version <version> --output <path>
set -eo pipefail
FEATURE_CONFIG="default"
K8S_VERSION=""
OUTPUT=""
while [[ $# -gt 0 ]]; do
case $1 in
--feature-config) FEATURE_CONFIG="$2"; shift 2;;
--k8s-version) K8S_VERSION="$2"; shift 2;;
--output) OUTPUT="$2"; shift 2;;
-h|--help)
echo "Usage: $0 --feature-config <config> --k8s-version <version> --output <path>"
echo " --feature-config: default | dra-enabled"
echo " --k8s-version: kindest/node version tag, e.g. v1.34.0"
echo " --output: path to write the generated kind config YAML"
exit 0;;
*) echo "Unknown option $1"; exit 1;;
esac
done
if [[ -z "$K8S_VERSION" || -z "$OUTPUT" ]]; then
echo "Error: --k8s-version and --output are required" >&2
exit 1
fi
K8S_MINOR=$(echo "$K8S_VERSION" | sed -nE 's/^v1\.([0-9]+).*$/\1/p')
if [[ -z "$K8S_MINOR" ]]; then
echo "Error: could not parse minor version from --k8s-version '$K8S_VERSION'" >&2
exit 1
fi
# Resolve version-specific settings for each feature config
ENABLE_DRA_FEATURE_GATE=false
RUNTIME_CONFIG=""
case "$FEATURE_CONFIG" in
dra-enabled)
if [ "$K8S_MINOR" -eq 32 ]; then
ENABLE_DRA_FEATURE_GATE=true
RUNTIME_CONFIG="resource.k8s.io/v1beta1=true"
elif [ "$K8S_MINOR" -eq 33 ]; then
ENABLE_DRA_FEATURE_GATE=true
RUNTIME_CONFIG="resource.k8s.io/v1beta1=true,resource.k8s.io/v1beta2=true"
fi
# k8s <= 1.31: DRA is alpha only (v1alpha3), no v1beta support
# k8s >= 1.34: DRA is GA (v1), feature gate on by default, no runtime-config needed
;;
default|*)
;;
esac
# Write config
{
echo "# Generated by hack/generate-kind-config.sh — do not edit directly"
echo "# Copyright 2025 NVIDIA CORPORATION"
echo "# SPDX-License-Identifier: Apache-2.0"
echo ""
echo "kind: Cluster"
echo "apiVersion: kind.x-k8s.io/v1alpha4"
if [ "$ENABLE_DRA_FEATURE_GATE" = "true" ]; then
echo "featureGates:"
echo " DynamicResourceAllocation: true"
fi
echo "nodes:"
echo "- role: control-plane"
if [ -n "$RUNTIME_CONFIG" ]; then
echo " kubeadmConfigPatches:"
echo " - |"
echo " kind: ClusterConfiguration"
echo " apiServer:"
echo " extraArgs:"
echo " runtime-config: \"$RUNTIME_CONFIG\""
fi
echo "# Device plugin nodes"
for i in 1 2 3 4; do
echo "- role: worker"
echo " labels:"
echo " run.ai/simulated-gpu-node-pool: default"
echo " nvidia.com/gpu.deploy.device-plugin: \"true\""
echo " nvidia.com/gpu.memory: 11441"
done
if [ "$FEATURE_CONFIG" = "dra-enabled" ]; then
echo "# DRA nodes"
for i in 1 2; do
echo "- role: worker"
echo " labels:"
echo " run.ai/simulated-gpu-node-pool: default"
echo " nvidia.com/gpu.deploy.dra-plugin-gpu: \"true\""
done
fi
echo "# CPU Node"
echo "- role: worker"
} > "$OUTPUT"