Skip to content

Commit 4804fbe

Browse files
authored
Merge pull request kubernetes#93121 from liggitt/resource-quota
kube-up: limit critical pods to kube-system by default
2 parents 92e471a + 3b323b2 commit 4804fbe

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# critical pods are configured as a limited resource by admission_controller_config.yaml,
2+
# which means they are disallowed unless explicitly allowed by a namespaced quota object.
3+
# This quota effectively removes the restriction on the number of critical pods allowed in the kube-system namespace.
4+
apiVersion: v1
5+
kind: ResourceQuota
6+
metadata:
7+
name: gcp-critical-pods
8+
namespace: kube-system
9+
labels:
10+
addonmanager.kubernetes.io/mode: Reconcile
11+
spec:
12+
hard:
13+
pods: "1000000000"
14+
scopeSelector:
15+
matchExpressions:
16+
- operator : In
17+
scopeName: PriorityClass
18+
values: ["system-node-critical", "system-cluster-critical"]

cluster/gce/gci/configure-helper.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,20 @@ kind: AdmissionConfiguration
915915
plugins:
916916
EOF
917917

918+
# Add resourcequota config to limit critical pods to kube-system by default
919+
cat <<EOF >>/etc/srv/kubernetes/admission_controller_config.yaml
920+
- name: "ResourceQuota"
921+
configuration:
922+
apiVersion: apiserver.config.k8s.io/v1
923+
kind: ResourceQuotaConfiguration
924+
limitedResources:
925+
- resource: pods
926+
matchScopes:
927+
- scopeName: PriorityClass
928+
operator: In
929+
values: ["system-node-critical", "system-cluster-critical"]
930+
EOF
931+
918932
if [[ "${ADMISSION_CONTROL:-}" == *"ImagePolicyWebhook"* ]]; then
919933
if [[ -z "${GCP_IMAGE_VERIFICATION_URL:-}" ]]; then
920934
1>&2 echo "The ImagePolicyWebhook admission control plugin was requested, but GCP_IMAGE_VERIFICATION_URL was not provided."
@@ -2528,6 +2542,7 @@ EOF
25282542
if echo "${ADMISSION_CONTROL:-}" | grep -q "LimitRanger"; then
25292543
setup-addon-manifests "admission-controls" "limit-range" "gce"
25302544
fi
2545+
setup-addon-manifests "addons" "admission-resource-quota-critical-pods"
25312546
if [[ "${NETWORK_POLICY_PROVIDER:-}" == "calico" ]]; then
25322547
setup-addon-manifests "addons" "calico-policy-controller"
25332548

0 commit comments

Comments
 (0)