1.2. 替换管理入口证书


如果您不想使用 OpenShift 默认入口证书,您可以通过更新 Red Hat Advanced Cluster Management for Kubernetes 路由来替换管理入口证书。

1.2.1. 替换管理入口证书的先决条件

将您的 management-ingress 证书和私钥准备妥当。如果需要,您可以使用 OpenSSL 生成 TLS 证书。将证书上的通用名称参数 CN 设置为 manangement-ingress。如果您要生成证书,请加入以下设置:

  • 在您的证书主题备用名称(SAN)列表中包括 Red Hat Advanced Cluster Management for Kubernetes 的路由名称作为域名。

    运行以下命令来接收路由名称:

    oc get route -n open-cluster-management
    Copy to Clipboard Toggle word wrap

    您可能会收到以下响应:

    multicloud-console.apps.grchub2.dev08.red-chesterfield.com
    Copy to Clipboard Toggle word wrap

1.2.1.1. 用于生成证书的示例配置文件

以下示例配置文件和 OpenSSL 命令提供了有关如何使用 OpenSSL 生成 TLS 证书的示例。查看以下 csr.cnf 配置文件,该文件定义了用来使用 OpenSSL 生成证书的配置设置。

[ req ]               # Main settings
default_bits = 2048       # Default key size in bits.
prompt = no               # Disables prompting for certificate values so the configuration file values are used.
default_md = sha256       # Specifies the digest algorithm.
req_extensions = req_ext  # Specifies the configuration file section that includes any extensions.
distinguished_name = dn   # Specifies the section that includes the distinguished name information.

[ dn ]               # Distinguished name settings
C = US                    # Country
ST = North Carolina             # State or province
L = Raleigh                # Locality
O = Red Hat Open Shift     # Organization
OU = Red Hat Advanced Container Management        # Organizational unit
CN = management-ingress  # Common name.

[ req_ext ]          # Extensions
subjectAltName = @alt_names # Subject alternative names

[ alt_names ]        # Subject alternative names
DNS.1 = multicloud-console.apps.grchub2.dev08.red-chesterfield.com

[ v3_ext ]          # x509v3 extensions
authorityKeyIdentifier=keyid,issuer:always  # Specifies the public key that corresponds to the private key that is used to sign a certificate.
basicConstraints=CA:FALSE                   # Indicates whether the certificate is a CA certificate during the certificate chain verification process.
#keyUsage=keyEncipherment,dataEncipherment   # Defines the purpose of the key that is contained in the certificate.
extendedKeyUsage=serverAuth                 # Defines the purposes for which the public key can be used.
subjectAltName=@alt_names                   # Identifies the subject alternative names for the identify that is bound to the public key by the CA.
Copy to Clipboard Toggle word wrap

备注:请必使用您的管理入口的正确主机名更新标记的 SAN,即 DNS.1

1.2.1.2. 用于生成证书的 OpenSSL 命令

以下 OpenSSL 命令与上述配置文件一同用来生成所需的 TLS 证书。

  1. 生成您的证书颁发机构 (CA) RSA 私钥:

    openssl genrsa -out ca.key 4096
    Copy to Clipboard Toggle word wrap
  2. 使用您的 CA 密钥生成自签名 CA 证书:

    openssl req -x509 -new -nodes -key ca.key -subj "/C=US/ST=North Carolina/L=Raleigh/O=Red Hat OpenShift" -days 400 -out ca.crt
    Copy to Clipboard Toggle word wrap
  3. 为您的证书生成 RSA 私钥:

    openssl genrsa -out ingress.key 4096
    Copy to Clipboard Toggle word wrap
  4. 使用私钥生成证书签名请求 (CSR):

    openssl req -new -key ingress.key -out ingress.csr -config csr.cnf
    Copy to Clipboard Toggle word wrap
  5. 使用您的 CA 证书和密钥及 CSR 生成签名证书:

    openssl x509 -req -in ingress.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out ingress.crt -sha256 -days 300 -extensions v3_ext -extfile csr.cnf
    Copy to Clipboard Toggle word wrap
  6. 检查证书内容:

    openssl x509  -noout -text -in ./ingress.crt
    Copy to Clipboard Toggle word wrap

1.2.2. 替换自带 (BYO) 入口证书

完成以下步骤以替换您的 BYO 入口证书:

  1. 使用您的证书和私钥创建 byo-ingress-tls secret。运行以下命令:

    oc -n open-cluster-management create secret tls byo-ingress-tls-secret --cert ./ingress.crt --key ./ingress.key
    Copy to Clipboard Toggle word wrap
  2. 使用以下命令验证是否在正确的命名空间中创建了 secret:

    oc get secret -n open-cluster-management | grep -e byo-ingress-tls-secret -e byo-ca-cert
    Copy to Clipboard Toggle word wrap
  3. 可选:运行以下命令,创建包含 CA 证书的 secret:

    oc -n open-cluster-management create secret tls byo-ca-cert --cert ./ca.crt --key ./ca.key
    Copy to Clipboard Toggle word wrap
  4. 删除 management-ingress 订阅以重新部署订阅。前面步骤中创建的 secret 会被自动使用。运行以下命令:

    oc delete subscription management-ingress-sub -n open-cluster-management
    Copy to Clipboard Toggle word wrap
  5. 验证当前证书是您的证书,并且所有控制台访问和登录功能保持不变。

1.2.3. 恢复管理入口的默认自签名证书

  1. 使用以下命令删除您自己的证书 secret:

    oc delete secret byo-ca-cert byo-ingress-tls-secret -n open-cluster-management
    Copy to Clipboard Toggle word wrap
  2. 删除 management-ingress 订阅以重新部署订阅。前面步骤中创建的 secret 会被自动使用。运行以下命令:

    oc delete subscription management-ingress-sub -n open-cluster-management
    Copy to Clipboard Toggle word wrap
  3. 验证当前证书是您的证书,并且所有控制台访问和登录功能保持不变。

如需有关由 Red Hat Advanced Cluster Management 创建和管理的证书的更多信息,请参阅证书。返回到风险和合规页面以了解更多有关保护集群的信息。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat