Skip to content

Commit 54f4ade

Browse files
committed
feat: introduce configs for OpenShift deployment and for developing in Eclipse Che
Signed-off-by: Valeriy Svydenko <[email protected]>
1 parent 3f08d6d commit 54f4ade

File tree

10 files changed

+820
-2
lines changed

10 files changed

+820
-2
lines changed

.devfile.yaml

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
schemaVersion: 2.3.0
2+
metadata:
3+
name: openvsx
4+
components:
5+
- name: tool
6+
container:
7+
image: quay.io/devfile/universal-developer-image:ubi8-latest
8+
memoryRequest: 256Mi
9+
memoryLimit: 8Gi
10+
cpuRequest: 100m
11+
cpuLimit: 2000m
12+
env:
13+
- name: OPENVSX_NAMESPACE
14+
value: openvsx
15+
volumeMounts:
16+
- name: local
17+
path: /home/user/.local/
18+
- name: elasticsearch
19+
container:
20+
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.1
21+
memoryRequest: 256Mi
22+
memoryLimit: 2Gi
23+
cpuRequest: 100m
24+
cpuLimit: 800m
25+
endpoints:
26+
- exposure: internal
27+
name: elasticsearch
28+
protocol: tcp
29+
targetPort: 9200
30+
- exposure: internal
31+
name: es9300
32+
protocol: tcp
33+
targetPort: 9300
34+
- exposure: public
35+
name: che-server
36+
targetPort: 8080
37+
- exposure: public
38+
name: che-webui
39+
targetPort: 3000
40+
env:
41+
- name: bootstrap.memory_lock
42+
value: 'true'
43+
- name: cluster.routing.allocation.disk.threshold_enabled
44+
value: 'false'
45+
- name: discovery.type
46+
value: single-node
47+
- name: xpack.ml.enabled
48+
value: 'false'
49+
- name: xpack.security.enabled
50+
value: 'false'
51+
- name: postgresql
52+
container:
53+
image: 'image-registry.openshift-image-registry.svc:5000/openshift/postgresql:15-el8'
54+
memoryRequest: 256Mi
55+
memoryLimit: 2Gi
56+
cpuRequest: 100m
57+
cpuLimit: '1'
58+
env:
59+
- name: POSTGRESQL_USER
60+
value: openvsx
61+
- name: POSTGRESQL_PASSWORD
62+
value: openvsx
63+
- name: POSTGRESQL_DATABASE
64+
value: openvsx
65+
- volume:
66+
ephemeral: true
67+
name: local
68+
69+
commands:
70+
- id: build-cli
71+
exec:
72+
label: "1.1. Build OVSX CLI"
73+
component: tool
74+
workingDir: ${PROJECTS_ROOT}/openvsx/cli
75+
commandLine: |
76+
yarn install &&
77+
yarn prepare
78+
79+
- id: build-webui
80+
exec:
81+
label: "1.2. Build UI Component"
82+
component: tool
83+
workingDir: ${PROJECTS_ROOT}/openvsx/webui
84+
commandLine: |
85+
yarn install &&
86+
yarn build &&
87+
yarn build:default
88+
89+
- id: build-server
90+
exec:
91+
label: "1.3. Build Server Component"
92+
component: tool
93+
workingDir: ${PROJECTS_ROOT}/openvsx
94+
commandLine: |
95+
server/gradlew -p server assemble downloadTestExtensions
96+
97+
- id: run-server
98+
exec:
99+
label: "1.4. Run OpenVSX Server"
100+
component: tool
101+
workingDir: ${PROJECTS_ROOT}/openvsx/server
102+
commandLine: |
103+
./scripts/generate-properties.sh &&
104+
sed -i 's/localhost:5432\/postgres/localhost:5432\/openvsx/g' src/dev/resources/application.yml &&
105+
sed -i 's/username: gitpod/username: openvsx/g' src/dev/resources/application.yml &&
106+
sed -i 's/password: gitpod/password: openvsx/g' src/dev/resources/application.yml &&
107+
./gradlew runServer
108+
109+
- id: run-webui
110+
exec:
111+
label: "1.5. Run OpenVSX WebUI"
112+
component: tool
113+
workingDir: ${PROJECTS_ROOT}/openvsx/webui
114+
commandLine: |
115+
yarn start:default
116+
117+
- id: cli-publish
118+
exec:
119+
label: "1.6. Publish extensions by OVSX CLI"
120+
component: tool
121+
workingDir: ${PROJECTS_ROOT}/openvsx
122+
commandLine: |
123+
nvm use v${NODEJS_20_VERSION}
124+
export OVSX_REGISTRY_URL=http://localhost:8080
125+
export OVSX_PAT=super_token
126+
export PUBLISHERS="DotJoshJohnson eamodio felixfbecker formulahendry HookyQR ms-azuretools ms-mssql ms-python ms-vscode octref redhat ritwickdey sburg vscode vscodevim Wscats"
127+
for pub in $PUBLISHERS; do cli/lib/ovsx create-namespace $pub; done
128+
find server/build/test-extensions-builtin -name '*.vsix' -exec cli/lib/ovsx publish '{}' \;
129+
find server/build/test-extensions -name '*.vsix' -exec cli/lib/ovsx publish '{}' \;
130+
131+
# Commands to deploy OpenVSX to OpenShift
132+
- id: build-openvsx-image
133+
exec:
134+
label: "2.1. Build and Publish OpenVSX Image"
135+
component: tool
136+
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
137+
commandLine: |
138+
read -p "Please enter the value for OPENVSX_VERSION (default: v0.18.0): " OPENVSX_VERSION
139+
OPENVSX_VERSION=${OPENVSX_VERSION:-v0.18.0}
140+
export OPENVSX_VERSION
141+
echo "OPENVSX_VERSION is set to $OPENVSX_VERSION"
142+
podman build -t "openvsx:$OPENVSX_VERSION" --build-arg "OPENVSX_VERSION=$OPENVSX_VERSION" -f openvsx.Dockerfile .&&
143+
oc new-project $OPENVSX_NAMESPACE
144+
export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx &&
145+
podman tag openvsx:$OPENVSX_VERSION ${IMAGE} &&
146+
podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 &&
147+
podman push --tls-verify=false "${IMAGE}"
148+
149+
- id: build-ovsx-cli-image
150+
exec:
151+
label: "2.2. Build and Publish OpenVSX CLI Image"
152+
component: tool
153+
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
154+
commandLine: |
155+
podman build -t "openvsx-cli" -f cli.Dockerfile .&&
156+
export IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli &&
157+
podman tag openvsx-cli ${IMAGE} &&
158+
podman login --tls-verify=false -u $(oc whoami | tr -d :) -p $(oc whoami -t) image-registry.openshift-image-registry.svc:5000 &&
159+
podman push --tls-verify=false "${IMAGE}"
160+
161+
- id: deploy-openvsx
162+
exec:
163+
label: "2.3. Deploy OpenVSX"
164+
component: tool
165+
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
166+
commandLine: |
167+
oc process -f openvsx-deployment.yml \
168+
-p OPENVSX_SERVER_IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx \
169+
-p OPENVSX_CLI_IMAGE=image-registry.openshift-image-registry.svc:5000/$OPENVSX_NAMESPACE/openvsx-cli \
170+
| oc apply -f -
171+
172+
- id: add-openvsx-user-with-pat
173+
exec:
174+
label: "2.4. Add OpenVSX user with PAT to the DB"
175+
component: tool
176+
commandLine: |
177+
read -p "Please enter OpenVSX user name (default: eclipse-che): " OPENVSX_USER_NAME
178+
OPENVSX_USER_NAME=${OPENVSX_USER_NAME:-eclipse-che}
179+
export OPENVSX_USER_NAME
180+
echo "OPENVSX_USER_NAME is set to $OPENVSX_USER_NAME"
181+
read -p "Please enter the value for OpenVSX user PAT (default: eclipse_che_token): " OPENVSX_USER_PAT
182+
OPENVSX_USER_PAT=${OPENVSX_USER_PAT:-eclipse_che_token}
183+
export OPENVSX_USER_PAT
184+
echo "OPENVSX_USER_PAT is set to $OPENVSX_USER_PAT"
185+
export POSTGRESQL_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^postgresql) &&
186+
kubectl exec -n "${OPENVSX_NAMESPACE}" "${POSTGRESQL_POD_NAME}" -- bash -c "psql -d openvsx -c \"INSERT INTO user_data (id, login_name, role) VALUES (1001, '$OPENVSX_USER_NAME', 'privileged');\"" &&
187+
kubectl exec -n "${OPENVSX_NAMESPACE}" "${POSTGRESQL_POD_NAME}" -- bash -c "psql -d openvsx -c \"INSERT INTO personal_access_token (id, user_data, value, active, created_timestamp, accessed_timestamp, description) VALUES (1001, 1001, '$OPENVSX_USER_PAT', true, current_timestamp, current_timestamp, 'extensions publisher');\""
188+
189+
- id: enable-internal-openvsx
190+
exec:
191+
label: "2.5. Configure Che to use the internal OpenVSX registry"
192+
component: tool
193+
workingDir: ${PROJECTS_ROOT}/openvsx/openshift
194+
commandLine: |
195+
export CHECLUSTER_NAME="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.name')" &&
196+
export CHECLUSTER_NAMESPACE="$(kubectl get checluster --all-namespaces -o json | jq -r '.items[0].metadata.namespace')" &&
197+
export OPENVSX_ROUTE_URL="$(oc get route internal -n "$OPENVSX_NAMESPACE" -o jsonpath='{.spec.host}')" &&
198+
export PATCH='{"spec":{"components":{"pluginRegistry":{"openVSXURL":"https://'"$OPENVSX_ROUTE_URL"'"}}}}' &&
199+
kubectl patch checluster "${CHECLUSTER_NAME}" --type=merge --patch "${PATCH}" -n "${CHECLUSTER_NAMESPACE}"
200+
201+
- id: publish-extension
202+
exec:
203+
label: "2.6. Publish VS Code Extension to the internal OpenVSX"
204+
component: tool
205+
commandLine: |
206+
read -p "Please enter extension's namespace name: " EXTENSION_NAMESPACE_NAME
207+
EXTENSION_NAMESPACE_NAME=${EXTENSION_NAMESPACE_NAME}
208+
export EXTENSION_NAMESPACE_NAME
209+
echo "EXTENSION_NAMESPACE_NAME is set to $EXTENSION_NAMESPACE_NAME"
210+
read -p "Please enter extension's download URL: " EXTENSION_DOWNLOAD_URL
211+
EXTENSION_DOWNLOAD_URL=${EXTENSION_DOWNLOAD_URL}
212+
export EXTENSION_DOWNLOAD_URL
213+
echo "EXTENSION_DOWNLOAD_URL is set to $EXTENSION_DOWNLOAD_URL"
214+
export OVSX_POD_NAME=$(kubectl get pods -n "$OPENVSX_NAMESPACE" -o jsonpath="{.items[*].metadata.name}" | tr ' ' '\n' | grep ^ovsx-cli) &&
215+
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "wget -O /tmp/extension.vsix '$EXTENSION_DOWNLOAD_URL' " &&
216+
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx create-namespace '$EXTENSION_NAMESPACE_NAME'" || true &&
217+
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "ovsx publish /tmp/extension.vsix" &&
218+
kubectl exec -n "${OPENVSX_NAMESPACE}" "${OVSX_POD_NAME}" -- bash -c "rm /tmp/extension.vsix"

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"redhat.java",
55
"vscjava.vscode-java-debug",
66
"vscjava.vscode-java-test",
7-
"richardwillis.vscode-gradle"
7+
"richardwillis.vscode-gradle",
8+
"redhat.vscode-yaml"
89
]
910
}

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Eclipse Open VSX
22

33
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/eclipse/openvsx)
4+
[![Contribute](https://www.eclipse.org/che/contribute.svg)](https://workspaces.openshift.com#https://github.com/eclipse/openvsx)
45
[![Join the chat at https://gitter.im/eclipse/openvsx](https://badges.gitter.im/eclipse/openvsx.svg)](https://gitter.im/eclipse/openvsx)
56
[![CI](https://github.com/eclipse/openvsx/workflows/CI/badge.svg)](https://github.com/eclipse/openvsx/actions?query=workflow%3ACI)
67

@@ -17,12 +18,16 @@ See the [openvsx Wiki](https://github.com/eclipse/openvsx/wiki) for documentatio
1718

1819
## Development
1920

20-
The easiest way to get a development environment for this project is to open it in [Gitpod](https://gitpod.io/).
21+
- The easiest way to get a development environment for this project is to open it in [Gitpod](https://gitpod.io/).
2122

2223
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/eclipse/openvsx)
2324

2425
Click _Open Browser_ on port 3000 to see the running web application.
2526

27+
- Open a development environment in [Red Hat OpenShift Dev Spaces](https://docs.redhat.com/en/documentation/red_hat_openshift_dev_spaces), it is an open source product based on Eclipse Che that is running on [OpenShift Dedicated](https://www.redhat.com/en/technologies/cloud-computing/openshift/dedicated).
28+
29+
[![Open in Dev Spaces](https://www.eclipse.org/che/contribute.svg)](https://workspaces.openshift.com#https://github.com/eclipse/openvsx)
30+
2631
### cli
2732

2833
* `yarn build` &mdash; build the library and `ovsx` command

doc/development.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ To get started quickly, it is recommended to use Gitpod as default with the deve
66

77
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/eclipse/openvsx)
88

9+
### Using Red Hat OpenShift Dev Spaces
10+
11+
Open a development environment in Red Hat OpenShift Dev Spaces.
12+
13+
[![Open in Dev Spaces](https://www.eclipse.org/che/contribute.svg)](https://workspaces.openshift.com#https://github.com/eclipse/openvsx)
14+
15+
In the workspace, you'll find a set of predefined commands from the devfile.yaml that will assist you in building, running, and testing the application:
16+
* 1.1. Build OVSX CLI
17+
* 1.2. Build UI Component
18+
* 1.3. Build Server Component
19+
* 1.4. Run OpenVSX Server
20+
* 1.5. Run OpenVSX WebUI
21+
* 1.6. Publish extensions by OVSX CLI
22+
23+
To execute any of these commands within your workspace, navigate to Terminal -> Run Task -> devfile.
24+
925
### Using Docker Compose
1026

1127
To run the Open VSX registry in a development environment, you can use `docker compose` by following these steps:

openshift/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Deploying a Private OpenVSX Registry on OpenShift
2+
3+
This guide provides the necessary steps to deploy a private OpenVSX registry on OpenShift. By following the instructions, you'll have a fully operational OpenVSX server and CLI deployed within your OpenShift cluster, ready to be used by Eclipse Che or other services.
4+
5+
## Prerequisites
6+
- [Deploy and run Eclipse Che on your cluster](https://eclipse.dev/che/docs/stable/administration-guide/installing-che-in-the-cloud/)
7+
- [Create a workspace](https://eclipse.dev/che/docs/stable/end-user-guide/starting-a-workspace-from-a-git-repository-url/) from the [openvsx Git repository URL](https://github.com/eclipse/openvsx)
8+
9+
## Step-by-Step Instructions
10+
In the workspace, you'll find a set of predefined commands from the `devfile.yaml` that will assist you in preparing and deploying a private OpenVSX registry. To execute any of these commands within your workspace, navigate to Terminal -> Run Task -> devfile:
11+
12+
* 2.1. Build and Publish OpenVSX Image
13+
14+
Build the OpenVSX image and push it to the OpenShift internal registry. You'll ask to enter the OpenVSX version to deploy (default is v0.18.0).
15+
16+
* 2.2. Build and Publish OpenVSX CLI Image
17+
18+
Build the OpenVSX CLI image and push it to the OpenShift internal registry.
19+
20+
* 2.3. Deploy OpenVSX
21+
22+
Deploy the OpenVSX registry using the provided `openvsx-deployment.yml` template
23+
24+
* 2.4. Add OpenVSX user with PAT to the DB
25+
26+
This command adds a new OpenVSX user along with a Personal Access Token (PAT) to the PostgreSQL database.
27+
28+
* 2.5. Configure Che to use the internal OpenVSX registry
29+
30+
In case you have deployed Eclipse Che on the cluster, you can patch it to use your private OpenVSX registry.
31+
32+
* 2.6. Publish VS Code Extension to the internal OpenVSX
33+
34+
This command facilitates publishing a VS Code extension to the local OpenVSX registry. It prompts the user to provide the extension's namespace name and download URL. The extension is then downloaded into a temporary folder inside the ovsx-cli pod, a namespace is created (if not already present), and the extension is published to the OpenVSX registry. Afterward, the temporary file is deleted. This command is ideal for adding custom or internal extensions to a local OpenVSX instance.
35+
36+
## OpenShift Template (openvsx-deployment.yml)
37+
You can find the deployment YAML configuration in the `openvsx-deployment.yml` file. This template defines the deployments, services, and route for the PostgreSQL database, Elasticsearch, OpenVSX Server, and OpenVSX CLI.
38+
39+
### Important Parameters
40+
* `ROUTE_NAME`: The name of the route to access the OpenVSX server (default: internal)
41+
* `NAMESPACE`: The namespace where OpenVSX will be deployed (default: openvsx)
42+
* `POSTGRESQL_IMAGE`: The PostgreSQL image to use for the database (default: image-registry.openshift-image-registry.svc:5000/openshift/postgresql:15-el8)
43+
* `OPENVSX_ELASTICSEARCH_IMAGE`: The image for Elasticsearch (default: docker.elastic.co/elasticsearch/elasticsearch:8.7.1).
44+
* `OPENVSX_SERVER_IMAGE`: The image for the OpenVSX Server.
45+
* `OPENVSX_CLI_IMAGE`: The image for the OpenVSX CLI.
46+
* `OVSX_PAT_BASE64`: Base64 encoded OVSX personal access token.
47+
* `GITHUB_CLIENT_ID_BASE64` and `GITHUB_CLIENT_SECRET_BASE64`: Base64 encoded GitHub Client ID and Secret to setup GitHub OAuth.

0 commit comments

Comments
 (0)