Set up Python to use your internal registry

Set up pip to use an internal PyPI mirror by mounting a pip.conf file into your workspaces. .Prerequisites

About this task

Procedure

  1. Create a Secret to store the TLS certificate:
    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cert
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
    type: Opaque
    data:
      tls.cer: >-
        <Base64_encoded_TLS_certificate>

    where:

    <Base64_encoded_TLS_certificate>
    The Base64-encoded content of your internal PyPI mirror’s TLS certificate.
  2. Apply the Secret to your project:
    $ oc apply -f tls-cert.yaml -n <your_namespace>
  3. Create a ConfigMap with your pip configuration:
    Warning

    Applying a ConfigMap that sets environment variables might cause a workspace boot loop. If you encounter this behavior, remove the ConfigMap and edit the devfile directly.

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: pip-config
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /home/user/.config/pip
    data:
      pip.conf: |
        [global]
        index-url = <your_internal_pypi_url>
        trusted-host = <your_internal_pypi_host>
        cert = /home/user/certs/tls.cer

    where:

    <your_internal_pypi_url>
    The URL of your internal PyPI mirror.
    <your_internal_pypi_host>
    The hostname of your internal PyPI mirror.
  4. Apply the ConfigMap to your project:
    $ oc apply -f pip-config.yaml -n <your_namespace>
  5. Start or restart your workspace.

Results

  1. Open a terminal in your workspace.
  2. Verify the pip configuration:
    $ pip config list
  3. Install a package to verify the configuration:
    $ pip install requests