Python

    Versions

    Currently, OKD provides versions , 3.3, , and 3.5 of Python.

    These images come in two flavors, depending on your needs:

    • RHEL 7

    RHEL 7 Based Images

    The RHEL 7 images are available through the Red Hat Registry:

    CentOS 7 Based Images

    These images are available on Docker Hub:

    To use these images, you can either access them directly from these or push them into your OKD container image registry. Additionally, you can create an that points to the image, either in your container image registry or at the external location. Your OKD resources can then reference the ImageStream. You can find example image stream definitions for all the provided OKD images.

    Build Process

    S2I produces ready-to-run images by injecting source code into a container and letting the container prepare that source code for execution. It performs the following steps:

    1. Starts a container from the builder image.

    2. Downloads the application source.

    3. Saves the final image.

    See S2I Build Process for a detailed overview of the build process.

    The Python image supports a number of environment variables which can be set to control the configuration and behavior of the Python runtime.

    To set these environment variables as part of your image, you can place them into inside your source code repository, or define them in the environment section of the build configuration’s definition.

    You can also set environment variables to be used with an existing image when , or by updating environment variables for existing objects such as deployment configurations.

    Hot Deploying

    Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new S2I build. If you are using Django, hot deployment works out of the box.

    To enable hot deployment while using Gunicorn, ensure you have a Gunicorn configuration file inside your repository with the **reload** option set to true. Specify your configuration file using the **APP_CONFIG** environment variable. For example, see the command. You can use the oc set env command to update environment variables of existing objects.

    To change your source code in a running pod, use the command to enter the container: