I have Google cloud Kubernetes which running my application from Docker image. My nodes pool are machines with 8 CPUs.
One of my applications are not using the CPUs well because it's written with Python (read more about python Global Interpreter Lock - GIL - problem).
So, the enviroment is running with 8 core but the application don't need it.
Is this possible to decide how many cores my application will "see"? I want to limit it to "1".
If you’ll read this documentation from Kubernetes, you’ll see that resource management is “baked in” to Kubernetes, specially for defining both the number of CPUs allocated and how much each CPU is used.
This is defined in a .yaml file.
From the documentation:
apiVersion: v1
kind: Pod
metadata:
name: cpu-demo
namespace: cpu-example
spec:
containers:
- name: cpu-demo-ctr
image: vish/stress
resources:
limits:
cpu: "1"
requests:
cpu: "0.5"
args:
- -cpus
- "2"
You can set the request
and the limit
of the resources for a specific pod.
resources:
limits:
cpu: "1"
requests:
cpu: "0.5"
Read more about it: https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/