Skip to content

Commit e69e9dd

Browse files
authored
Merge pull request openshift#7607 from mburke5678/pr-7495
New Sections for Custom Certificates
2 parents 3000998 + 0e6a81e commit e69e9dd

File tree

1 file changed

+288
-43
lines changed

1 file changed

+288
-43
lines changed

install_config/certificate_customization.adoc

+288-43
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This can be done during an
1919
xref:../install_config/install/advanced_install.adoc#advanced-install-custom-certificates[advanced installation] or configured after installation.
2020

2121
[[ansible-configuring-custom-certificates]]
22-
== Configuring Custom Certificates with Ansible
22+
== Configuring Custom Certificates During Installation
2323

2424
During
2525
xref:../install_config/install/advanced_install.adoc#install-config-install-advanced-install[advanced installations],
@@ -29,72 +29,317 @@ custom certificates can be configured using the
2929
configurable in the inventory file. More details are available about
3030
xref:../install_config/install/advanced_install.adoc#advanced-install-custom-certificates[configuring custom certificates with Ansible].
3131

32-
.Example Custom Certificate Configuration with Ansible
33-
----
34-
# Configure custom named certificates
35-
# NOTE: openshift_master_named_certificates is cached on masters and is an
36-
# additive fact, meaning that each run with a different set of certificates
37-
# will add the newly provided certificates to the cached set of certificates.
38-
#
39-
# An optional CA may be specified for each named certificate. CAs will
40-
# be added to the OpenShift CA bundle which allows for the named
41-
# certificate to be served for internal cluster communication.
42-
#
43-
# If you would like openshift_master_named_certificates to be overwritten with
44-
# the provided value, specify openshift_master_overwrite_named_certificates.
32+
.Custom Certificate Configuration Parameters
33+
[source,yaml]
34+
----
35+
openshift_master_overwrite_named_certificates=true <1>
36+
openshift_master_named_certificates=[{"certfile": "/path/on/host/to/crt-file", "keyfile": "/path/on/host/to/key-file", "names": ["public-master-host.com"], "cafile": "/path/on/host/to/ca-file"}] <2>
37+
openshift_hosted_router_certificate=[{"certfile": "/path/on/host/to/app-crt-file", "keyfile": "/path/on/host/to/app-key-file", "cafile": "/path/on/host/to/app-ca-file"}] <3>
38+
----
39+
40+
<1> If you provide a value for the `openshift_master_named_certificates` parameter, set this parameter to `true`.
41+
<2> Provisions a xref:configuring-custom-certificates-master[master API certificate].
42+
<3> Provisions a xref:configuring-custom-certificates-wildcard[wildcard API certificate].
43+
44+
Example parameters for a master API certificate:
45+
----
4546
openshift_master_overwrite_named_certificates=true
46-
#
47-
# Provide local certificate paths which will be deployed to masters
48-
openshift_master_named_certificates=[{"certfile": "/path/on/host/to/custom1.crt", "keyfile": "/path/on/host/to/custom1.key", "cafile": "/path/on/host/to/custom-ca1.crt"}]
49-
#
50-
# Detected names may be overridden by specifying the "names" key
51-
#openshift_master_named_certificates=[{"certfile": "/path/on/host/to/custom1.crt", "keyfile": "/path/on/host/to/custom1.key", "names": ["public-master-host.com"], "cafile": "/path/on/host/to/custom-ca1.crt"}]
47+
openshift_master_named_certificates=[{"names": ["master.148.251.233.173.nip.io"], "certfile": "/home/cloud-user/master-bundle.cert.pem", "keyfile": "/home/cloud-user/master.148.251.233.173.nip.io.key.pem" ]
48+
----
49+
50+
Example parameters for a wildcard API certificate:
51+
----
52+
openshift_hosted_router_certificate={"certfile": "/home/cloud-user/star-apps.148.251.233.173.nip.io.cert.pem", "keyfile": "/home/cloud-user/star-apps.148.251.233.173.nip.io.key.pem", "cafile": "/home/cloud-user/ca-chain.cert.pem"}
5253
----
5354

5455
[[configuring-custom-certificates]]
55-
== Configuring Custom Certificates
56+
== Configuring Custom Certificates for the Web Console or CLI
57+
58+
You can specify custom certificates for the web console and for the CLI through the
59+
`servingInfo` section of the xref:../install_config/master_node_configuration.adoc#master-configuration-files[master
60+
configuration file]:
5661

57-
In the
58-
xref:../install_config/master_node_configuration.adoc#master-configuration-files[master
59-
configuration file] you can list the `namedCertificates` section in the
60-
`servingInfo` section so the custom certificate serves up for the
61-
web console, and in the `servingInfo` section so the custom certificate serves
62-
up for the CLI and other API calls. Multiple certificates can be configured this
63-
way and each certificate may be associated with multiple host names or
64-
wildcards.
62+
* The `servingInfo.namedCertificates` section serves up custom certificates for the web console.
63+
* The `servingInfo` section serves up custom certificates for the CLI and other API calls.
64+
65+
You can configure multiple certificates this way, and each certificate can be associated with
66+
xref:configuring-custom-certificates-master[multiple host names], xref:configuring-custom-certificates-master[multiple routers], or the xref:configuring-custom-certificates-registry[{product-title} image registry].
6567

6668
A default certificate must be configured in the `servingInfo.certFile` and
6769
`servingInfo.keyFile` configuration sections in addition to
6870
`namedCertificates`.
6971

7072
[NOTE]
7173
====
72-
The `namedCertificates` section should only be configured for the host name
74+
The `namedCertificates` section should be configured only for the host name
7375
associated with the `masterPublicURL` and
74-
`oauthConfig.assetPublicURL` settings. Using a custom serving certificate for
76+
`oauthConfig.assetPublicURL` settings n the *_/etc/origin/master/master-config.yaml_* file.
77+
Using a custom serving certificate for
7578
the host name associated with the `masterURL` will result in TLS errors as
7679
infrastructure components will attempt to contact the master API using the
7780
internal `masterURL` host.
7881
====
7982

8083
.Custom Certificates Configuration
84+
8185
----
8286
servingInfo:
83-
...
87+
logoutURL: ""
88+
masterPublicURL: https://openshift.example.com:8443
89+
publicURL: https://openshift.example.com:8443/console/
8490
namedCertificates:
85-
- certFile: /etc/origin/master/named_certificates/custom.crt
86-
keyFile: /etc/origin/master/named_certificates/custom.key
87-
names:
88-
- "customhost.com"
89-
- "api.customhost.com"
90-
- "console.customhost.com"
91-
...
91+
bindAddress: 0.0.0.0:8443
92+
bindNetwork: tcp4
93+
certFile: master.server.crt <1>
94+
clientCA: ""
95+
keyFile: master.server.key <1>
96+
maxRequestsInFlight: 0
97+
requestTimeoutSeconds: 0
98+
namedCertificates:
99+
- certFile: wildcard.example.com.crt <2>
100+
keyFile: wildcard.example.com.key <2>
101+
names:
102+
- "openshift.example.com"
103+
metricsPublicURL: "https://metrics.os.example.com/hawkular/metrics"
104+
105+
----
106+
107+
<1> Path to certificate and key files for the CLI and other API calls.
108+
<2> Path to certificate and key files for the web console.
109+
110+
The `openshift_master_cluster_public_hostname` and `openshift_master_cluster_hostname` parameters in the xref:../install_config/install/advanced_install.adoc#configuring-ansible[Ansible inventory file], by default `/etc/ansible/hosts`, must be different. If they are the same, the named certificates will fail and you will need to re-install them.
111+
92112
----
113+
# Native HA with External LB VIPs
114+
openshift_master_cluster_hostname=internal.paas.example.com
115+
openshift_master_cluster_public_hostname=external.paas.example.com
116+
----
117+
118+
For more information on
119+
using DNS with {product-title}, see the xref:../install_config/install/prerequisites.adoc#prereq-dns[DNS installation prerequisites].
93120

