-
Notifications
You must be signed in to change notification settings - Fork 1.8k
OCPBUGS#8882: configure an addditionl clientca for the openshiftapi s… #89427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Module included in the following assemblies: | ||
// | ||
// * security/certificates/api-server.adoc | ||
|
||
:_content-type: PROCEDURE | ||
[id="configure-an-additional-clientCA-for-the-OpenShift-API-server_{context}"] | ||
|
||
= Replacing the installer-generated clientCA with a new clientCA for the OpenShift API server | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
||
|
||
An existing kubeconfig is replaced by adding a new kubeconfig and configuring the existing kubeconfig to be invalid. The existing kubeconfig remains in place, but is not used due to its invalidating configuration. The existing, now invalid, kubeconfig cannot be removed. | ||
|
||
Optionally, you can replace the installer-generated kubeconfig. This process is also referred to as configuring the installer-generated kubceconfig to be invalid. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
||
You might do this if any of the following conditions exist: | ||
|
||
* You do not trust who installed the cluster. | ||
* The kubeconfig is leaked. | ||
+ | ||
[NOTE] | ||
==== | ||
A leak can occur if a third party installs the cluster. That third party has the kubeconfig and can potentially access the cluster. To increase security, replace the kubeconfig. | ||
==== | ||
+ | ||
* Other security-related needs exist, such as the periodic rotation of the kubeconfig. | ||
|
||
.Procedure | ||
|
||
To replace the installer-generated kubeconfig, remove the installer-generated clientCA from the API server: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
||
|
||
. Use the following command to import an additional CA certificate in a configmap in the `openshift-config`` namespace. The CA file must be in PEM format. | ||
+ | ||
[source,terminal] | ||
---- | ||
oc create configmap client-ca-custom -n openshift-config --from-file=ca-bundle.crt=ca.crt | ||
---- | ||
+ | ||
. Use the following command to patch the APIServer instance: | ||
+ | ||
[source, terminal] | ||
---- | ||
oc patch apiserver cluster --type=merge -p '{"spec": {"clientCA": {"name": "client-ca-custom"}}}' | ||
---- | ||
|
||
. Test the new clientCA certificate with a certificate signed from the new clientCA. | ||
. If the test is successful, you can remove the installer-generated clientCA. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Module included in the following assemblies: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] OpenShiftAsciiDoc.ModuleContainsContentType: Module is missing the '_mod-docs-content-type' variable. |
||
// | ||
// * security/certificates/api-server.adoc | ||
|
||
:_content-type: PROCEDURE | ||
[id="replace-the-certificate-authority_{context}"] | ||
|
||
= Invalidating the installer-generated kubeconfig before replacing it with a newly generated CA certificate | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
||
|
||
The installer-generated kubeconfig cannot be removed, but it can be invalidated and replaced with a newly generated CA certificate. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'The installer'. For more information, see RedHat.TermsErrors. |
||
|
||
You can replace the installer-generated kubeconfig. You might do this if any of the following conditions exist: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
||
|
||
* You do not trust who installed the cluster. | ||
* The kubeconfig is leaked. | ||
* Other security-related needs exist, such as the periodic rotation of the kubeconfig. | ||
|
||
[IMPORTANT] | ||
==== | ||
To avoid being locked out of the cluster, have an alternative way to login, such as, using an OAuth-authenticated administrator user or using a client certificate signed by an additional client CA. | ||
==== | ||
|
||
.Procedure | ||
|
||
. Optional: Generate a new self-signed CA, unless an existing corporate or other CA is to be used. | ||
.. Export a name for the new self-signed CA. | ||
[source,terminal] | ||
---- | ||
|
||
$ export NAME="custom" | ||
---- | ||
+ | ||
.. Export the subject for the new self-signed CA. | ||
[source,terminal] | ||
---- | ||
|
||
$ export CA_SUBJ="/OU=openshift/CN=admin-kubeconfig-signer-custom" | ||
---- | ||
+ | ||
.. Set the CA validity to 10 years (in days). | ||
[source,terminal] | ||
---- | ||
|
||
$ export VALIDITY=3650 | ||
---- | ||
+ | ||
.. Generate the CA private key. | ||
[source,terminal] | ||
---- | ||
|
||
$ openssl genrsa -out ${NAME}-ca.key 4096 | ||
---- | ||
+ | ||
.. Create the CA certificate. | ||
[source,terminal] | ||
---- | ||
|
||
$ openssl req -x509 -new -nodes -key ${NAME}-ca.key -sha256 -days $VALIDITY -out ${NAME}-ca.crt -subj "${CA_SUBJ}" | ||
---- | ||
+ | ||
. Generate a new `system:admin` certificate. This X.509 certificate must include the user's name in the Common Name (*CN*) field and the group name in the Organization (*O*) field. | ||
+ | ||
[Note] | ||
==== | ||
The information in the *CN* and *O* fields are required for authentication. | ||
==== | ||
|
||
+ | ||
[source,terminal] | ||
---- | ||
$ export USER=system:admin | ||
$ export GROUP=system:masters | ||
$ export USER_SUBJ="/O=${GROUP}/CN=${USER}" | ||
|
||
# create the user CSR | ||
$ openssl req -nodes -newkey rsa:2048 -keyout ${USER}.key -subj "${USER_SUBJ}" -out ${USER}.csr | ||
|
||
# sign the user CSR and generate the certificate, the certificate must have the `clientAuth` extension | ||
$ openssl x509 -extfile <(printf "extendedKeyUsage = clientAuth") -req -in ${USER}.csr \ | ||
-CA ${NAME}-ca.crt -CAkey ${NAME}-ca.key -CAcreateserial -out | ||
${USER}.crt -days $VALIDITY -sha256 | ||
---- | ||
+ | ||
. Use the following commands to add the new certificate as an additional clientCA: | ||
+ | ||
[source,terminal] | ||
---- | ||
# create the client-ca ConfigMap" | ||
$ oc create configmap client-ca-custom -n openshift-config --from-file=ca-bundle.crt=${NAME}-ca.crt | ||
|
||
# patch the APIServer | ||
$ oc patch apiserver cluster --type=merge -p '{"spec": {"clientCA": {"name": "client-ca-custom"}}}' | ||
---- | ||
+ | ||
. Use the following commands to import an additional CA certificate in a config map in the `openshift-config`` namespace. The CA file must be in PEM format. | ||
+ | ||
[source,terminal] | ||
---- | ||
$ oc create --kubeconfig="$NEW_KUBECONFIG" configmap admin-kubeconfig-client-ca -n openshift-config --from-file=ca-bundle.crt=${NAME}-ca.crt \ | ||
--dry-run -o yaml | oc replace -f - | ||
---- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,14 @@ by one that is issued by a CA that clients trust. | |
In hosted control plane clusters, you cannot replace self-signed certificates from the API. | ||
==== | ||
|
||
include::modules/customize-certificates-api-add-named.adoc[leveloffset=+1] | ||
include::modules/customize-certificates-api-add-named.adoc[leveloffset=+1] | ||
|
||
include::modules/configure-an-additional-clientCA.adoc[leveloffset=+1] | ||
|
||
include::modules/replace-the-certificate-authority-clientca.adoc[leveloffset=+1] | ||
|
||
[discrete] | ||
[role="_additional-resources"] | ||
== Additional resources | ||
|
||
* link:https://access.redhat.com/solutions/6054981[Replacing the certificate authority for the installer system:admin kubeconfig] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 [error] RedHat.TermsErrors: Use 'installation program' rather than 'the installer'. For more information, see RedHat.TermsErrors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 [error] OpenShiftAsciiDoc.ModuleContainsContentType: Module is missing the '_mod-docs-content-type' variable.