Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 4. Supported configurations for Red Hat Developer Hub

download PDF

This section describes the configurations that are required to access the Red Hat Developer Hub, including:

  • Custom applications configuration
  • Source control configuration for Developer Hub Catalog

4.1. Adding a custom application configuration file to Red Hat OpenShift Container Platform

To access the Red Hat Developer Hub, you must add a custom application configuration file to Red Hat OpenShift Container Platform. In OpenShift Container Platform, you can use the following content as a base template to create a ConfigMap named app-config-rhdh:

kind: ConfigMap
apiVersion: v1
metadata:
  name: app-config-rhdh
data:
  app-config-rhdh.yaml: |
    app:
      title: {product}

You can add the custom application configuration file to OpenShift Container Platform in one of the following ways:

  • The Red Hat Developer Hub Operator
  • The Red Hat Developer Hub Helm chart.

4.1.1. Adding a custom application configuration file to OpenShift Container Platform using the Helm chart

You can use the Red Hat Developer Hub Helm chart to add a custom application configuration file to your OpenShift Container Platform instance.

Prerequisites

  • You have created an Red Hat OpenShift Container Platform account.

Procedure

  1. From the OpenShift Container Platform web console, select the ConfigMaps tab.
  2. Click Create ConfigMap.
  3. From Create ConfigMap page, select the YAML view option in Configure via and make changes to the file, if needed.
  4. Click Create.
  5. Go to the Helm tab to see the list of Helm releases.
  6. Click the overflow menu on the Helm release that you want to use and select Upgrade.
  7. Use either the Form view or YAML view to edit the Helm configuration.

    • Using Form view

      1. Expand Root Schema Backstage chart schema Backstage parameters Extra app configuration files to inline into command arguments.
      2. Click the Add Extra app configuration files to inline into command arguments link.
      3. Enter the value in the following fields:

        • configMapRef: app-config-rhdh
        • filename: app-config-rhdh.yaml
      4. Click Upgrade.
    • Using YAML view

      1. Set the value of the upstream.backstage.extraAppConfig.configMapRef and upstream.backstage.extraAppConfig.filename parameters as follows:

        # ... other Red Hat Developer Hub Helm Chart configurations
        upstream:
          backstage:
            extraAppConfig:
              - configMapRef: app-config-rhdh
                filename: app-config-rhdh.yaml
        # ... other Red Hat Developer Hub Helm Chart configurations
      2. Click Upgrade.

4.1.2. Adding a custom application configuration file to OpenShift Container Platform using the Operator

A custom application configuration file is a ConfigMap object that you can use to change the configuration of your Red Hat Developer Hub instance. If you are deploying your Developer Hub instance on Red Hat OpenShift Container Platform, you can use the Red Hat Developer Hub Operator to add a custom application configuration file to your OpenShift Container Platform instance by creating the ConfigMap object and referencing it in the Developer Hub custom resource (CR).

The custom application configuration file contains a sensitive environment variable, named BACKEND_SECRET. This variable contains a mandatory backend authentication key that Developer Hub uses to reference an environment variable defined in an OpenShift Container Platform secret. You must create a secret, named 'secrets-rhdh', and reference it in the Developer Hub CR.

Note

You are responsible for protecting your Red Hat Developer Hub installation from external and unauthorized access. Manage the backend authentication key like any other secret. Meet strong password requirements, do not expose it in any configuration files, and only inject it into configuration files as an environment variable.

Prerequisites

  • You have an active Red Hat OpenShift Container Platform account.
  • Your administrator has installed the Red Hat Developer Hub Operator in OpenShift Container Platform. For more information, see Installing the Red Hat Developer Hub Operator.
  • You have created the Red Hat Developer Hub CR in OpenShift Container Platform.

Procedure

  1. From the Developer perspective in the OpenShift Container Platform web console, select the Topology view, and click the Open URL icon on the Developer Hub pod to identify your Developer Hub external URL: <RHDH_URL>.
  2. From the Developer perspective in the OpenShift Container Platform web console, select the ConfigMaps view.
  3. Click Create ConfigMap.
  4. Select the YAML view option in Configure via and use the following example as a base template to create a ConfigMap object, such as app-config-rhdh.yaml:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: app-config-rhdh
    data:
      "app-config-rhdh.yaml": |
        app:
          title: Red Hat Developer Hub
          baseUrl: <RHDH_URL> 1
        backend:
          auth:
            keys:
              - secret: "${BACKEND_SECRET}" 2
          baseUrl: <RHDH_URL> 3
          cors:
            origin: <RHDH_URL> 4
    1
    Set the external URL of your Red Hat Developer Hub instance.
    2
    Use an environment variable exposing an OpenShift Container Platform secret to define the mandatory Developer Hub backend authentication key.
    3
    Set the external URL of your Red Hat Developer Hub instance.
    4
    Set the external URL of your Red Hat Developer Hub instance.
  5. Click Create.
  6. Select the Secrets view.
  7. Click Create Key/value Secret.
  8. Create a secret named secrets-rhdh.
  9. Add a key named BACKEND_SECRET and a base64 encoded string as a value. Use a unique value for each Red Hat Developer Hub instance. For example, you can use the following command to generate a key from your terminal:

    node -p 'require("crypto").randomBytes(24).toString("base64")'
  10. Click Create.
  11. Select the Topology view.
  12. Click the overflow menu for the Red Hat Developer Hub instance that you want to use and select Edit Backstage to load the YAML view of the Red Hat Developer Hub instance.

    operator install 2
  13. In the CR, enter the name of the custom application configuration config map as the value for the spec.application.appConfig.configMaps field, and enter the name of your secret as the value for the spec.application.extraEnvs.secrets field. For example:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: example
    spec:
      application:
        appConfig:
          mountPath: /opt/app-root/src
          configMaps:
             - name: app-config-rhdh
        extraEnvs:
          secrets:
             - name: secrets-rhdh
        extraFiles:
          mountPath: /opt/app-root/src
        replicas: 1
        route:
          enabled: true
      database:
        enableLocalDb: true
  14. Click Save.
  15. Navigate back to the Topology view and wait for the Red Hat Developer Hub pod to start.
  16. Click the Open URL icon to use the Red Hat Developer Hub platform with the configuration changes.

Additional resources

4.2. Adding source control for Catalog in Red Hat Developer Hub

To populate the Catalog in Red Hat Developer Hub, you need to add software templates, and to add the templates, you must enable a source control such as GitHub, GitLab, or BitBucket.

Prerequisites

  • You have a GitHub account.
  • You have an account on the Red Hat OpenShift cluster.
  • You have installed the Developer Hub, otherwise the GitHub login fails. For more information about installation, see Chapter 3, Installing Red Hat Developer Hub.

4.2.1. Configuring GitHub authentication

The configuration of GitHub authentication is required to enable the GitHub OAuth login in Developer Hub.

Procedure

  1. In the Red Hat OpenShift cluster, navigate to the main page of the GitHub organization where you want to create the OAuth application.
  2. Click Settings Developer Settings OAuth Apps Register an application
  3. Enter the application name as Developer Hub.
  4. Add the following URL as the Homepage URL:

    https://developer-hub-<NAMESPACE_NAME>.<OPENSHIFT_ROUTE_HOST>/

  5. Add the following URL as Authorization callback URL:

    https://developer-hub-<NAMESPACE_NAME>.<OPENSHIFT_ROUTE_HOST>/api/auth/github/handler/frame

  6. Clear the Enable Device Flow checkbox.
  7. Click Register application to create your OAuth application.
  8. After creating the application, click Generate a new client secret and copy the generated client secret.
  9. In OpenShift, click ConfigMaps.
  10. Generate a key/value secret named 'github-secrets' using the provided environment variables as keys, and input the values you generated for your GitHub OAuth application:

    1. In Red Hat OpenShift, go to the Secrets tab and click Create.
    2. Select Key/value secret.
    3. Enter Secret name as github-secrets.
    4. Add environment variables as Key and Value and click Create.

      Table 4.1. Environment variables
      KeyValue

      GITHUB_OAUTH_CLIENT_ID

      Client ID from OAuth application

      GITHUB_OAUTH_CLIENT_SECRET

      Client Secret from OAuth application

  11. Modify your app-config-rhdh ConfigMap to include the GitHub authentication configuration as follows:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: app-config-rhdh
    data:
      app-config-rhdh.yaml: |
        app:
          title: Red Hat Developer Hub
        auth:
          # see https://backstage.io/docs/auth/ to learn about auth providers
          environment: development
          providers:
            github:
              development:
                clientId: ${GITHUB_OAUTH_CLIENT_ID}
                clientSecret: ${GITHUB_OAUTH_CLIENT_SECRET}
  12. Click Save.
  13. Navigate to the Helm tab and select Upgrade.
  14. Use one of the following views to edit the Helm configuration:

    • Using Form view

      1. Expand Root Schema Backstage Chart Schema Backstage Parameters Backstage container environment variables from existing Secrets.
      2. Click the Add Backstage container environment variables from existing Secrets link.
      3. Enter github-secrets as the value.
      4. Click Upgrade.
    • Using YAML view

      1. Set the value of the upstream.backstage.extraEnvVarsSecrets parameter to github-secrets as shown in the following example:

        # other Red Hat Developer Hub Helm Chart configurations
        upstream:
          backstage:
            # other Red Hat Developer Hub Helm Chart configurations
            extraEnvVarsSecrets:
              - github-secrets
            # other Red Hat Developer Hub Helm Chart configurations
      2. Click Upgrade.

4.2.2. Configuring GitHub integration

The configuration of GitHub is required to enable the GitHub plugins in Developer Hub.

Procedure

  1. In the Red Hat OpenShift cluster, navigate to the main page of the GitHub organization where you want to create the OAuth application.
  2. Click Settings Developer Settings GitHub Apps New GitHub App.
  3. Enter the application name as Developer Hub.
  4. Add the following URL as the Homepage URL:

    https://developer-hub-<NAMESPACE_NAME>.<OPENSHIFT_ROUTE_HOST>/

  5. Add the following URL as Authorization callback URL:

    https://developer-hub-<NAMESPACE_NAME>.<OPENSHIFT_ROUTE_HOST>/api/auth/github/handler/frame

  6. Deselect Webhook URL Active.
  7. Under the Where can this GitHub App be installed? section, ensure that Only on this account is selected.
  8. Click Register application.
  9. After creating the application, click Generate a new client secret and copy the generated client secret.
  10. Click Generate a private key at the bottom of the page and download the generated file.
  11. In OpenShift, click ConfigMaps.
  12. Generate a key/value secret named 'github-secrets' using the provided environment variables as keys, and input the values you generated for your GitHub OAuth application:

    1. In Red Hat OpenShift, go to the Secrets tab and click Create.
    2. Select Key/value secret.
    3. Enter Secret name as github-secrets.
    4. Add environment variables as Key and Value and click Create.
    Table 4.2. Environment variables
    KeyValue

    GITHUB_APP_APP_ID

    App ID from GitHub application

    GITHUB_APP_CLIENT_ID

    Client ID from GitHub application

    GITHUB_APP_CLIENT_SECRET

    Client Secret from GitHub application

    GITHUB_APP_WEBHOOK_URL

    Enter "none"

    GITHUB_APP_WEBHOOK_SECRET

    Enter "none"

    GITHUB_APP_PRIVATE_KEY

    Upload the private key that was downloaded

  13. Modify your app-config-rhdh ConfigMap to include the GitHub integration configuration as follows:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: app-config-rhdh
    data:
      app-config-rhdh.yaml: |
        app:
          title: Red Hat Developer Hub
        integrations:
          github:
            - host: github.com
              apps:
                - appId: ${GITHUB_APP_APP_ID}
                  clientId: ${GITHUB_APP_CLIENT_ID}
                  clientSecret: ${GITHUB_APP_CLIENT_SECRET}
                  webhookUrl: ${GITHUB_APP_WEBHOOK_URL}
                  webhookSecret: ${GITHUB_APP_WEBHOOK_SECRET}
                  privateKey: |
                    ${GITHUB_APP_PRIVATE_KEY}
  14. Click Toplogy developer hub Actions (drop-down) Restart rollout.

