第 2 章 可能会造成问题的更改


本节列出了 Red Hat Developer Hub 1.7 中的破坏更改。

在以前的版本中,Operator 可以自动检测并挂载名为 dynamic-plugins-npmrc 的可选 Secret,以配置自定义的 npm registry。

在这个版本中,您可以进行以下任一临时解决方案:

  • 修改 Operator 默认配置中的 default-config/secret-files.yaml 键(rhdh-default-config ConfigMap 在 rhdh-operator 命名空间中),使其包含自定义 .npmrc 内容。
  • 在 Backstage 自定义资源(CR)中,完成以下步骤:

    1. 创建包含自定义 .npmrc 内容的新 Secret。
    2. 将 Secret 挂载到 install-dynamic-plugins initContainer。
    3. 设置 NPM_CONFIG_USERCONFIG 环境变量,以引用 spec.deployment.patch 部分中挂载的 .npmrc 文件。

      包含 .npmrc 文件的 Secret 示例

      apiVersion: v1
      kind: Secret
      metadata:
        name: dynamic-plugins-npmrc
      type: Opaque
      stringData:
        .npmrc: |
          @my-company:registry=https://my-company.example.com
          //<registry-url>:_authToken=<auth-token>
      ---
      apiVersion: rhdh.redhat.com/v1alpha3
      kind: Backstage
      metadata:
        name: my-rhdh
      spec:
        application:
          dynamicPluginsConfigMapName: my-dynamic-plugins-rhdh
        # --- BEGIN WORKAROUND: Ensure you have the volumes, volume mounts and NPM_CONFIG_USERCONFIG env var listed below
        deployment:
          patch:
            spec:
              template:
                spec:
                  initContainers:
                    - name: install-dynamic-plugins
                      volumeMounts:
                        - mountPath: /opt/app-root/src/.my-dynamic-plugins-npmrc.dynamic-plugins
                          name: my-dynamic-plugins-npmrc
                      env:
                        - name:
                        - name: NPM_CONFIG_USERCONFIG
                          # path before .npmrc should be the same as in the mountPath above
                          # file name .npmrc should be the same as key in the dynamic-plugins-npmrc secret above
                          value: /opt/app-root/src/.my-dynamic-plugins-npmrc.dynamic-plugins/.npmrc
                  volumes:
                    - name: my-dynamic-plugins-npmrc
                      secret:
                        secretName: dynamic-plugins-npmrc
        # --- END WORKAROUND

其他资源

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部