第 1 章 Adding custom certificates
Learn how to use a custom TLS certificate with Red Hat Advanced Cluster Security for Kubernetes. After you set up a certificate, users and API clients do not have to bypass the certificate security warnings when connecting to Central.
1.1. Adding a custom security certificate 复制链接链接已复制到粘贴板!
You can apply a security certificate during the installation or on an existing Red Hat Advanced Cluster Security for Kubernetes deployment.
1.1.1. Prerequisites for adding custom certificates 复制链接链接已复制到粘贴板!
Prerequisites
- You must already have PEM-encoded private key and certificate files.
The certificate file should begin and end with human-readable blocks. For example:
-----BEGIN CERTIFICATE----- MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0G ... l4wOuDwKQa+upc8GftXE2C//4mKANBC6It01gUaTIpo= -----END CERTIFICATE-----The certificate file can contain either a single (leaf) certificate, or a certificate chain.
警告- If the certificate is not directly signed by a trusted root, you must provide the full certificate chain, including any intermediate certificates.
- All certificates in the chain must be in order so that the leaf certificate is the first and the root certificate is the last in the chain.
- If you are using a custom certificate that is not globally trusted, you must also configure the Sensor to trust your custom certificate.
Procedure
If you are installing Red Hat Advanced Cluster Security for Kubernetes using the Operator:
Create a
central-default-tls-certsecret that contains the appropriate TLS certificates in the namespace where the Central service will be installed by entering the following command:oc -n <namespace> create secret tls central-default-tls-cert --cert <tls-cert.pem> --key <tls-key.pem>
If you are installing Red Hat Advanced Cluster Security for Kubernetes using Helm:
Add your custom certificate and its key in the
values-private.yamlfile:central: # Configure a default TLS certificate (public cert + private key) for central defaultTLS: cert: | -----BEGIN CERTIFICATE----- EXAMPLE!MIIMIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0G ... -----END CERTIFICATE----- key: | -----BEGIN EC PRIVATE KEY----- EXAMPLE!MHcl4wOuDwKQa+upc8GftXE2C//4mKANBC6It01gUaTIpo= ... -----END EC PRIVATE KEY-----Provide the configuration file during the installation:
$ helm install -n stackrox --create-namespace stackrox-central-services rhacs/central-services -f values-private.yaml
If you are installing Red Hat Advanced Cluster Security for Kubernetes using the
roxctlCLI, provide the certificate and key files when you run the installer:For the non-interactive installer, use the
--default-tls-certand--default-tls-keyoptions:$ roxctl central generate --default-tls-cert "cert.pem" --default-tls-key "key.pem"For the interactive installer, provide the certificate and key files when you enter answers for the prompts:
... Enter PEM cert bundle file (optional): <cert.pem> Enter PEM private key file (optional): <key.pem> Enter administrator password (default: autogenerated): Enter orchestrator (k8s, openshift): openshift ...
Procedure
If you have installed Red Hat Advanced Cluster Security for Kubernetes using the Operator:
Create a
central-default-tls-certsecret that contains the appropriate TLS certificates in the namespace where the Central service is installed by entering the following command:oc -n <namespace> create secret tls central-default-tls-cert --cert <tls-cert.pem> --key <tls-key.pem>
If you have installed Red Hat Advanced Cluster Security for Kubernetes using Helm:
Add your custom certificate and its key in the
values-private.yamlfile:central: # Configure a default TLS certificate (public cert + private key) for central defaultTLS: cert: | -----BEGIN CERTIFICATE----- EXAMPLE!MIIMIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0G ... -----END CERTIFICATE----- key: | -----BEGIN EC PRIVATE KEY----- EXAMPLE!MHcl4wOuDwKQa+upc8GftXE2C//4mKANBC6It01gUaTIpo= ... -----END EC PRIVATE KEY-----Use the
helm upgradecommand and provide the updated configuration file:$ helm upgrade -n stackrox --create-namespace stackrox-central-services \ rhacs/central-services --reuse-values \ -f values-private.yamlwhere:
--reuse-values-
Specifies that the upgrade will reuse existing values. You must use this parameter because the
values-private.yamlfile does not contain all of the required configuration values.
If you have installed Red Hat Advanced Cluster Security for Kubernetes using the
roxctlCLI:Create and apply a TLS secret from the PEM-encoded key and certificate files:
$ oc -n stackrox create secret tls central-default-tls-cert \ --cert <server_cert.pem> \ --key <server_key.pem> \ --dry-run -o yaml | oc apply -f -After you run this command, Central automatically applies the new key and certificate without requiring the pod to be restarted. It might take up to a minute to propagate the changes.
If you use a custom certificate for Central, you can update the certificate by performing the following procedure.
Procedure
Delete the existing custom certificate’s secret:
$ oc delete secret central-default-tls-certCreate a new secret:
$ oc -n stackrox create secret tls central-default-tls-cert \ --cert <server_cert.pem> \ --key <server_key.pem> \ --dry-run -o yaml | oc apply -f -- Restart the Central container.
1.1.4.1. Restarting the Central container 复制链接链接已复制到粘贴板!
You can restart the Central container by deleting the Central pod.
If you use Kubernetes, enter kubectl instead of oc.
Procedure
To delete the Central pod, run the following command:
$ oc -n stackrox delete pod -lapp=central