4.2.3. Enabling GitHub discovery in Red Hat Developer Hub

You can enable GitHub discoverability for your components in Developer Hub, such as any repositories that contain catalog-info.yaml file.

Prerequisites

Procedure

  1. In the Developer perspective of the OpenShift Container Platform web console, go to the Helm tab.
  2. Click the overflow menu on a Helm release and select Upgrade.
  3. Use one of the following views to edit the Helm configuration:

    • Using Form view

      1. Expand Root Schema global Dynamic plugins configuration List of dynamic plugins that should be installed in the backstage application.
      2. Click the Add List of dynamic plugins that should be installed in the backstage application link.
      3. In the Package specification of the dynamic plugin to install. It should be usable by the npm pack command. field, add the following value:

        ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-dynamic

        enable gh discovery
      4. Click Upgrade.
    • Using YAML view

      1. Set the value of the global.dynamic.plugins.package parameter to ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-dynamic as shown in the following example:

        global:
          dynamic:
            # other Red Hat Developer Hub Helm Chart configurations
            plugins:
              - disabled: false
                package: >-
                  ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-dynamic
            # other Red Hat Developer Hub Helm Chart configurations
      2. Click Upgrade.
  4. Add the following code in the ConfigMap:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: app-config-rhdh
    data:
      app-config-rhdh.yaml: |
        ...
          catalog:
            providers:
              github:
                providerId:
                  organization: '${GITHUB_ORG}'
                  schedule:
                    frequency:
                      minutes: 30
                    initialDelay:
                      seconds: 15
                    timeout:
                      minutes: 3
        ...

    In the previous code, replace ${GITHUB_ORG} with the GitHub organization from where you want to discover the components. Also, if there is a single provider, then following code can be added in the ConfigMap:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: app-config-rhdh
    data:
      app-config-rhdh.yaml: |
        ...
        catalog:
          providers:
            github:
              organization: ${GITHUB_ORG}
              schedule:
                frequency: { minutes: 1 }
                timeout: { minutes: 1 }
                initialDelay: { seconds: 100 }
        ...

    The providerId in the previous code is required to identify the provider when there is a list of them.

  5. Click Save.

4.2.4. Enabling GitHub organization member discovery in Red Hat Developer Hub

You can also enable GitHub discoverability for the members of your GitHub organization.

Prerequisites

Procedure

  1. In the Developer perspective of the OpenShift Container Platform web console, go to the Helm tab.
  2. Click the overflow menu on a Helm release and select Upgrade.
  3. Use one of the following views to edit the Helm configuration:

    • Using Form view

      1. Expand Root Schema global Dynamic plugins configuration List of dynamic plugins that should be installed in the backstage application.
      2. Click the Add List of dynamic plugins that should be installed in the backstage application link.
      3. In the Package specification of the dynamic plugin to install. It should be usable by the npm pack command. field, add the following value:

        ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic

        enable gh member discovery
      4. Click Upgrade.
    • Using YAML view

      1. Set the value of the global.dynamic.plugins.package parameter to ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic as shown in the following example:

        global:
          dynamic:
            # other Red Hat Developer Hub Helm Chart configurations
            plugins:
              - disabled: false
                package: >-
                  ./dynamic-plugins/dist/backstage-plugin-catalog-backend-module-github-org-dynamic
            # other Red Hat Developer Hub Helm Chart configurations
      2. Click Upgrade.
  4. Add the following code in the ConfigMap:

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: app-config-rhdh
    data:
      app-config-rhdh.yaml: |
        ...
        catalog:
          providers:
            githubOrg:
              id: production
              githubUrl: "${GITHUB_URL}"
              orgs: [ "${GITHUB_ORG}" ]
        ...

    where:

    ${GITHUB_URL}
    Denotes a variable that you must replace with the GitHub URL.
    ${GITHUB_ORG}
    Denotes a variable that you must replace with the GitHub organization you want to ingest users from.
  5. Click Save.
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.