Chapter 6. Configuring a custom PKI
To ensure secure communication between internal components, your OpenShift Container Platform cluster uses a shared set of trusted Certificate Authorities (CAs). If your organization uses its own private certificates (a custom PKI), you must add your CA to the cluster so that all components trust it.
You can add your custom CA certificates to the cluster-wide truststore in one of two ways:
-
During cluster installation, by adding your CA certificate to the
install-config.yaml
file. -
On a running cluster, by creating a
ConfigMap
object that contains your CA certificate and referencing it in the clusterProxy
object.
The cluster Proxy object is the mechanism for managing the cluster-wide truststore. This guide focuses only on the task of adding a CA. If you also need to configure an egress proxy, refer to the "Configuring the cluster-wide proxy" chapter for detailed instructions.
6.1. Adding a custom CA during cluster installation Copy linkLink copied to clipboard!
You can add a custom CA to the cluster-wide truststore during installation by providing the certificate in your install-config.yaml
file.
This procedure uses the additionalTrustBundle
parameter. If you are also configuring an egress proxy, you can add this parameter to your install-config.yaml
file along with your proxy configuration. For more information on the available proxy settings, see the "Configuring the cluster-wide proxy" chapter.
Prerequisites
-
You have access to the
install-config.yaml
file for your cluster installation. - You have your custom CA certificate avalable in PEM-encoded format.
Procedure
-
Open your
install-config.yaml
file. Add the
additionalTrustBundle
parameter with your PEM-encoded CA certificate:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
additionalTrustBundle
parameter contains the custom CA certificate that you want the cluster to trust. The installation program uses the certificate to generate auser-ca-bundle
ConfigMap
object in theopenshift-config
namespace.
-
Save the
install-config.yaml
file and continue with your cluster installation.
During installation, the Cluster Network Operator (CNO) merges the certificate you provided with the system’s default trust bundle. This process makes your custom CA trusted across the entire cluster.
6.2. Adding a custom CA to a running cluster Copy linkLink copied to clipboard!
For a running cluster, you can add a custom CA by creating a ConfigMap
object that contains your certificate and then referencing that ConfigMap
object in the cluster Proxy
object.
When you modify the cluster Proxy
object, the Machine Config Operator (MCO) initiates a rolling reboot of all nodes to apply the change. This is expected behavior and does not require manual intervention.
This procedure uses the trustedCA
field in the Proxy
object. If you also need to configure or modify egress proxy settings at the same time, see the "Configuring the cluster-wide proxy" chapter for detailed instructions.
Prerequisites
- You have cluster-admin privileges.
-
You have the OpenShift CLI (
oc
) installed. - You have your custom CA certificate available in PEM-encoded format.
Procedure
The procedure involves two stages: creating a ConfigMap
object with your certificate and then updating the cluster to trust it.
Create a
ConfigMap
object with your CA certificate.-
Create a YAML file named
custom-ca.yaml
to define theConfigMap
object. Add the following content to the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Create a YAML file named
Apply the manifest to create the
ConfigMap
object in the cluster:oc apply -f custom-ca.yaml
$ oc apply -f custom-ca.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reference the
ConfigMap
object in the clusterProxy
object.Run the following
oc patch
command to update the clusterProxy
object to reference theConfigMap
object you just created.oc patch proxy/cluster --type=merge --patch='{"spec":{"trustedCA":{"name":"custom-ca-bundle"}}}'
$ oc patch proxy/cluster --type=merge --patch='{"spec":{"trustedCA":{"name":"custom-ca-bundle"}}}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
After you run this command, the Machine Config Operator (MCO) detects the change and begins distributing the new trusted CA to all nodes in the cluster.
6.3. Verifying the custom CA configuration Copy linkLink copied to clipboard!
After you add your custom CA certificate, you can verify that it has been successfully added to the cluster-wide trust bundle.
Prerequisites
-
You have permissions to view
ConfigMap
objects in the openshift-config namespace. -
You have the OpenShift CLI (
oc
) installed.
Procedure
Run the following command to view the contents of the cluster-wide CA trust bundle:
oc get configmap trusted-ca-bundle -n openshift-config -o yaml
$ oc get configmap trusted-ca-bundle -n openshift-config -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
In the YAML output, inspect the
data.ca-bundle.crt
field. This field contains all the trusted certificates for the cluster. Verify that the PEM-encoded certificate you added is included in the list of certificates. The output will resemble the following structure:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If your certificate is present in the output, the cluster now trusts your custom PKI.
6.4. Certificate injection using Operators Copy linkLink copied to clipboard!
Once your custom CA certificate is added to the cluster via ConfigMap, the Cluster Network Operator merges the user-provided and system CA certificates into a single bundle and injects the merged bundle into the Operator requesting the trust bundle injection.
After adding a config.openshift.io/inject-trusted-cabundle="true"
label to the config map, existing data in it is deleted. The Cluster Network Operator takes ownership of a config map and only accepts ca-bundle
as data. You must use a separate config map to store service-ca.crt
by using the service.beta.openshift.io/inject-cabundle=true
annotation or a similar configuration. Adding a config.openshift.io/inject-trusted-cabundle="true"
label and service.beta.openshift.io/inject-cabundle=true
annotation on the same config map can cause issues.
Operators request this injection by creating an empty ConfigMap with the following label:
config.openshift.io/inject-trusted-cabundle="true"
config.openshift.io/inject-trusted-cabundle="true"
An example of the empty ConfigMap:
- 1
- Specifies the empty ConfigMap name.
The Operator mounts this ConfigMap into the container’s local trust store.
Adding a trusted CA certificate is only needed if the certificate is not included in the Red Hat Enterprise Linux CoreOS (RHCOS) trust bundle.
Certificate injection is not limited to Operators. The Cluster Network Operator injects certificates across any namespace when an empty ConfigMap is created with the config.openshift.io/inject-trusted-cabundle=true
label.
The ConfigMap can reside in any namespace, but the ConfigMap must be mounted as a volume to each container within a pod that requires a custom CA. For example: