此文档 下面两处生成证书命令警告缺少 -hostname= (此证书缺少“主机名”字段),这个问题是否需要忽略? 如不能忽略两处 -hostname= 值应该是什么?
3.2.3 生成apiserver聚合证书
cfssl gencert \
-ca=/etc/kubernetes/pki/front-proxy-ca.pem \
-ca-key=/etc/kubernetes/pki/front-proxy-ca-key.pem \
-config=ca-config.json \
-profile=kubernetes front-proxy-client-csr.json | cfssljson -bare /etc/kubernetes/pki/front-proxy-client
# 这个命令使用cfssl工具生成一个用于Kubernetes的front-proxy-client证书。
#
# 主要参数解释如下:
# - `-ca=/etc/kubernetes/pki/front-proxy-ca.pem`: 指定用于签署证书的根证书文件路径。
# - `-ca-key=/etc/kubernetes/pki/front-proxy-ca-key.pem`: 指定用于签署证书的根证书的私钥文件路径。
# - `-config=ca-config.json`: 指定用于配置证书签署的配置文件路径。该配置文件描述了证书生成的一些规则,如加密算法和有效期等。
# - `-profile=kubernetes`: 指定生成证书时使用的配置文件中定义的profile,其中包含了一些默认的参数。
# - `front-proxy-client-csr.json`: 指定用于生成证书的CSR文件路径,该文件包含了证书请求的相关信息。
# - `| cfssljson -bare /etc/kubernetes/pki/front-proxy-client`: 通过管道将生成的证书输出到cfssljson工具进行解析,并通过`-bare`参数将证书和私钥分别保存到指定路径。
#
# 这个命令的作用是根据提供的CSR文件和配置信息,使用指定的根证书和私钥生成一个前端代理客户端的证书,并将证书和私钥分别保存到`/etc/kubernetes/pki/front-proxy-client.pem`和`/etc/kubernetes/pki/front-proxy-client-key.pem`文件中。
[root@node81 json]# cfssl gencert
-ca=/etc/kubernetes/pki/front-proxy-ca.pem
-ca-key=/etc/kubernetes/pki/front-proxy-ca-key.pem
-config=ca-config.json
-profile=kubernetes front-proxy-client-csr.json | cfssljson -bare /etc/kubernetes/pki/front-proxy-client
2026/04/06 22:50:45 [INFO] generate received request
2026/04/06 22:50:45 [INFO] received CSR
2026/04/06 22:50:45 [INFO] generating key: rsa-2048
2026/04/06 22:50:46 [INFO] encoded CSR
2026/04/06 22:50:46 [INFO] signed certificate with serial number 169152847885327258476148093162490864342007837496
2026/04/06 22:50:46 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2.3 ("Information Requirements").
3.2.4 生成controller-manage的证书
cfssl gencert \
-ca=/etc/kubernetes/pki/front-proxy-ca.pem \
-ca-key=/etc/kubernetes/pki/front-proxy-ca-key.pem \
-config=ca-config.json \
-profile=kubernetes front-proxy-client-csr.json | cfssljson -bare /etc/kubernetes/pki/front-proxy-client
# 这是一个命令行操作,使用cfssl工具生成证书。
#
# 1. `cfssl gencert` 是cfssl工具的命令,用于生成证书。
# 2. `-ca` 指定根证书的路径和文件名,这里是`/etc/kubernetes/pki/ca.pem`。
# 3. `-ca-key` 指定根证书的私钥的路径和文件名,这里是`/etc/kubernetes/pki/ca-key.pem`。
# 4. `-config` 指定配置文件的路径和文件名,这里是`ca-config.json`。
# 5. `-profile` 指定证书使用的配置文件中的配置模板,这里是`kubernetes`。
# 6. `manager-csr.json` 是证书签发请求的配置文件,用于生成证书签发请求。
# 7. `|` 管道操作符,将前一条命令的输出作为后一条命令的输入。
# 8. `cfssljson -bare` 是 cfssl 工具的命令,作用是将证书签发请求的输出转换为PKCS#1、PKCS#8和x509 PEM文件。
# 9. `/etc/kubernetes/pki/controller-manager` 是转换后的 PEM 文件的存储位置和文件名。
[root@node81 json]# cfssl gencert
-ca=/etc/kubernetes/pki/ca.pem
-ca-key=/etc/kubernetes/pki/ca-key.pem
-config=ca-config.json
-profile=kubernetes
manager-csr.json | cfssljson -bare /etc/kubernetes/pki/controller-manager
2026/04/06 22:56:48 [INFO] generate received request
2026/04/06 22:56:48 [INFO] received CSR
2026/04/06 22:56:48 [INFO] generating key: rsa-2048
2026/04/06 22:56:48 [INFO] encoded CSR
2026/04/06 22:56:48 [INFO] signed certificate with serial number 88345327531138995789040290692667474295864197074
2026/04/06 22:56:48 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2.3 ("Information Requirements").
此文档 下面两处生成证书命令警告缺少
-hostname=(此证书缺少“主机名”字段),这个问题是否需要忽略? 如不能忽略两处-hostname=值应该是什么?3.2.3 生成apiserver聚合证书
[root@node81 json]# cfssl gencert
-ca=/etc/kubernetes/pki/front-proxy-ca.pem
-ca-key=/etc/kubernetes/pki/front-proxy-ca-key.pem
-config=ca-config.json
-profile=kubernetes front-proxy-client-csr.json | cfssljson -bare /etc/kubernetes/pki/front-proxy-client
2026/04/06 22:50:45 [INFO] generate received request
2026/04/06 22:50:45 [INFO] received CSR
2026/04/06 22:50:45 [INFO] generating key: rsa-2048
2026/04/06 22:50:46 [INFO] encoded CSR
2026/04/06 22:50:46 [INFO] signed certificate with serial number 169152847885327258476148093162490864342007837496
2026/04/06 22:50:46 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2.3 ("Information Requirements").
3.2.4 生成controller-manage的证书
[root@node81 json]# cfssl gencert
-ca=/etc/kubernetes/pki/ca.pem
-ca-key=/etc/kubernetes/pki/ca-key.pem
-config=ca-config.json
-profile=kubernetes
manager-csr.json | cfssljson -bare /etc/kubernetes/pki/controller-manager
2026/04/06 22:56:48 [INFO] generate received request
2026/04/06 22:56:48 [INFO] received CSR
2026/04/06 22:56:48 [INFO] generating key: rsa-2048
2026/04/06 22:56:48 [INFO] encoded CSR
2026/04/06 22:56:48 [INFO] signed certificate with serial number 88345327531138995789040290692667474295864197074
2026/04/06 22:56:48 [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1.6, from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2.3 ("Information Requirements").