Chapter 1. Provisioning and using your custom Red Hat Developer Hub configuration
Chapter 1. Provisioning and using your custom Red Hat Developer Hub configuration To configure Red Hat Developer Hub, use these methods, which are widely used to configure a Red Hat OpenShift Container Platform application: Use config maps to mount files and directories. Use secrets to inject environment variables. Learn to apply these methods to Developer Hub: Provision your custom config maps and secrets to OpenShift Container Platform . Use your selected deployment method to mount the config maps and inject the secrets: Use the Red Hat Developer Hub operator to deploy Developer Hub . Use the Red Hat Developer Hub Helm chart to deploy Developer Hub . 1.1. Provisioning your custom Red Hat Developer Hub configuration To configure Red Hat Developer Hub, provision your custom Red Hat Developer Hub config maps and secrets to Red Hat OpenShift Container Platform before running Red Hat Developer Hub. Tip You can skip this step to run Developer Hub with the default config map and secret. Your changes on this configuration might get reverted on Developer Hub restart. Prerequisites By using the OpenShift CLI ( oc ) , you have access, with developer permissions, to the OpenShift Container Platform cluster aimed at containing your Developer Hub instance. Procedure Author your custom my-rhdh-secrets.txt file to provision your secrets as environment variables values in an OpenShift Container Platform secret, rather than in clear text in your configuration files. It contains one secret per line in KEY=value form. Enter your authentication secrets . Author your custom app-config.yaml file. This is the main Developer Hub configuration file. The baseUrl field is mandatory in your app-config.yaml file to ensure proper functionality of Developer Hub. You must specify the baseUrl in both the app and backend sections to avoid errors during initialization. Example 1.1. Configuring the baseUrl in app-config.yaml app: title: Red Hat Developer Hub baseUrl: https:// <my_developer_hub_url> backend: auth: externalAccess: - type: legacy options: subject: legacy-default-config secret: "USD{BACKEND_SECRET}" baseUrl: https:// <my_developer_hub_url> cors: origin: https:// <my_developer_hub_url> Optionally, enter your configuration such as: Authentication . Authorization . Customization . Configure your OpenShift Container Platform integration . Provision your custom configuration files to your OpenShift Container Platform cluster. Create the <my-rhdh-project> project aimed at containing your Developer Hub instance. USD oc create namespace my-rhdh-project Alternatively, create the project by using the web console . Provision your app-config.yaml file to the my-rhdh-app-config config map in the <my-rhdh-project> project. USD oc create configmap my-rhdh-app-config --from-file=app-config.yaml --namespace=my-rhdh-project Alternatively, create the config map by using the web console . Provision your my-rhdh-secrets.txt file to the my-rhdh-secrets secret in the <my-rhdh-project> project. USD oc create secret generic my-rhdh-secrets --from-file=my-rhdh-secrets.txt --namespace=my-rhdh-project Alternatively, create the secret by using the web console . steps Consider provisioning additional config maps and secrets: To use an external PostgreSQL database, provision your PostgreSQL database secrets . To enable dynamic plugins, provision your dynamic plugins config map . To configure authorization by using external files, provision your RBAC policies config map . 1.2. Using the Red Hat Developer Hub operator to run Developer Hub with your custom configuration To use the Developer Hub operator to run Red Hat Developer Hub with your custom configuration, create your Backstage custom resource (CR) that: Mounts files provisioned in your custom config maps. Injects environment variables provisioned in your custom secrets. Prerequisites By using the OpenShift CLI ( oc ) , you have access, with developer permissions, to the OpenShift Container Platform cluster aimed at containing your Developer Hub instance. Your OpenShift Container Platform administrator has installed the Red Hat Developer Hub Operator in OpenShift Container Platform . You have provisioned your custom config maps and secrets in your <my-rhdh-project> project . Procedure Author your Backstage CR in a my-rhdh-custom-resource.yaml file to use your custom config maps and secrets. Example 1.2. Minimal my-rhdh-custom-resource.yaml custom resource example apiVersion: rhdh.redhat.com/v1alpha3 kind: Backstage metadata: name: my-rhdh-custom-resource spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config extraEnvs: secrets: - name: my-rhdh-secrets extraFiles: mountPath: /opt/app-root/src replicas: 1 route: enabled: true database: enableLocalDb: true Example 1.3. my-rhdh-custom-resource.yaml custom resource example with dynamic plugins and RBAC policies config maps, and external PostgreSQL database secrets. apiVersion: rhdh.redhat.com/v1alpha3 kind: Backstage metadata: name: <my-rhdh-custom-resource> spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config - name: rbac-policies dynamicPluginsConfigMapName: dynamic-plugins-rhdh extraEnvs: secrets: - name: my-rhdh-secrets - name: my-rhdh-database-secrets extraFiles: mountPath: /opt/app-root/src secrets: - name: my-rhdh-database-certificates-secrets key: postgres-crt.pem, postgres-ca.pem, postgres-key.key replicas: 1 route: enabled: true database: enableLocalDb: false Mandatory fields No fields are mandatory. You can create an empty Backstage CR and run Developer Hub with the default configuration. Optional fields spec.application.appConfig.configMaps Enter your config map name list. .Mount files in the my-rhdh-app-config config map. spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config Example 1.4. Mount files in the my-rhdh-app-config and rbac-policies config maps. spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config - name: rbac-policies spec.application.extraEnvs.envs Optionally, enter your additional environment variables that are not secrets, such as your proxy environment variables . Example 1.5. Inject your HTTP_PROXY , HTTPS_PROXY and NO_PROXY environment variables. spec: application: extraEnvs: envs: - name: HTTP_PROXY value: 'http://10.10.10.105:3128' - name: HTTPS_PROXY value: 'http://10.10.10.106:3128' - name: NO_PROXY value: 'localhost,example.org' spec.application.extraEnvs.secrets Enter your environment variables secret name list. Example 1.6. Inject the environment variables in your my-rhdh-secrets secret spec: application: extraEnvs: secrets: - name: my-rhdh-secrets Example 1.7. Inject the environment variables in the my-rhdh-secrets and my-rhdh-database-secrets secrets spec: application: extraEnvs: secrets: - name: my-rhdh-secrets - name: my-rhdh-database-secrets spec.application.extraFiles.secrets Enter your certificates files secret name and files list. Mount the postgres-crt.pem , postgres-ca.pem , and postgres-key.key files contained in the my-rhdh-database-certificates-secrets secret spec: application: extraFiles: mountPath: /opt/app-root/src secrets: - name: my-rhdh-database-certificates-secrets key: postgres-crt.pem, postgres-ca.pem, postgres-key.key spec.database.enableLocalDb Enable or disable the local PostgreSQL database. Disable the local PostgreSQL database generation to use an external postgreSQL database spec: database: enableLocalDb: false On a development environment, use the local PostgreSQL database spec: database: enableLocalDb: true spec.deployment Optionally, enter your deployment configuration . Apply your Backstage CR to start or update your Developer Hub instance. USD oc apply --filename=my-rhdh-custom-resource.yaml --namespace=my-rhdh-project 1.2.1. Mounting additional files in your custom configuration using the Red Hat Developer Hub Operator You can use the Developer Hub Operator to mount extra files, such as a ConfigMap or Secret, to the container in a preferred location. The mountPath field specifies the location where a ConfigMap or Secret is mounted. The behavior of the mount, whether it includes or excludes a subPath , depends on the specification of the key or mountPath fields. If key and mountPath are not specified: Each key or value is mounted as a filename or content with a subPath . If key is specified with or without mountPath : The specified key or value is mounted with a subPath . If only mountPath is specified: A directory containing all the keys or values is mounted without a subPath . Note OpenShift Container Platform does not automatically update a volume mounted with subPath . By default, the RHDH operator monitors these ConfigMaps or Secrets and refreshes the RHDH Pod when changes occur. For security purposes, Red Hat Developer Hub does not give the Operator Service Account read access to Secrets. As a result, mounting files from Secrets without specifying both mountPath and key is not supported. Prerequisites You have developer permissions to access the OpenShift Container Platform cluster containing your Developer Hub instance using the OpenShift CLI ( oc ). Your OpenShift Container Platform administrator has installed the Red Hat Developer Hub Operator in OpenShift Container Platform . Procedure In OpenShift Container Platform, create your ConfigMap or Secret with the following YAML codes: Example 1.8. Minimal my-project-configmap ConfigMap example apiVersion: v1 kind: ConfigMap metadata: name: my-project-configmap data: file11.txt: | My file11 content file 12.txt: | My file12 content Example 1.9. Minimal my-rhdh-secrets Secret example apiVersion: v1 kind: Secret metadata: name: my-rhdh-secrets StringData: secret11.txt: | secret-content For more information, see Provisioning and using your custom Red Hat Developer Hub configuration . Set the value of the configMaps name to the name of the ConfigMap or secrets name to the name of the Secret in your Backstage CR. For example: spec: application: extraFiles: mountPath: /my/path configMaps: - name: my-project-configmap key: file12.txt mountPath: /my/my-rhdh-config-map/path secrets: - name: my-rhdh-secrets key: secret11.txt mountPath: /my/my-rhdh-secret/path 1.3. Using the Red Hat Developer Hub Helm chart to run Developer Hub with your custom configuration You can use the Red Hat Developer Hub Helm chart to add a custom application configuration file to your OpenShift Container Platform instance. Prerequisites By using the OpenShift Container Platform web console, you have access with developer permissions, to an OpenShift Container Platform project named <my-rhdh-project> , aimed at containing your Developer Hub instance. You have uploaded your custom configuration files and secrets in your <my-rhdh-project> project . Procedure Configure Helm to use your custom configuration files in Developer Hub. Go to the Helm tab to see the list of Helm releases. Click the overflow menu on the Helm release that you want to use and select Upgrade . Use the YAML view to edit the Helm configuration. Set the value of the upstream.backstage.extraAppConfig.configMapRef and upstream.backstage.extraAppConfig.filename parameters as follows: Helm configuration excerpt upstream: backstage: extraAppConfig: - configMapRef: my-rhdh-app-config filename: app-config.yaml Click Upgrade . steps Install Developer Hub by using Helm.
app: title: Red Hat Developer Hub baseUrl: https:// <my_developer_hub_url> backend: auth: externalAccess: - type: legacy options: subject: legacy-default-config secret: "USD{BACKEND_SECRET}" baseUrl: https:// <my_developer_hub_url> cors: origin: https:// <my_developer_hub_url> oc create namespace my-rhdh-project oc create configmap my-rhdh-app-config --from-file=app-config.yaml --namespace=my-rhdh-project oc create secret generic my-rhdh-secrets --from-file=my-rhdh-secrets.txt --namespace=my-rhdh-project apiVersion: rhdh.redhat.com/v1alpha3 kind: Backstage metadata: name: my-rhdh-custom-resource spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config extraEnvs: secrets: - name: my-rhdh-secrets extraFiles: mountPath: /opt/app-root/src replicas: 1 route: enabled: true database: enableLocalDb: true apiVersion: rhdh.redhat.com/v1alpha3 kind: Backstage metadata: name: <my-rhdh-custom-resource> spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config - name: rbac-policies dynamicPluginsConfigMapName: dynamic-plugins-rhdh extraEnvs: secrets: - name: my-rhdh-secrets - name: my-rhdh-database-secrets extraFiles: mountPath: /opt/app-root/src secrets: - name: my-rhdh-database-certificates-secrets key: postgres-crt.pem, postgres-ca.pem, postgres-key.key replicas: 1 route: enabled: true database: enableLocalDb: false spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config spec: application: appConfig: mountPath: /opt/app-root/src configMaps: - name: my-rhdh-app-config - name: rbac-policies spec: application: extraEnvs: envs: - name: HTTP_PROXY value: 'http://10.10.10.105:3128' - name: HTTPS_PROXY value: 'http://10.10.10.106:3128' - name: NO_PROXY value: 'localhost,example.org' spec: application: extraEnvs: secrets: - name: my-rhdh-secrets spec: application: extraEnvs: secrets: - name: my-rhdh-secrets - name: my-rhdh-database-secrets spec: application: extraFiles: mountPath: /opt/app-root/src secrets: - name: my-rhdh-database-certificates-secrets key: postgres-crt.pem, postgres-ca.pem, postgres-key.key spec: database: enableLocalDb: false spec: database: enableLocalDb: true oc apply --filename=my-rhdh-custom-resource.yaml --namespace=my-rhdh-project apiVersion: v1 kind: ConfigMap metadata: name: my-project-configmap data: file11.txt: | My file11 content file 12.txt: | My file12 content apiVersion: v1 kind: Secret metadata: name: my-rhdh-secrets StringData: secret11.txt: | secret-content spec: application: extraFiles: mountPath: /my/path configMaps: - name: my-project-configmap key: file12.txt mountPath: /my/my-rhdh-config-map/path secrets: - name: my-rhdh-secrets key: secret11.txt mountPath: /my/my-rhdh-secret/path upstream: backstage: extraAppConfig: - configMapRef: my-rhdh-app-config filename: app-config.yaml