This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.2.2. Adding API server certificates
The default API server certificate is issued by an internal OpenShift Container Platform cluster CA. Clients outside of the cluster will not be able to verify the API server’s certificate by default. This certificate can be replaced by one that is issued by a CA that clients trust.
2.2.1. Add an API server named certificate 复制链接链接已复制到粘贴板!
The default API server certificate is issued by an internal OpenShift Container Platform cluster CA. You can add one or more alternative certificates that the API server will return based on the fully qualified domain name (FQDN) requested by the client, for example when a reverse proxy or load balancer is used.
Prerequisites
- You must have a certificate for the FQDN and its corresponding private key. Each should be in a separate PEM format file.
- The private key must be unencrypted. If your key is encrypted, decrypt it before importing it into OpenShift Container Platform.
-
The certificate must include the
subjectAltName
extension showing the FQDN. - The certificate file can contain one or more certificates in a chain. The certificate for the API server FQDN must be the first certificate in the file. It can then be followed with any intermediate certificates, and the file should end with the root CA certificate.
Do not provide a named certificate for the internal load balancer (host name api-int.<cluster_name>.<base_domain>
). Doing so will leave your cluster in a degraded state.
Procedure
Create a secret that contains the certificate chain and private key in the
openshift-config
namespace.oc create secret tls <secret> \ --cert=</path/to/cert.crt> \ --key=</path/to/cert.key> \ -n openshift-config
$ oc create secret tls <secret> \
1 --cert=</path/to/cert.crt> \
2 --key=</path/to/cert.key> \
3 -n openshift-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the API server to reference the created secret.
oc patch apiserver cluster \ --type=merge -p \ '{"spec":{"servingCerts": {"namedCertificates":
$ oc patch apiserver cluster \ --type=merge -p \ '{"spec":{"servingCerts": {"namedCertificates": [{"names": ["<FQDN>"],
1 "servingCertificate": {"name": "<secret>"}}]}}}'
2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow Examine the
apiserver/cluster
object and confirm the secret is now referenced.oc get apiserver cluster -o yaml
$ oc get apiserver cluster -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow