Last active
May 30, 2024 18:48
-
-
Save rafaeltuelho/37657c96828909b3ec5298bec4790a33 to your computer and use it in GitHub Desktop.
Sample NodeJS DevWorkspace CR which creates a Openshift DevSpaces workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: workspace.devfile.io/v1alpha2 | |
kind: DevWorkspace | |
metadata: | |
annotations: | |
che.eclipse.org/che-editor: che-incubator/che-code/latest | |
name: nodejs-mongodb | |
namespace: user1-devspaces | |
finalizers: | |
- rbac.controller.devfile.io | |
spec: | |
contributions: | |
- name: ide | |
uri: https://devspaces.apps.cluster-4qzct.4qzct.sandbox2558.opentlc.com/plugin-registry/v3/plugins/che-incubator/che-code/latest/devfile.yaml | |
routingClass: che | |
started: true | |
template: | |
attributes: | |
controller.devfile.io/devworkspace-config: | |
name: devworkspace-config | |
namespace: openshift-devspaces | |
controller.devfile.io/scc: container-build | |
controller.devfile.io/storage-type: per-workspace | |
commands: | |
- exec: | |
commandLine: npm install && node --inspect=9229 app.js | |
component: nodejs | |
group: | |
kind: run | |
label: Run the application | |
workingDir: '${PROJECTS_ROOT}/nodejs-mongodb-sample' | |
id: 1-run | |
components: | |
- container: | |
cpuRequest: '1' | |
env: | |
- name: SECRET | |
value: 220fd770-c028-480d-8f95-f84353c7d55a | |
- name: NODE_ENV | |
value: production | |
memoryRequest: 512Mi | |
sourceMapping: /projects | |
cpuLimit: '2' | |
volumeMounts: | |
- name: npm | |
path: /home/user/.npm | |
memoryLimit: 1Gi | |
image: >- | |
registry.redhat.io/devspaces/udi-rhel8@sha256:022cc606ec53638f7079a638f0810fee3a1717b42426bcfa31c2ba2e78520c54 | |
endpoints: | |
- exposure: public | |
name: nodejs | |
protocol: https | |
targetPort: 8080 | |
mountSources: true | |
name: nodejs | |
- name: npm | |
volume: | |
size: 1G | |
- container: | |
cpuRequest: '0.25' | |
env: | |
- name: MONGODB_USER | |
value: user | |
- name: MONGODB_PASSWORD | |
value: password | |
- name: MONGODB_DATABASE | |
value: guestbook | |
- name: MONGODB_ADMIN_PASSWORD | |
value: password | |
memoryRequest: 256Mi | |
sourceMapping: /projects | |
cpuLimit: '1' | |
volumeMounts: | |
- name: mongo-storage | |
path: /var/lib/mongodb/data | |
memoryLimit: 512Mi | |
image: >- | |
registry.redhat.io/rhscl/mongodb-36-rhel7@sha256:9f799d356d7d2e442bde9d401b720600fd9059a3d8eefea6f3b2ffa721c0dc73 | |
endpoints: | |
- exposure: internal | |
name: mongodb | |
protocol: http | |
targetPort: 27017 | |
mountSources: false | |
name: mongo | |
- name: mongo-storage | |
volume: | |
size: 1G | |
projects: | |
- name: nodejs-mongodb-sample | |
zip: | |
location: >- | |
http://devfile-registry.openshift-devspaces.svc:8080/resources/v2/nodejs-mongodb-sample.zip |
Remember you need also to create and annotate the user's namespace properly before. Here is an user namespace sample definition.
kind: Namespace
apiVersion: v1
metadata:
name: user1-devspaces # <-- change username here
labels:
app.kubernetes.io/component: workspaces-namespace
app.kubernetes.io/part-of: che.eclipse.org
kubernetes.io/metadata.name: user1-devspaces # <-- change username here
annotations:
che.eclipse.org/username: user1 # <-- change username here
openshift.io/description: 'DevSpaces workspace for user1'
spec: {}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference: https://access.redhat.com/documentation/en-us/red_hat_openshift_dev_spaces/3.13/html-single/user_guide/index#managing-workspaces-with-apis-creating-workspaces