此内容没有您所选择的语言版本。
Chapter 3. Customizing the registries
This chapter describes how to build and run custom registries for CodeReady Workspaces.
3.1. Understanding the CodeReady Workspaces registries 复制链接链接已复制到粘贴板!
CodeReady Workspaces uses two registries: the plug-ins registry and the devfile registry. They are static websites publishing the metadata of CodeReady Workspaces plug-ins and devfiles. When built in offline mode they also include artifacts.
The devfile and plug-in registries run in two separate Pods. Their deployment is part of the CodeReady Workspaces installation.
The devfile and plug-in registries
- The devfile registry
-
The devfile registry holds the definitions of the CodeReady Workspaces stacks. Stacks are available on the CodeReady Workspaces user dashboard when selecting Create Workspace. It contains the list of CodeReady Workspaces technological stack samples with example projects. When built in offline mode it also contains all sample projects referenced in devfiles as
zipfiles. - The plug-in registry
- The plug-in registry makes it possible to share a plug-in definition across all the users of the same instance of CodeReady Workspaces. When built in offline mode it also contains all plug-in or extension artifacts.
Additional resources
3.2. Building custom registry images 复制链接链接已复制到粘贴板!
3.2.1. Building a custom devfile registry image 复制链接链接已复制到粘贴板!
This section describes how to build a custom devfile registry image. The procedure explains how to add a devfile. The image contains all sample projects referenced in devfiles.
Prerequisites
- A running installation of podman or docker.
- Valid content for the devfile to add. See: https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.7/html-single/end-user_guide/index#making-a-workspace-portable-using-a-devfile_crw.
Procedure
Clone the devfile registry repository and check out the version to deploy:
git clone git@github.com:redhat-developer/codeready-workspaces.git cd codeready-workspaces git checkout crw-2.7-rhel-8
$ git clone git@github.com:redhat-developer/codeready-workspaces.git $ cd codeready-workspaces $ git checkout crw-2.7-rhel-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the
./dependencies/che-devfile-registry/devfiles/directory, create a subdirectory<devfile-name>/and add thedevfile.yamlandmeta.yamlfiles.Example 3.1. File organization for a devfile
./dependencies/che-devfile-registry/devfiles/ └── <devfile-name> ├── devfile.yaml └── meta.yaml./dependencies/che-devfile-registry/devfiles/ └── <devfile-name> ├── devfile.yaml └── meta.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Add valid content in the
devfile.yamlfile. For a detailed description of the devfile format, see https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.7/html-single/end-user_guide/index#making-a-workspace-portable-using-a-devfile_crw. Ensure that the
meta.yamlfile conforms to the following structure:Expand Table 3.1. Parameters for a devfile meta.yaml Attribute Description descriptionDescription as it appears on the user dashboard.
displayNameName as it appears on the user dashboard.
globalMemoryLimitThe sum of the expected memory consumed by all the components launched by the devfile. This number will be visible on the user dashboard. It is informative and is not taken into account by the CodeReady Workspaces server.
iconLink to an
.svgfile that is displayed on the user dashboard.tagsList of tags. Tags usually include the tools included in the stack.
Example 3.2. Example devfile
meta.yamldisplayName: Rust description: Rust Stack with Rust 1.39 tags: ["Rust"] icon: https://www.eclipse.org/che/images/logo-eclipseche.svg globalMemoryLimit: 1686Mi
displayName: Rust description: Rust Stack with Rust 1.39 tags: ["Rust"] icon: https://www.eclipse.org/che/images/logo-eclipseche.svg globalMemoryLimit: 1686MiCopy to Clipboard Copied! Toggle word wrap Toggle overflow Build a custom devfile registry image:
cd dependencies/che-devfile-registry ./build.sh --organization <my-org> \ --registry <my-registry> \ --tag <my-tag>$ cd dependencies/che-devfile-registry $ ./build.sh --organization <my-org> \ --registry <my-registry> \ --tag <my-tag>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTo display full options for the
build.shscript, use the--helpparameter.
3.2.2. Building a custom plug-ins registry image 复制链接链接已复制到粘贴板!
This section describes how to build a custom plug-ins registry image. The procedure explains how to add a plug-in. The image contains plug-ins or extensions metadata.
Prerequisites
- NodeJS 12.x
- A running version of yarn. See: Installing Yarn.
-
./node_modules/.binis in thePATHenvironment variable. - A running installation of podman or docker.
-
Valid content for the
meta.yamlfile describing the plug-in to add. See: https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.7/html-single/end-user_guide/index#proc_publishing-metadata-for-a-vs-code-extension_crw.
Procedure
Clone the plug-ins registry repository and check out the version to deploy:
git clone git@github.com:redhat-developer/codeready-workspaces.git cd codeready-workspaces git checkout crw-2.7-rhel-8
$ git clone git@github.com:redhat-developer/codeready-workspaces.git $ cd codeready-workspaces $ git checkout crw-2.7-rhel-8Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the
./dependencies/che-plugin-registry/v3/plugins/directory, create new directories<publisher>/<plugin-name>/<plugin-version>/and ameta.yamlfile in the last directory.Example 3.3. File organization for a plugin
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Add valid content to the
meta.yamlfile. See: https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.7/html-single/end-user_guide/index#proc_publishing-metadata-for-a-vs-code-extension_crw. Create a file named
latest.txtwith content the name of the latest<plugin-version>directory.Example 3.4. Example plug-in files tree
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Build a custom plug-ins registry image:
cd dependencies/che-plugin-registry ./build.sh --organization <my-org> \ --registry <my-registry> \ --tag <my-tag>$ cd dependencies/che-plugin-registry $ ./build.sh --organization <my-org> \ --registry <my-registry> \ --tag <my-tag>Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTo display full options for the
build.shscript, use the--helpparameter. To include the plug-in binaries in the registry image, add the--offlineparameter.
Additional resources
3.3. Running custom registries 复制链接链接已复制到粘贴板!
Prerequisites
The my-plug-in-registry and my-devfile-registry images used in this section are built using the docker command. This section assumes that these images are available on the OpenShift cluster where CodeReady Workspaces is deployed.
These images can be then pushed to:
-
A public container registry such as
quay.io, or the DockerHub. - A private registry.
3.3.1. Deploying registries in OpenShift 复制链接链接已复制到粘贴板!
Procedure
An OpenShift template to deploy the plug-in registry is available in the deploy/openshift/ directory of the GitHub repository.
To deploy the plug-in registry using the OpenShift template, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- If installed using crwctl, the default CodeReady Workspaces project is
openshift-workspaces. The OperatorHub installation method deploys CodeReady Workspaces to the users current project.
The devfile registry has an OpenShift template in the
deploy/openshift/directory of the GitHub repository. To deploy it, run the command:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- If installed using crwctl, the default CodeReady Workspaces project is
openshift-workspaces. The OperatorHub installation method deploys CodeReady Workspaces to the users current project.
Verification steps
The <plug-in> plug-in is available in the plug-in registry.
Example 3.5. Find <plug-in> requesting the plug-in registry API.
URL=$(oc get route -l app=che,component=plugin-registry \ -o 'custom-columns=URL:.spec.host' --no-headers) INDEX_JSON=$(curl -sSL http://${URL}/v3/plugins/index.json) echo ${INDEX_JSON} | jq '.[] | select(.name == "<plug-in>")'$ URL=$(oc get route -l app=che,component=plugin-registry \ -o 'custom-columns=URL:.spec.host' --no-headers) $ INDEX_JSON=$(curl -sSL http://${URL}/v3/plugins/index.json) $ echo ${INDEX_JSON} | jq '.[] | select(.name == "<plug-in>")'Copy to Clipboard Copied! Toggle word wrap Toggle overflow The <devfile> devfile is available in the devfile registry.
Example 3.6. Find <devfile> requesting the devfile registry API.
URL=$(oc get route -l app=che,component=devfile-registry \ -o 'custom-columns=URL:.spec.host' --no-headers) INDEX_JSON=$(curl -sSL http://${URL}/v3/plugins/index.json) echo ${INDEX_JSON} | jq '.[] | select(.name == "<devfile>")'$ URL=$(oc get route -l app=che,component=devfile-registry \ -o 'custom-columns=URL:.spec.host' --no-headers) $ INDEX_JSON=$(curl -sSL http://${URL}/v3/plugins/index.json) $ echo ${INDEX_JSON} | jq '.[] | select(.name == "<devfile>")'Copy to Clipboard Copied! Toggle word wrap Toggle overflow CodeReady Workspaces server points to the URL of the plug-in registry.
Example 3.7. Compare the value of the
CHE_WORKSPACE_PLUGIN__REGISTRY__URLparameter in thecheConfigMap with the URL of the plug-in registry route.Get the value of the
CHE_WORKSPACE_PLUGIN__REGISTRY__URLparameter in thecheConfigMap.oc get cm/che \ -o "custom-columns=URL:.data['CHE_WORKSPACE_PLUGIN__REGISTRY__URL']" \ --no-headers
$ oc get cm/che \ -o "custom-columns=URL:.data['CHE_WORKSPACE_PLUGIN__REGISTRY__URL']" \ --no-headersCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the URL of the plug-in registry route.
oc get route -l app=che,component=plugin-registry \ -o 'custom-columns=URL: .spec.host' --no-headers
$ oc get route -l app=che,component=plugin-registry \ -o 'custom-columns=URL: .spec.host' --no-headersCopy to Clipboard Copied! Toggle word wrap Toggle overflow CodeReady Workspaces server points to the URL of the devfile registry.
Example 3.8. Compare the value of the
CHE_WORKSPACE_DEVFILE__REGISTRY__URLparameter in thecheConfigMap with the URL of the devfile registry route.Get the value of the
CHE_WORKSPACE_DEVFILE__REGISTRY__URLparameter in thecheConfigMap.oc get cm/che \ -o "custom-columns=URL:.data['CHE_WORKSPACE_DEVFILE__REGISTRY__URL']" \ --no-headers
$ oc get cm/che \ -o "custom-columns=URL:.data['CHE_WORKSPACE_DEVFILE__REGISTRY__URL']" \ --no-headersCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the URL of the devfile registry route.
oc get route -l app=che,component=devfile-registry \ -o 'custom-columns=URL: .spec.host' --no-headers
$ oc get route -l app=che,component=devfile-registry \ -o 'custom-columns=URL: .spec.host' --no-headersCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the values do not match, update the ConfigMap and restart the CodeReady Workspaces server.
oc edit cm/codeready (...) oc scale --replicas=0 deployment/codeready oc scale --replicas=1 deployment/codeready
$ oc edit cm/codeready (...) $ oc scale --replicas=0 deployment/codeready $ oc scale --replicas=1 deployment/codereadyCopy to Clipboard Copied! Toggle word wrap Toggle overflow
- The plug-ins are available in the completion to chePlugin components in Devfile tab of a workspace details.
- The plug-ins are available in the Plugin Theia view of a workspace.
- The devfiles are available in the Get Started and Create Custom Workspace tab of the user dashboard.