예제 #1
0
def param_substitutions():
    vop = dsl.VolumeOp(name="create_volume", resource_name="data", size="1Gi")

    op = dsl.ContainerOp(name="cop",
                         image="image",
                         arguments=["--param", vop.output],
                         pvolumes={"/mnt": vop.volume})
예제 #2
0
def volumeop_parallel():
    vop = dsl.VolumeOp(
        name="create_pvc",
        resource_name="my-pvc",
        size="10Gi",
        modes=dsl.VOLUME_MODE_RWM)

    step1 = dsl.ContainerOp(
        name="step1",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["echo 1 | tee /mnt/file1"],
        pvolumes={"/mnt": vop.volume})

    step2 = dsl.ContainerOp(
        name="step2",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["echo 2 | tee /common/file2"],
        pvolumes={"/common": vop.volume})

    step3 = dsl.ContainerOp(
        name="step3",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["echo 3 | tee /mnt3/file3"],
        pvolumes={"/mnt3": vop.volume})
예제 #3
0
def volumeop_sequential():
    vop = dsl.VolumeOp(
        name="mypvc",
        resource_name="newpvc",
        size="10Gi",
        modes=dsl.VOLUME_MODE_RWM)

    step1 = dsl.ContainerOp(
        name="step1",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["echo 1|tee /data/file1"],
        pvolumes={"/data": vop.volume})

    step2 = dsl.ContainerOp(
        name="step2",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["cp /data/file1 /data/file2"],
        pvolumes={"/data": step1.pvolume})

    step3 = dsl.ContainerOp(
        name="step3",
        image="library/bash:4.4.23",
        command=["cat", "/mnt/file1", "/mnt/file2"],
        pvolumes={"/mnt": step2.pvolume})
예제 #4
0
def volume_snapshotop_sequential(url):
    vop = dsl.VolumeOp(
        name="create_volume",
        resource_name="vol1",
        size="1Gi",
        modes=dsl.VOLUME_MODE_RWM
    )

    step1 = dsl.ContainerOp(
        name="step1_ingest",
        image="google/cloud-sdk:279.0.0",
        command=["sh", "-c"],
        arguments=["mkdir /data/step1 && "
                   "gsutil cat %s | gzip -c >/data/step1/file1.gz" % url],
        pvolumes={"/data": vop.volume}
    )

    step1_snap = dsl.VolumeSnapshotOp(
        name="step1_snap",
        resource_name="step1_snap",
        volume=step1.pvolume
    )

    step2 = dsl.ContainerOp(
        name="step2_gunzip",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["mkdir /data/step2 && "
                   "gunzip /data/step1/file1.gz -c >/data/step2/file1"],
        pvolumes={"/data": step1.pvolume}
    )

    step2_snap = dsl.VolumeSnapshotOp(
        name="step2_snap",
        resource_name="step2_snap",
        volume=step2.pvolume
    )

    step3 = dsl.ContainerOp(
        name="step3_copy",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["mkdir /data/step3 && "
                   "cp -av /data/step2/file1 /data/step3/file3"],
        pvolumes={"/data": step2.pvolume}
    )

    step3_snap = dsl.VolumeSnapshotOp(
        name="step3_snap",
        resource_name="step3_snap",
        volume=step3.pvolume
    )

    step4 = dsl.ContainerOp(
        name="step4_output",
        image="library/bash:4.4.23",
        command=["cat", "/data/step2/file1", "/data/step3/file3"],
        pvolumes={"/data": step3.pvolume}
    )
예제 #5
0
def volumeop_basic(size: str="1Gi"):
    vop = dsl.VolumeOp(
        name="create-pvc",
        resource_name="my-pvc",
        modes=dsl.VOLUME_MODE_RWO,
        size=size
    )

    write_to_volume().add_pvolumes({"/mnt": vop.volume})
def volume_snapshotop_rokurl(rok_url):
    vop1 = dsl.VolumeOp(name="create_volume_1",
                        resource_name="vol1",
                        size="1Gi",
                        annotations={"rok/origin": rok_url},
                        modes=dsl.VOLUME_MODE_RWM)

    step1 = dsl.ContainerOp(
        name="step1_concat",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["cat /data/file*| gzip -c >/data/full.gz"],
        pvolumes={"/data": vop1.volume})

    step1_snap = dsl.VolumeSnapshotOp(name="create_snapshot_1",
                                      resource_name="snap1",
                                      volume=step1.pvolume)

    vop2 = dsl.VolumeOp(name="create_volume_2",
                        resource_name="vol2",
                        data_source=step1_snap.snapshot,
                        size=step1_snap.outputs["size"])

    step2 = dsl.ContainerOp(name="step2_gunzip",
                            image="library/bash:4.4.23",
                            command=["gunzip", "-k", "/data/full.gz"],
                            pvolumes={"/data": vop2.volume})

    step2_snap = dsl.VolumeSnapshotOp(name="create_snapshot_2",
                                      resource_name="snap2",
                                      volume=step2.pvolume)

    vop3 = dsl.VolumeOp(name="create_volume_3",
                        resource_name="vol3",
                        data_source=step2_snap.snapshot,
                        size=step2_snap.outputs["size"])

    step3 = dsl.ContainerOp(name="step3_output",
                            image="library/bash:4.4.23",
                            command=["cat", "/data/full"],
                            pvolumes={"/data": vop3.volume})
예제 #7
0
def volumeop_basic(size):
    vop = dsl.VolumeOp(
        name="create_pvc",
        resource_name="my-pvc",
        modes=dsl.VOLUME_MODE_RWM,
        size=size)

    cop = dsl.ContainerOp(
        name="cop",
        image="library/bash:4.4.23",
        command=["sh", "-c"],
        arguments=["echo foo > /mnt/file1"],
        pvolumes={"/mnt": vop.volume})
예제 #8
0
def volume_op_dag():
    vop = dsl.VolumeOp(name="create_pvc",
                       resource_name="my-pvc",
                       size="10Gi",
                       modes=dsl.VOLUME_MODE_RWM)

    step1 = dsl.ContainerOp(name="step1",
                            image="library/bash:4.4.23",
                            command=["sh", "-c"],
                            arguments=["echo 1 | tee /mnt/file1"],
                            pvolumes={"/mnt": vop.volume})

    step2 = dsl.ContainerOp(name="step2",
                            image="library/bash:4.4.23",
                            command=["sh", "-c"],
                            arguments=["echo 2 | tee /mnt2/file2"],
                            pvolumes={"/mnt2": vop.volume})

    step3 = dsl.ContainerOp(name="step3",
                            image="library/bash:4.4.23",
                            command=["sh", "-c"],
                            arguments=["cat /mnt/file1 /mnt/file2"],
                            pvolumes={"/mnt": vop.volume.after(step1, step2)})