|
| 1 | +* Installed `oc` and git tools. |
| 2 | +* Installed Podman. |
| 3 | +* Log in to the OpenShift cluster where a {prod-short} is deployed as an administrator. |
| 4 | ++ |
| 5 | +[TIP] |
| 6 | +==== |
| 7 | +
|
| 8 | +`$ oc login pass:c,a,q[{prod-url}] --username=__<my_user>__` |
| 9 | + |
| 10 | +==== |
| 11 | +
|
| 12 | +.Procedure |
| 13 | +
|
| 14 | +. Create a new OpenShift project for Open VSX. |
| 15 | ++ |
| 16 | +[subs="+attributes,+quotes"] |
| 17 | +---- |
| 18 | +oc new-project openvsx |
| 19 | +---- |
| 20 | +. Clone Open VSX sources. |
| 21 | ++ |
| 22 | +Get Open VSX sources and navigate to the OpenShift deploy directory: |
| 23 | ++ |
| 24 | +[bash,subs="verbatim",options="nowrap"] |
| 25 | +---- |
| 26 | +git clone https://github.com/eclipse/openvsx.git && |
| 27 | +cd openvsx/deploy/openshift |
| 28 | +---- |
| 29 | +
|
| 30 | +. Prepare Open VSX server image. |
| 31 | ++ |
| 32 | +The next step is to build and publish the Open VSX server image. To do this, run the following commands: |
| 33 | ++ |
| 34 | +[bash,subs="verbatim",options="nowrap"] |
| 35 | +---- |
| 36 | +export REGISTRY=quay.io && |
| 37 | +export NAMESPACE=myuser && |
| 38 | +export OPENVSX_SERVER_IMAGE_NAME=openvsx-server && |
| 39 | +export OPENVSX_VERSION=v0.27.0 && |
| 40 | +export OPENVSX_SERVER_IMAGE=${REGISTRY}/${NAMESPACE}/${OPENVSX_SERVER_IMAGE_NAME}:${OPENVSX_VERSION} && |
| 41 | +podman build -t "${OPENVSX_SERVER_IMAGE}" --build-arg "OPENVSX_VERSION=${OPENVSX_VERSION}" -f openvsx.Dockerfile . && |
| 42 | +podman login "${REGISTRY}" && |
| 43 | +podman push "${OPENVSX_SERVER_IMAGE}" |
| 44 | +---- |
| 45 | ++ |
| 46 | +[IMPORTANT] |
| 47 | +==== |
| 48 | + |
| 49 | +Make sure to configure the correct container registry and namespace for your image. Additionally, ensure that the image is publicly accessible and can be pulled without authentication. |
| 50 | + |
| 51 | +==== |
| 52 | +
|
| 53 | +. Prepare Open VSX CLI image. |
| 54 | ++ |
| 55 | +Build and publish the Open VSX CLI image. To do this, run the following commands: |
| 56 | ++ |
| 57 | +[bash,subs="verbatim",options="nowrap"] |
| 58 | +---- |
| 59 | +export OPENVSX_CLI_IMAGE_NAME=openvsx-cli && |
| 60 | +export OPENVSX_CLI_VERSION=0.10.5 && |
| 61 | +export OPENVSX_CLI_IMAGE=${REGISTRY}/${NAMESPACE}/${OPENVSX_CLI_IMAGE_NAME}:${OPENVSX_CLI_VERSION} && |
| 62 | +podman build -t "${OPENVSX_CLI_IMAGE}" --build-arg "OVSX_VERSION=${OPENVSX_CLI_VERSION}" -f cli.Dockerfile . && |
| 63 | +podman push "${OPENVSX_CLI_IMAGE}" |
| 64 | +---- |
| 65 | ++ |
| 66 | +[IMPORTANT] |
| 67 | +==== |
| 68 | + |
| 69 | +Ensure that the image is publicly accessible and can be pulled without authentication. |
| 70 | + |
| 71 | +==== |
| 72 | +
|
| 73 | +. Deploy Open VSX. |
| 74 | ++ |
| 75 | +[bash,subs="verbatim",options="nowrap"] |
| 76 | +---- |
| 77 | +oc process -f openvsx-deployment.yml \ |
| 78 | +-p OPENVSX_SERVER_IMAGE="${OPENVSX_SERVER_IMAGE}" \ |
| 79 | +-p OPENVSX_CLI_IMAGE="${OPENVSX_CLI_IMAGE}" \ |
| 80 | +| oc apply -f - |
| 81 | +---- |
| 82 | +
|
| 83 | +. Verify that all pods in the `openvsx` namespace are running and ready. It might take a few minutes for all pods to become ready. Run the following command: |
| 84 | ++ |
| 85 | +[bash,subs="verbatim",options="nowrap"] |
| 86 | +---- |
| 87 | +oc get pods -n openvsx \ |
| 88 | + -o jsonpath='{range .items[*]}{@.metadata.name}{"\t"}{@.status.phase}{"\t"}{.status.containerStatuses[*].ready}{"\n"}{end}' |
| 89 | +---- |
| 90 | +
|
| 91 | +. Add Open VSX user with PAT to the database. |
| 92 | ++ |
| 93 | +Find PostgreSQL pod: |
| 94 | ++ |
| 95 | +[bash,subs="verbatim",options="nowrap"] |
| 96 | +---- |
| 97 | +export POSTGRESQL_POD_NAME=$(oc get pods -n openvsx \ |
| 98 | + -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep '^postgresql' | head -n 1) |
| 99 | +---- |
| 100 | ++ |
| 101 | +Insert username into OpenVSX database: |
| 102 | ++ |
| 103 | +[bash,subs="verbatim",options="nowrap"] |
| 104 | +---- |
| 105 | +oc exec -n openvsx "$POSTGRESQL_POD_NAME" -- bash -c \ |
| 106 | + "psql -d openvsx -c \"INSERT INTO user_data (id, login_name, role) VALUES (1001, 'eclipse-che', 'privileged');\"" |
| 107 | +---- |
| 108 | ++ |
| 109 | +Insert user PAT into OpenVSX database: |
| 110 | ++ |
| 111 | +[bash,subs="verbatim",options="nowrap"] |
| 112 | +---- |
| 113 | +oc exec -n openvsx "$POSTGRESQL_POD_NAME" -- bash -c \ |
| 114 | + "psql -d openvsx -c \"INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description) VALUES (1001, 1001, 'eclipse_che_token', true, current_timestamp, current_timestamp, 'extensions publisher');\"" |
| 115 | +---- |
| 116 | +
|
| 117 | +. Configure {prod-short} to use the internal Open VSX. |
| 118 | ++ |
| 119 | +[bash,subs="verbatim",options="nowrap"] |
| 120 | +---- |
| 121 | +export CHECLUSTER_NAME="$(oc get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')" && |
| 122 | +export CHECLUSTER_NAMESPACE="$(oc get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" && |
| 123 | +export OPENVSX_ROUTE_URL="$(oc get route internal -n openvsx -o jsonpath='{.spec.host}')" && |
| 124 | +export PATCH='{"spec":{"components":{"pluginRegistry":{"openVSXURL":"https://'"$OPENVSX_ROUTE_URL"'"}}}}' && |
| 125 | +oc patch checluster "${CHECLUSTER_NAME}" --type=merge --patch "${PATCH}" -n "${CHECLUSTER_NAMESPACE}" |
| 126 | +---- |
| 127 | ++ |
| 128 | +[TIP] |
| 129 | +==== |
| 130 | + |
| 131 | +Refer to the xref:configuring-the-open-vsx-registry-url.adoc[] for detailed instructions on configuring the Open VSX registry URL in {prod-short}. |
| 132 | + |
| 133 | +==== |
| 134 | +
|
| 135 | +. Publish Visual Studio Code extensions with the `ovsx` command. |
| 136 | ++ |
| 137 | +[NOTE] |
| 138 | +==== |
| 139 | + |
| 140 | +At the beginning, the Open VSX registry does not provide any extension. |
| 141 | + |
| 142 | +==== |
| 143 | ++ |
| 144 | +With everything configured, the next step is to publish a Visual Studio Code extension from inside the ovsx-cli container. |
| 145 | +To do this, you need two pieces of information: the extension `namespace` name (used for publishing), the download URL of the .vsix extension package. |
| 146 | +Once you have this information, run the following commands to publish the extension: |
| 147 | ++ |
| 148 | +.. Retrieve the name of the pod running the Open VSX server: |
| 149 | ++ |
| 150 | +[bash,subs="verbatim",options="nowrap"] |
| 151 | +---- |
| 152 | +export OVSX_POD_NAME=$(oc get pods -n openvsx -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^ovsx-cli) |
| 153 | +---- |
0 commit comments