5.6. 配置证书轮转


配置证书轮转参数以替换现有证书。

5.6.1. 配置证书轮转

您可以在 web 控制台中的 OpenShift Virtualization 安装过程中,或者在安装 HyperConverged 自定义资源(CR)后完成此操作。

先决条件

  • 已安装 OpenShift CLI(oc)。

流程

  1. 运行以下命令打开 HyperConverged CR:

    $ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
    Copy to Clipboard Toggle word wrap
  2. 按照以下示例所示,编辑 spec.certConfig 字段。要避免系统过载,请确保所有值都大于或等于 10 分钟。将所有值显示为符合 golang ParseDuration 格式的字符串

    apiVersion: hco.kubevirt.io/v1beta1
    kind: HyperConverged
    metadata:
      name: kubevirt-hyperconverged
      namespace: openshift-cnv
    spec:
      certConfig:
        ca:
          duration: 48h0m0s
          renewBefore: 24h0m0s
        server:
          duration: 24h0m0s
          renewBefore: 12h0m0s
    Copy to Clipboard Toggle word wrap
    • ca.renewBefore 的值必须小于或等于 ca.duration 的值。
    • server.duration 的值必须小于或等于 ca.duration 的值。
    • server.renewBefore 的值必须小于或等于 server.duration 的值。
  3. 运行以下命令,将更新应用到 HyperConverged CR:

    $ oc apply -f <filename>.yaml
    Copy to Clipboard Toggle word wrap

    例如:

    $ oc apply -f kubevirt-hyperconverged.yaml
    Copy to Clipboard Toggle word wrap

5.6.2. 证书轮转参数故障排除

删除 HyperConverged 自定义资源(CR)中的一个或多个 certConfig 值会导致 certConfig 值恢复到默认值。

如果默认值与以下条件之一冲突,您会收到错误消息:

  • ca.renewBefore 的值必须小于或等于 ca.duration 的值。
  • server.duration 的值必须小于或等于 ca.duration 的值。
  • server.renewBefore 的值必须小于或等于 server.duration 的值。

例如,如果您删除了 server.duration 值,则默认值 24h0m0s 大于 ca.duration 的值,这与指定条件冲突:

apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
  name: kubevirt-hyperconverged
  namespace: openshift-cnv
spec:
  # ...
  certConfig:
    ca:
      duration: 4h0m0s
      renewBefore: 1h0m0s
    server:
      duration: 4h0m0s
      renewBefore: 4h0m0s
# ...
Copy to Clipboard Toggle word wrap

这会生成以下出错信息:

error: hyperconvergeds.hco.kubevirt.io "kubevirt-hyperconverged" could not be patched: admission webhook "validate-hco.kubevirt.io" denied the request: spec.certConfig: ca.duration is smaller than server.duration
Copy to Clipboard Toggle word wrap

错误消息仅提及第一个冲突。在继续操作前,请查看所有 certConfig 值。

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2026 Red Hat
返回顶部