From 7e979cb2f7a77d8ba482b4723e9a4756407cb0dc Mon Sep 17 00:00:00 2001 From: Francois Andrieu Date: Fri, 3 Feb 2023 15:44:56 +0100 Subject: [PATCH] communishift: set default resource limits for pods Once a resource quota is set for a namespace, kube will refuse to schedule any pod without limits set, including build pod. This can be difficult to figure out unless you know where to look, and can be challenging for new openshift/kubernetes users. Setting a default limit would, at least, avoid the non-schedulable issue. --- .../communishift/tasks/create-limit-range.yml | 21 +++++++++++++++++++ roles/communishift/tasks/main.yml | 1 + 2 files changed, 22 insertions(+) create mode 100644 roles/communishift/tasks/create-limit-range.yml diff --git a/roles/communishift/tasks/create-limit-range.yml b/roles/communishift/tasks/create-limit-range.yml new file mode 100644 index 0000000000..1d604756dd --- /dev/null +++ b/roles/communishift/tasks/create-limit-range.yml @@ -0,0 +1,21 @@ +--- +- name: Create a k8s LimitRange + community.okd.k8s: + api_key: "{{ communishift_ocp_api_token }}" + host: "{{ communishift_ocp_api_host }}" + state: present + definition: + apiVersion: v1 + kind: LimitRange + metadata: + name: "{{ communishift_project_name }}-limitrange" + namespace: "{{ communishift_project_name }}" + spec: + limits: + - default: + cpu: 500m + memory: 500Mi + defaultRequest: + cpu: 100m + memory: 100Mi + type: Container diff --git a/roles/communishift/tasks/main.yml b/roles/communishift/tasks/main.yml index aeeac3fffa..49f29ba3c4 100644 --- a/roles/communishift/tasks/main.yml +++ b/roles/communishift/tasks/main.yml @@ -12,3 +12,4 @@ - include_tasks: create-role.yml - include_tasks: create-role-binding.yml - include_tasks: create-resource-quota.yml +- include_tasks: create-limit-range.yml