ITMan Documents

This Weblog Just Created For Document Sysadmin Challenges

Resource Limitation

Resource Limitation on NameSpace

apiVersion: v1
kind: ResourceQuota
metadata:
  name: mem-cpu-limit-${NameSpace}
spec:
  hard:
    requests.cpu: "${RequestsCPU}"
    requests.memory: ${RequestsMemory}Gi
    limits.cpu: "${LimitCPU}"
    limits.memory: ${LimitMemory}Gi
while [ -z "${NameSpace}" ]
do
	read -p 'Please Enter Kubernetes NameSpace: ' NameSpace
	export NameSpace
done

while [ -z "${RequestsCPU}" ]
do
	read -p "Please Enter Requests CPU Count Qouta: "
	export $RequestsCPU
done

while [ -z "${LimitCPU}" ]
do
	read -p "Please Enter Limit CPU Count Qouta: "
	export $RequestsCPU
done

while [ -z "${RequestsMemory}" ]
do
	read -p "Please Enter Requests Memory Qouta in Gibibyte: "
	export $RequestsCPU
done

while [ -z "${LimitMemory}" ]
do
	read -p "Please Enter Limit Memory Qouta in Gibibyte: "
	export $RequestsCPU
done

curl -sS https://itmconsult.ir/kubernetes/resource-limitation/limit.yml  | envsubst > limit-${NameSpace}.yml \
&& kubectl apply -n ${NameSpace} -f limit-${NameSpace}.yml \
&& echo "EveryThing is OK" \
&& rm -rf limit-${NameSpace}.yml limit.yml

Automatic Way

bash <(curl -s https://itmconsult.ir/kubernetes/resource-limitation/limit.sh)
Last updated on 8 Nov 2020
Published on 8 Nov 2020