How can I dynamically allocate resources to each pod?

120 views Asked by At

I want to change the resource allocation of each pod dynamically using python client.

I tried below code but it seems doesn't change.

I searched really hard but I don't know how to...

Or is there any other API that makes this change possible?

from kubernetes import client, config
...
config.load_kube_config()
v1 = client.CoreV1Api()

  res_pods = v1.list_pod_for_all_namespaces(pretty=True)
  for i in res_pods.items:
      for j in i.spec.containers:
          if j.resources.requests or j.resources.limits:
              print(i.spec.node_name, j.name, j.resources)
              j.resources.requests["cpu"] = ... # want to change 

Thanks!

0

There are 0 answers