Lightweight Python 3+ client library for Kubernetes (pykube-ng) https://pykube.readthedocs.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

36 lines
844 B

import time
class ReplicatedMixin:
scalable_attr = "replicas"
@property
def replicas(self):
return self.obj["spec"]["replicas"]
@replicas.setter
def replicas(self, value):
self.obj["spec"]["replicas"] = value
class ScalableMixin:
@property
def scalable(self):
return getattr(self, self.scalable_attr)
@scalable.setter
def scalable(self, value):
setattr(self, self.scalable_attr, value)
def scale(self, replicas=None):
count = self.scalable if replicas is None else replicas
self.exists(ensure=True)
if self.scalable != count:
self.scalable = count
self.update()
while True:
self.reload()
if self.scalable == count:
break
time.sleep(1)