def generate_pod_spec_for_task(): pod_spec = generated_pb2.PodSpec() secondary_container = generated_pb2.Container( name="secondary", image="alpine", ) secondary_container.command.extend(["/bin/sh"]) secondary_container.args.extend( ["-c", "echo hi sidecar world > /data/message.txt"]) shared_volume_mount = generated_pb2.VolumeMount( name="shared-data", mountPath="/data", ) secondary_container.volumeMounts.extend([shared_volume_mount]) primary_container = generated_pb2.Container(name="primary") primary_container.volumeMounts.extend([shared_volume_mount]) pod_spec.volumes.extend([ generated_pb2.Volume(name="shared-data", volumeSource=generated_pb2.VolumeSource( emptyDir=generated_pb2.EmptyDirVolumeSource( medium="Memory", ))) ]) pod_spec.containers.extend([primary_container, secondary_container]) return pod_spec
def get_pod_spec(): a_container = generated_pb2.Container(name="a container",) a_container.command.extend(["fee", "fi", "fo", "fum"]) a_container.volumeMounts.extend([generated_pb2.VolumeMount(name="volume mount", mountPath="some/where",)]) pod_spec = generated_pb2.PodSpec(restartPolicy="OnFailure",) pod_spec.containers.extend([a_container, generated_pb2.Container(name="another container")]) return pod_spec
def get_pod_spec(): a_container = generated_pb2.Container(name="main") a_container.command.extend(["foo", "bar"]) a_container.volumeMounts.extend( [generated_pb2.VolumeMount( name="scratch", mountPath="/scratch", )]) pod_spec = generated_pb2.PodSpec(restartPolicy="Never", ) pod_spec.containers.extend( [a_container, generated_pb2.Container(name="sidecar")]) return pod_spec
def generate_pod_spec_for_task(): pod_spec = generated_pb2.PodSpec() # Primary containers do not require us to specify an image, the default image built for flyte tasks will get used. primary_container = generated_pb2.Container(name="primary") # Note: for non-primary containers we must specify an image. secondary_container = generated_pb2.Container( name="secondary", image="alpine", ) secondary_container.command.extend(["/bin/sh"]) secondary_container.args.extend( ["-c", "echo hi pod world > {}".format(_SHARED_DATA_PATH)]) resources = generated_pb2.ResourceRequirements() resources.limits["cpu"].CopyFrom(Quantity(string="1")) resources.requests["cpu"].CopyFrom(Quantity(string="1")) resources.limits["memory"].CopyFrom(Quantity(string="100Mi")) resources.requests["memory"].CopyFrom(Quantity(string="100Mi")) primary_container.resources.CopyFrom(resources) secondary_container.resources.CopyFrom(resources) shared_volume_mount = generated_pb2.VolumeMount( name="shared-data", mountPath="/data", ) secondary_container.volumeMounts.extend([shared_volume_mount]) primary_container.volumeMounts.extend([shared_volume_mount]) pod_spec.volumes.extend([ generated_pb2.Volume( name="shared-data", volumeSource=generated_pb2.VolumeSource( emptyDir=generated_pb2.EmptyDirVolumeSource(medium="Memory", )), ) ]) pod_spec.containers.extend([primary_container, secondary_container]) return pod_spec
def generate_pod_spec_for_task(): pod_spec = generated_pb2.PodSpec() primary_container = generated_pb2.Container(name="primary") secondary_container = generated_pb2.Container( name="secondary", image="alpine", ) secondary_container.command.extend(["/bin/sh"]) secondary_container.args.extend( ["-c", "echo hi sidecar world > {}".format(_SHARED_DATA_PATH)]) resources = generated_pb2.ResourceRequirements() resources.limits["cpu"].CopyFrom(Quantity(string="1")) resources.requests["cpu"].CopyFrom(Quantity(string="1")) resources.limits["memory"].CopyFrom(Quantity(string="100Mi")) resources.requests["memory"].CopyFrom(Quantity(string="100Mi")) primary_container.resources.CopyFrom(resources) secondary_container.resources.CopyFrom(resources) shared_volume_mount = generated_pb2.VolumeMount( name="shared-data", mountPath="/data", ) secondary_container.volumeMounts.extend([shared_volume_mount]) primary_container.volumeMounts.extend([shared_volume_mount]) pod_spec.volumes.extend([ generated_pb2.Volume(name="shared-data", volumeSource=generated_pb2.VolumeSource( emptyDir=generated_pb2.EmptyDirVolumeSource( medium="Memory", ))) ]) pod_spec.containers.extend([primary_container, secondary_container]) return pod_spec