File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,13 @@ else
140140 fi
141141fi
142142
143+ # test if resource specification is required
144+ resources_json=' "resources": {
145+ "limits": { "cpu": "' ${container_cpu} ' ", "memory": "' ${container_memory} ' " },
146+ "requests": { "cpu": "' ${container_cpu} ' ", "memory": "' ${container_memory} ' " }
147+ }'
148+ $kubectl run test --image test --dry-run=server 2>&1 | grep ' failed quota' --quiet || resources_json=' "resources": {}'
149+
143150overrides=" $(
144151cat << EOT
145152{
@@ -156,10 +163,7 @@ cat <<EOT
156163 "stdinOnce": true,
157164 "tty": $tty ,
158165 "command": $cmd ,
159- "resources": {
160- "limits": { "cpu": "${container_cpu} ", "memory": "${container_memory} " },
161- "requests": { "cpu": "${container_cpu} ", "memory": "${container_memory} " }
162- },
166+ $resources_json ,
163167 "volumeMounts": $volume_mounts
164168 }
165169 ],
@@ -172,7 +176,6 @@ cat <<EOT
172176}
173177EOT
174178) "
175-
176179# Support Kubectl <1.18
177180m=$( kubectl version --client -o yaml | awk -F' [ :"]+' ' $2 == "minor" {print $3+0}' )
178181if [ " $m " -lt 18 ]; then
You can’t perform that action at this time.
0 commit comments