def submit_sleep_container(image: str): """ Simple armada job where image allows you to control if this container fails or not. """ pod = core_v1.PodSpec( containers=[ core_v1.Container( name="sleep", image=image, args=["sleep", "10s"], securityContext=core_v1.SecurityContext(runAsUser=1000), resources=core_v1.ResourceRequirements( requests={ "cpu": api_resource.Quantity(string="120m"), "memory": api_resource.Quantity(string="510Mi"), }, limits={ "cpu": api_resource.Quantity(string="120m"), "memory": api_resource.Quantity(string="510Mi"), }, ), ) ], ) return [submit_pb2.JobSubmitRequestItem(priority=1, pod_spec=pod)]
def submit_sleep_job(): """ This is a PodSpec definition that allows you to run sleep. This returns an array of JobSubmitRequestItems that allows you to submit to Armada. """ pod = core_v1.PodSpec(containers=[ core_v1.Container( name="sleep", image="busybox", args=["sleep", "10s"], securityContext=core_v1.SecurityContext(runAsUser=1000), resources=core_v1.ResourceRequirements( requests={ "cpu": api_resource.Quantity(string="120m"), "memory": api_resource.Quantity(string="510Mi"), }, limits={ "cpu": api_resource.Quantity(string="120m"), "memory": api_resource.Quantity(string="510Mi"), }, ), ) ], ) return [submit_pb2.JobSubmitRequestItem(priority=1, pod_spec=pod)]
def create_job_request_item( self, pod_spec: core_v1.PodSpec, priority: int = 1, **job_item_params ) -> submit_pb2.JobSubmitRequestItem: """Create a job request. :param priority: The priority of the job :param pod_spec: The k8s pod spec of the job :param job_item_params: All other job_item kwaarg arguments as specified in the api definition. :return: A job item request object. See the api definition. """ return submit_pb2.JobSubmitRequestItem( priority=priority, pod_spec=pod_spec, **job_item_params )
def sleep_job(): pod = core_v1.PodSpec(containers=[ core_v1.Container( name="container-1", image="busybox", args=["sleep", "10s"], securityContext=core_v1.SecurityContext(runAsUser=1000), resources=core_v1.ResourceRequirements( requests={ "cpu": api_resource.Quantity(string="120m"), "memory": api_resource.Quantity(string="510Mi"), }, limits={ "cpu": api_resource.Quantity(string="120m"), "memory": api_resource.Quantity(string="510Mi"), }, ), ) ], ) return [submit_pb2.JobSubmitRequestItem(priority=0, pod_spec=pod)]