Deploy Open VSX from source

Build custom Open VSX server and CLI images from source and deploy them to your cluster. Use this method when you need a specific Open VSX version or custom modifications to the registry.

Prerequisites
  • You have the kubectl tool installed.

  • You are logged in to the cluster where Che is deployed as a cluster administrator.

    $ kubectl login https://<che_fqdn> --username=<my_user>

  • You have Podman installed.

  • You have access to a container registry where you can push images.

  • You have jq installed.

Procedure
  1. Create a new namespace for Open VSX:

    kubectl create namespace openvsx
  2. Clone the Open VSX repository and navigate to the deployment directory:

    git clone https://github.com/eclipse-openvsx/openvsx.git &&
    cd openvsx/deploy/openshift
  3. Build and push the Open VSX server image:

    export REGISTRY=<registry_hostname>
    export NAMESPACE=<registry_namespace>
    export OPENVSX_VERSION=<openvsx_version>
    export OPENVSX_SERVER_IMAGE=${REGISTRY}/$namespace/openvsx-server:${OPENVSX_VERSION}
    
    podman build -t "${OPENVSX_SERVER_IMAGE}" \
      --build-arg "OPENVSX_VERSION=${OPENVSX_VERSION}" -f openvsx.Dockerfile . &&
    podman login "${REGISTRY}" &&
    podman push "${OPENVSX_SERVER_IMAGE}"

    where:

    <registry_hostname>

    The container registry hostname. For example: quay.io.

    <registry_namespace>

    Your organization or account in the registry. For example: myuser.

    <openvsx_version>

    The Open VSX version tag to build. For example: v0.33.0. Available versions are listed on the Open VSX releases page.

    Ensure that the image is publicly accessible or that the cluster can pull from the registry with appropriate credentials.

  4. Build and push the Open VSX CLI image:

    export OPENVSX_CLI_VERSION=<cli_version>
    export OPENVSX_CLI_IMAGE=${REGISTRY}/$namespace/openvsx-cli:${OPENVSX_CLI_VERSION}
    
    podman build -t "${OPENVSX_CLI_IMAGE}" \
      --build-arg "OVSX_VERSION=${OPENVSX_CLI_VERSION}" -f cli.Dockerfile . &&
    podman push "${OPENVSX_CLI_IMAGE}"

    where:

    <cli_version>

    The Open VSX CLI version. For example: 0.10.9.

  5. Deploy Open VSX with the custom images:

    kubectl process -f openvsx-deployment.yml \
      -p OPENVSX_SERVER_IMAGE="${OPENVSX_SERVER_IMAGE}" \
      -p OPENVSX_CLI_IMAGE="${OPENVSX_CLI_IMAGE}" \
      | kubectl apply -f -
  6. Verify that all pods in the openvsx namespace are running and ready:

    kubectl get pods -n openvsx \
      -o jsonpath='{range .items[]}{@.metadata.name}{"\t"}{@.status.phase}{"\t"}{.status.containerStatuses[].ready}{"\n"}{end}'
  7. Add an Open VSX user with a Personal Access Token (PAT) to the database.

    1. Find the PostgreSQL pod:

      export POSTGRESQL_POD_NAME=$(kubectl get pods -n openvsx \
         -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep '^postgresql' | head -n 1)
    2. Insert the username into the Open VSX database:

      kubectl exec -n openvsx "$POSTGRESQL_POD_NAME" -- bash -c \
         "psql -d openvsx -c \"INSERT INTO user_data (id, login_name, role) VALUES (1001, 'eclipse-che', 'privileged');\""
    3. Insert the user PAT into the Open VSX database:

      kubectl exec -n openvsx "$POSTGRESQL_POD_NAME" -- bash -c \
         "psql -d openvsx -c \"INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description, notified) VALUES (1001, 1001, 'eclipse_che_token', true, current_timestamp, current_timestamp, 'extensions publisher', false);\""

      The user PAT must match the decoded value of OVSX_PAT_BASE64 specified in the deployment file. If you update OVSX_PAT_BASE64, use the new decoded value as the user PAT.

  8. Configure Che to use the internal Open VSX registry:

    export CHECLUSTER_NAME="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')" &&
    export CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" &&
    export OPENVSX_ROUTE_URL="$(kubectl get route internal -n openvsx -o jsonpath='{.spec.host}')" &&
    export PATCH='{"spec":{"components":{"pluginRegistry":{"openVSXURL":"https://'"$OPENVSX_ROUTE_URL"'"}}}}' &&
    kubectl patch checluster "${CHECLUSTER_NAME}" --type=merge --patch "${PATCH}" -n "${CHECLUSTER_NAMESPACE}"
  9. Publish a Visual Studio Code extension from a .vsix file. The Open VSX registry does not provide any extension by default.

    1. Retrieve the name of the pod running the Open VSX server:

      export OVSX_POD_NAME=$(kubectl get pods -n openvsx -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^openvsx-server)
    2. Download the .vsix extension:

      kubectl exec -n openvsx "${OVSX_POD_NAME}" -- bash -c "wget -O /tmp/extension.vsix <EXTENSION_DOWNLOAD_URL>"
    3. Create an extension namespace:

      kubectl exec -n openvsx "${OVSX_POD_NAME}" -- bash -c "ovsx create-namespace <EXTENSION_NAMESPACE_NAME>" || true
    4. Publish the extension:

      kubectl exec -n openvsx "${OVSX_POD_NAME}" -- bash -c "ovsx publish /tmp/extension.vsix"
    5. Delete the downloaded extension file:

      kubectl exec -n openvsx "${OVSX_POD_NAME}" -- bash -c "rm /tmp/extension.vsix"
  10. Optional: Publish multiple extensions from a list. Update the deploy/openshift/extensions.txt file with the download URLs of each .vsix file, then publish all listed extensions:

    while IFS= read -r url; do
      kubectl exec -n openvsx "${OVSX_POD_NAME}" -- bash -c "wget -O /tmp/extension.vsix '$url' && ovsx publish /tmp/extension.vsix && rm /tmp/extension.vsix"
    done < deploy/openshift/extensions.txt
Verification
  • Start any workspace and verify the published extensions are available in the Extensions view of the workspace IDE.

  • Navigate to the Open VSX route URL to verify the registry UI displays the published extensions.

Next steps