13.2. Using a dedicated service to provide data to the Quick access card
When using a dedicated service, you can do the following tasks:
- Use the same service to provide the data to all configurable Developer Hub pages or use a different service for each page.
-
Use the
red-hat-developer-hub-customization-provideras an example service, which provides data for both the Home and Tech Radar pages. Thered-hat-developer-hub-customization-providerservice provides the same data as default Developer Hub data. You can fork thered-hat-developer-hub-customization-providerservice repository from GitHub and modify it with your own data, if required. -
Deploy the
red-hat-developer-hub-customization-providerservice and the Developer Hub Helm chart on the same cluster.
Prerequisites
- You have installed the Red Hat Developer Hub using Helm chart. For more information, see Installing Red Hat Developer Hub on OpenShift Container Platform with the Helm chart.
Procedure
To use a separate service to provide the Home page data, complete the following steps:
- In the Red Hat OpenShift Container Platform web console, click +Add > Import from Git.
Enter the URL of your Git repository into the Git Repo URL field.
To use the
red-hat-developer-hub-customization-providerservice, add the URL for the red-hat-developer-hub-customization-provider repository or your fork of the repository containing your customizations.-
On the General tab, enter
red-hat-developer-hub-customization-providerin the Name field and click Create. On the Advanced Options tab, copy the value from Target Port.
注意Target Port automatically generates a Kubernetes or OpenShift Container Platform service to communicate with.
Add the following code to the
app-config.yamlfile:proxy: endpoints: # Other Proxies # customize developer hub instance '/developer-hub': target: ${HOMEPAGE_DATA_URL}1 changeOrigin: true # Change to "false" in case of using self-hosted cluster with a self-signed certificate secure: true注意The
red-hat-developer-hub-customization-providerservice contains the 8080 port by default. If you are using a custom port, you can specify it with the 'PORT' environmental variable in theapp-config.yamlfile.-
Replace the
HOMEPAGE_DATA_URLby adding the URL torhdh-secretsor by directly replacing it in your custom ConfigMap. - Delete the Developer Hub pod to ensure that the new configurations are loaded correctly.
Verification
To view the service, go to the OpenShift Container Platform web console and click Networking > Service.
注意You can also view Service Resources in the Topology view.
Ensure that the provided API URL for the Home page returns the data in JSON format as shown in the following example:
[ { "title": "Dropdown 1", "isExpanded": false, "links": [ { "iconUrl": "https://imagehost.com/image.png", "label": "Dropdown 1 Item 1", "url": "https://example.com/" }, { "iconUrl": "https://imagehost2.org/icon.png", "label": "Dropdown 1 Item 2", "url": "" } ] }, { "title": "Dropdown 2", "isExpanded": true, "links": [ { "iconUrl": "http://imagehost3.edu/img.jpg", "label": "Dropdown 2 Item 1", "url": "http://example.com" } ] } ]注意If the request call fails or is not configured, the Developer Hub instance falls back to the default local data.
If the images or icons do not load, then allowlist them by adding your image or icon host URLs to the content security policy (csp)
img-srcin your custom ConfigMap as shown in the following example:kind: ConfigMap apiVersion: v1 metadata: name: app-config.yaml data: app-config.yaml: | app: title: Red Hat Developer Hub backend: csp: connect-src: - "'self'" - 'http:' - 'https:' img-src: - "'self'" - 'data:' - <image host url 1> - <image host url 2> - <image host url 3> # Other Configurations