94-
Relative paths are resolved relative to the master configuration file. Restart
121+
This approach allows you to take advantage of the self-signed certificates generated by {product-title} and add custom trusted certificates to individual components as needed.
122+
123+
Note that the internal infrastructure certificates remain self-signed, which might be perceived as bad practice by some security or PKI teams. However, any risk here is minimal, as the only clients that trust these certificates are other components within the cluster. All external users and systems use custom trusted certificates.
124+
125+
Relative paths are resolved based on the location of the master configuration file. Restart
95126
the server to pick up the configuration changes.
96127

97-
For the master API or web console, wildcard names are accepted.
128+
[[configuring-custom-certificates-master]]
129+
== Configuring a Custom Master Host Certificate
130+
131+
In order to facilitate trusted connections with external users of {product-title}, you can provision a named certificate that matches the domain name provided in the `openshift_master_cluster_public_hostname` paramater in the xref:../install_config/install/advanced_install.adoc#configuring-ansible[Ansible inventory file],
132+
by default `/etc/ansible/hosts`.
133+
134+
You must place this certificate in a directory accessible to Ansible and add the path in the
135+
Ansible inventory file, as follows:
136+
137+
----
138+
openshift_master_named_certificates=[{"certfile": "/path/to/console.ocp-c1.myorg.com.crt", "keyfile": "/path/to/console.ocp-c1.myorg.com.key", "names": ["console.ocp-c1.myorg.com"]}]
139+
----
140+
141+
Where the parameter values are:
142+
143+
* *certfile* is the path to the file that contains the {product-title} router certificate.
144+
145+
* *keyfile* is the path to the file that contains the {product-title} wildcard key.
146+
147+
* *names* is the cluster public hostname.
148+
149+
// * *cafile* contains the root CA for this key and certificate. If an intermediate CA is in use, it must contain both the intermediate and root CA. "cafile": "/path/to/console.ocp-c1.myorg.com.ca.crt"
150+
151+
152+
The file paths must be local to the system where Ansible runs. Certificates
153+
are copied to master hosts and are deployed within the
154+
*_/etc/origin/master/named_certificates/_* directory.
155+
156+
When securing the registry, add the service hostnames and IP addresses to the server certificate for the registry.
157+
The Subject Alternative Names (SAN) must contain the following.
158+
159+
* Two service hostnames:
160+
+
161+
----
162+
docker-registry.default.svc.cluster.local
163+
docker-registry.default.svc
164+
----
165+
166+
* Service IP address.
167+
+
168+
For example:
169+
+
170+
----
171+
172.30.252.46
172+
----
173+
+
174+
Use the following command to get the Docker registry service IP address:
175+
+
176+
----
177+
oc get service docker-registry --template='{{.spec.clusterIP}}'
178+
----
179+
180+
* Public hostname.
181+
+
182+
----
183+
docker-registry-default.apps.example.com
184+
----
185+
+
186+
Use the following command to get the Docker registry public hostname:
187+
+
188+
----
189+
oc get route docker-registry --template '{{.spec.host}}'
190+
----
191+
192+
For example, the server certificate should contain SAN details similar to the following:
193+
194+
----
195+
X509v3 Subject Alternative Name:
196+
DNS:docker-registry-public.openshift.com, DNS:docker-registry.default.svc, DNS:docker-registry.default.svc.cluster.local, DNS:172.30.2.98, IP Address:172.30.2.98
197+
----
198+
199+
[[configuring-custom-certificates-wildcard]]
200+
== Configuring a Custom Wildcard Certificate for the Default Router
201+
202+
You can configure the {product-title} default router with a default wildcard certificate. A default wildcard certificate provides a convenient way for
203+
applications that are deployed in {product-title} to use default encryption without needing custom certificates.
204+
205+
[NOTE]
206+
====
207+
Default wildcard certificates are recommended for non-production environments only.
208+
====
209+
210+
In order to configure a default wildcard certificate, provision a certificate that is valid for `.<app_domain>`, where `<app_domain>` is the value of `openshift_master_default_subdomain` in the xref:../install_config/install/advanced_install.adoc#configuring-ansible[Ansible inventory file], by default `/etc/ansible/hosts`. Once provisioned, place the certificate, key, and ca certificate files on your Ansible host, and add the following line to your Ansible inventory file.
211+
212+
----
213+
openshift_hosted_router_certificate={"certfile": "/path/to/apps.c1-ocp.myorg.com.crt", "keyfile": "/path/to/apps.c1-ocp.myorg.com.key", "cafile": "/path/to/apps.c1-ocp.myorg.com.ca.crt"}
214+
----
215+
216+
For example:
217+
218+
----
219+
openshift_hosted_router_certificate={"certfile": "/home/cloud-user/star-apps.148.251.233.173.nip.io.cert.pem", "keyfile": "/home/cloud-user/star-apps.148.251.233.173.nip.io.key.pem", "cafile": "/home/cloud-user/ca-chain.cert.pem"}
220+
----
221+
222+
Where the parameter values are:
223+
224+
* *certfile* is the path to the file that contains the {product-title} router certificate.
225+
226+
* *keyfile* is the path to the file that contains the {product-title} wildcard key.
227+
228+
* *cafile* is the path to the file that contains the root CA for this key and certificate. If an intermediate CA is in use, the file should contain both the intermediate and root CA.
229+
230+
If these certificate files are new to your {product-title} cluster, run the Ansible *_deploy_cluster.yml_* playbook to add these files to the {product-title} configuration files.
231+
The playbook adds the certificate files to the *_/etc/origin/master/named_certificates/_* directory.
232+
233+
----
234+
ifdef::openshift-enterprise[]
235+
# ansible-playbook [-i /path/to/inventory] \
236+
/usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml
237+
endif::[]
238+
ifdef::openshift-origin[]
239+
# ansible-playbook [-i /path/to/inventory] \
240+
~/openshift-ansible/playbooks/deploy_cluster.yml
241+
endif::[]
242+
----
243+
244+
If xref:../install_config/redeploying_certificates.adoc#redeploying-all-certificates-current-ca[the certificates are not new],
245+
for example, you want to change existing certificates or replace expired certificates, run the following playbook:
246+
247+
----
248+
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/redeploy-certificates.yml
249+
----
250+
251+
[NOTE]
252+
For this playbook to run, the certificate names must not change. If the certificate names change, rerun the Ansible *_deploy_cluster.yml_* playbook
253+
as if the certificates were new.
254+
255+
[[configuring-custom-certificates-registry]]
256+
== Configuring a Custom Certificate for the Image Registry
257+
258+
The {product-title} image registry is an internal service that facilitates builds and deployments. Most of the communication with the registry is handled by internal components in {product-title}. As such, you should not need to replace the certificate used by the registry service itself.
259+
260+
However, by default, the registry uses routes to allow external systems and users to do pulls and pushes of images. You can use a _re-encrypt route_ with a custom certificate that is presented to external users instead of using the internal, self-signed certificate.
261+
262+
To configure this, add the xref:../install_config/install/advanced_install.adoc#advanced-install-configuring-docker-route[following lines] of code
263+
to the [OSEv3:vars] section of the Ansible inventory file, by default /etc/ansible/hosts file.
264+
Specify the certificates to use with the registry route.
265+
266+
----
267+
openshift_hosted_registry_routehost=registry.apps.c1-ocp.myorg.com <1>
268+
openshift_hosted_registry_routecertificates={"certfile": "/path/to/registry.apps.c1-ocp.myorg.com.crt", "keyfile": "/path/to/registry.apps.c1-ocp.myorg.com.key", "cafile": "/path/to/registry.apps.c1-ocp.myorg.com-ca.crt"} <2>
269+
openshift_hosted_registry_routetermination=reencrypt <3>
270+
----
271+
272+
//https://github.com/openshift/openshift-docs/issues/5765
273+
<1> The host name of the registry.
274+
<2> The locations of the *cacert*, *root*, and *cafile* files.
275+
+
276+
* *certfile* is the path to the file that contains the {product-title} router certificate.
277+
278+
* *keyfile* is the path to the file that contains the {product-title} wildcard key.
279+
280+
* *cafile* is the path to the file that contains the root CA for this key and certificate. If an intermediate CA is in use, the file should contain both the intermediate and root CA.
281+
<3> Specify where encryption is performed:
282+
+
283+
* Set to `reencrypt` with a _re-encrypt route_ to terminate encryption at the edge router and re-encrypt it with a new certificate supplied by the destination.
284+
+
285+
* Set to `passthrough` to terminate encryption at the destination. The destination is responsible for decrypting traffic.
286+
287+
[[configuring-custom-certificates-retrofit]]
288+
== Retrofit Custom Certificates into a Cluster
289+
290+
You can retrofit custom master and custom router certificates into an existing {product-title} cluster by editing the
291+
the Ansible inventory file, by default *_/etc/ansible/hosts_*, and running a playbook.
292+
293+
[[configuring-custom-certificates-retrofit-master]]
294+
=== Retrofit Custom Master Certificates into a Cluster
295+
296+
To retrofit custom certificates:
297+
298+
. Edit the Ansible inventory file to set the `openshift_master_overwrite_named_certificates=true`.
299+
300+
. Specify the path to the certificate using the `openshift_master_named_certificates` parameter.
301+
+
302+
[source,yaml]
303+
----
304+
openshift_master_overwrite_named_certificates=true
305+
openshift_master_named_certificates=[{"certfile": "/path/on/host/to/crt-file", "keyfile": "/path/on/host/to/key-file", "names": ["public-master-host.com"], "cafile": "/path/on/host/to/ca-file"}] <1>
306+
----
307+
+
308+
<1> Path to a xref:configuring-custom-certificates-master[master API certificate].
309+
310+
. Run the following playbook:
311+
+
312+
----
313+
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/redeploy-certificates.yml
314+
----
315+
316+
[[configuring-custom-certificates-retrofit-router]]
317+
=== Retrofit Custom Router Certificates into a Cluster
318+
319+
To retrofit custom router certificates:
320+
321+
. Edit the Ansible inventory file to set the `openshift_master_overwrite_named_certificates=true`.
322+
323+
. Specify the path to the certificate using the `openshift_hosted_router_certificate` parameter.
324+
+
325+
[source,yaml]
326+
----
327+
openshift_master_overwrite_named_certificates=true
328+
openshift_hosted_router_certificate=[{"certfile": "/path/on/host/to/app-crt-file", "keyfile": "/path/on/host/to/app-key-file", "cafile": "/path/on/host/to/app-ca-file"}] <1>
329+
----
330+
+
331+
<1> Path to a xref:configuring-custom-certificates-wildcard[wildcard API certificate].
332+
333+
. Run the following playbook:
334+
+
335+
----
336+
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/redeploy-router-certificates.yml
337+
----
338+
339+
[[ansible-configuring-custom-certificates-other]]
340+
== Using Custom Certificates with Other Components
341+
342+
For information on how other components, such as Logging & Metrics, use custom certificates, see
343+
xref:../admin_solutions/certificate_management.adoc#admin-solutions-certificate-management[Certificate Management].
344+
98345

99-
The provided named certificate can also be added using the
100-
xref:../install_config/redeploying_certificates.adoc#redeploying-all-certificates-current-ca[*_redeploy-certificates.yml_* playbook].

0 commit comments

Comments
 (0)