<p>I recently found out about kubeflow and kubeflow pipeline but it is not clear for me how to build an image from my python program.</p>

<p>Let's assume that I have a simple python function that crops images:</p>

<pre><code>class Image_Proc:
    def crop_image(self, image, start_pixel, end_pixel):
        # crop
        return cropped_image
</code></pre>

<p>How shall I containerize this and use it in the KubeFlow pipeline? Do I need to wrap it in an API (with Flask for example) Or do I need to connect to some media/data broker?</p>

<p>How KubeFlow pipeline sends input to this code and transfers the output of this code to the next step?</p>

AVarf
<p>Basically you can follow the steps provided by Docker <a href="https://docs.docker.com/get-started/part2/" rel="nofollow noreferrer">here</a> to create Docker image and publish to Docker Hub (or you can build your own private docker registry, but I think it may be too much work for beginner). Just roughly list steps:</p>

<ol>
<li>Create Dockerfile. In your Dockerfile, just specify several things: base image (for you case, just use python image from Docker), working directory and what commands to be executed when running this image</li>
<li>Run your Image locally to make sure it works as expected (Install docker first if you haven't), then push to Docker Hub</li>
<li>Once published, you will have the image URL after publishing to Docker Hub, then use that url when you create pipelines in Kubeflow.</li>
</ol>

<p>Also, you can read this <a href="https://github.com/argoproj/argo/blob/master/examples/README.md" rel="nofollow noreferrer">doc</a> to know how to create pipelines (Kubeflow pipeline is just argo workflow). For your case, just fill in <code>inputs</code> and/or <code>outputs</code> sections of the step you want in the pipeline YAML file.</p>
