Mohammed Naser | e78b4c5 | 2024-06-01 20:49:40 -0400 | [diff] [blame] | 1 | ============ |
| 2 | Certificates |
| 3 | ============ |
| 4 | |
| 5 | Atmosphere simplifies all the management of your SSL certificates for all of |
| 6 | your API endpoints by automatically issuing and renewing certificates for you |
| 7 | using `cert-manager <https://cert-manager.io>`_. |
| 8 | |
| 9 | Types |
| 10 | ===== |
| 11 | |
| 12 | There are two different ways of issuing certificates. It can either issue |
| 13 | individual certificates for each API endpoint or it can issue a wildcard |
| 14 | certificate for all of your API endpoints. |
| 15 | |
| 16 | Individual Certificates |
| 17 | ----------------------- |
| 18 | |
| 19 | If you want to issue individual certificates for each API endpoint, you do not |
| 20 | need to do anything. This is the default behavior of Atmosphere. |
| 21 | |
| 22 | Wildcard Certificate |
| 23 | -------------------- |
| 24 | |
| 25 | If you decide to use wildcard certificates, you can either let the certificate |
| 26 | manager issue and renew the certificate for you or you can use an existing |
| 27 | wildcard certificate. |
| 28 | |
| 29 | Automatically Issued |
| 30 | ~~~~~~~~~~~~~~~~~~~~ |
| 31 | |
| 32 | If you want to issue a wildcard certificate for all of your API endpoints using |
| 33 | the certificate manager, you can configure it by setting the the following variable |
| 34 | in your inventory: |
| 35 | |
| 36 | .. code-block:: yaml |
| 37 | |
| 38 | openstack_helm_ingress_wildcard_domain: cloud.atmosphere.dev |
| 39 | |
| 40 | This will issue a wildcard certificate for ``*.cloud.atmosphere.dev`` and all |
| 41 | subdomains. The certificate manager will automatically renew the certificate |
| 42 | before it expires. |
| 43 | |
| 44 | Existing Certificate |
| 45 | ~~~~~~~~~~~~~~~~~~~~ |
| 46 | |
| 47 | If you want to use an existing wildcard certificate without relying on the |
| 48 | certificate manager issuing and renewing the certificate, you can use the |
| 49 | following steps: |
| 50 | |
| 51 | 1. Create a Kubernetes TLS secret using your wildcard certificate, you can refer |
| 52 | to the `Kubernetes documentation <https://kubernetes.io/docs/concepts/configuration/secret/#tls-secrets>`_ |
| 53 | for more details. |
| 54 | |
| 55 | .. code-block:: shell |
| 56 | |
| 57 | kubectl -n openstack create secret tls wildcard-certs --key=/path/to/tls.key --cert=/path/to/tls.crt |
| 58 | |
| 59 | .. note:: |
| 60 | |
| 61 | If you have a certificate that needs to be combined with an intermediate |
| 62 | certificate, you can combine them all to a single file with the certificate |
| 63 | first, followed by the intermediate certificate, followed by the root. |
| 64 | |
| 65 | 2. Update the ``openstack_helm_ingress_secret_name`` to point towards the name |
| 66 | of the secret you created in step 1. |
| 67 | |
| 68 | .. code-block:: yaml |
| 69 | |
| 70 | openstack_helm_ingress_secret_name: wildcard-certs |
| 71 | |
| 72 | 3. Set ``cluster_issuer_type`` to ``none``, this is required for other roles |
| 73 | like for example Horizon. |
| 74 | |
| 75 | .. code-block:: yaml |
| 76 | |
| 77 | cluster_issuer_type: none |
| 78 | |
| 79 | .. warning:: |
| 80 | |
| 81 | If you decide to use an existing wildcard certificate, you will need to |
| 82 | manually renew the certificate before it expires. |
| 83 | |
| 84 | Issuers |
| 85 | ======= |
| 86 | |
| 87 | In order to be able to automatically issue certificates, you need to configure |
| 88 | an issuer. There are three different types of issuers that you can use with |
| 89 | Atmosphere. |
| 90 | |
| 91 | .. note:: |
| 92 | |
| 93 | If you decide to change the certificate issuer after deployment, you will |
| 94 | need to delete the existing certificate secret in order for the new issuer |
| 95 | to be able to issue a new certificate. |
| 96 | |
| 97 | ACME |
| 98 | ---- |
| 99 | |
| 100 | Atmosphere uses the `ACME <https://tools.ietf.org/html/rfc8555>`_ protocol by |
| 101 | default to request certificates from `LetsEncrypt <https://letsencrypt.org>`_. |
| 102 | |
| 103 | There are two different challenge types that can be used to verify ownership of |
| 104 | the domain to issue the certificate using ACME. Regardless of the challenge |
| 105 | type, you will need to configure an email address to be used for the ACME |
| 106 | account. |
| 107 | |
| 108 | .. code-block:: yaml |
| 109 | |
| 110 | cluster_issuer_type: acme |
| 111 | cluster_issuer_acme_email: user@example.com |
| 112 | |
| 113 | If you're running your own internal ACME server, you can configure Atmosphere to |
| 114 | point towards it by setting the ``cluster_issuer_acme_server`` variable. |
| 115 | |
| 116 | .. code-block:: yaml |
| 117 | |
| 118 | cluster_issuer_acme_server: https://acme.example.com |
| 119 | cluster_issuer_acme_email: user@example.com |
| 120 | |
| 121 | If the ACME server is using certificates signed by a custom CA, you can add the |
| 122 | following configuration to allow Atmosphere to trust the CA. |
| 123 | |
| 124 | .. code-block:: yaml |
| 125 | |
| 126 | cluster_issuer_acme_private_ca: true |
| 127 | |
| 128 | HTTP-01 Challenge |
| 129 | ~~~~~~~~~~~~~~~~~ |
| 130 | |
| 131 | This is configured to work out of the box if your APIs are publicly accessible |
| 132 | since it uses an HTTP-01 challenge to verify ownership of the domain. You just |
| 133 | need to configure an email address. |
| 134 | |
| 135 | DNS-01 Challenge |
| 136 | ~~~~~~~~~~~~~~~~ |
| 137 | |
| 138 | Atmosphere uses the ``HTTP-01`` solver by default, which means that as long as |
| 139 | your ACME server can reach your API, you don't need to do anything else. |
| 140 | |
| 141 | If your ACME server cannot reach your API, you will need to use the ``DNS-01`` |
| 142 | challenges which require you to configure your DNS provider. |
| 143 | |
| 144 | RFC2136 |
| 145 | ******* |
| 146 | |
| 147 | If you have a DNS server that supports RFC2136, you can use it to solve the DNS |
| 148 | challenges with the following configuration: |
| 149 | |
| 150 | .. code-block:: yaml |
| 151 | |
| 152 | cluster_issuer_acme_email: user@example.com |
| 153 | cluster_issuer_acme_solver: rfc2136 |
| 154 | cluster_issuer_acme_rfc2136_nameserver: <NAMESERVER>:<PORT> |
| 155 | cluster_issuer_acme_rfc2136_tsig_algorithm: <ALGORITHM> |
| 156 | cluster_issuer_acme_rfc2136_tsig_key_name: <KEY_NAME> |
| 157 | cluster_issuer_acme_rfc2136_tsig_secret_key: <SECRET_KEY> |
| 158 | |
| 159 | Route53 |
| 160 | ******* |
| 161 | |
| 162 | If you are using Route53 to host the DNS for your domains, you can use the |
| 163 | following configuration: |
| 164 | |
| 165 | .. code-block:: yaml |
| 166 | |
| 167 | cluster_issuer_acme_email: user@example.com |
| 168 | cluster_issuer_acme_solver: route53 |
| 169 | cluster_issuer_acme_route53_region: <REGION> |
| 170 | cluster_issuer_acme_route53_hosted_zone_id: <HOSTED_ZONE_ID> |
| 171 | cluster_issuer_acme_route53_access_key_id: <AWS_ACCESS_KEY_ID> |
| 172 | cluster_issuer_acme_route53_secret_access_key: <AWS_SECRET_ACCESS_KEY> |
| 173 | |
| 174 | .. note:: |
| 175 | |
| 176 | You'll need to make sure that your AWS credentials have the correct |
| 177 | permissions to update the Route53 zone. |
| 178 | |
| 179 | GoDaddy |
| 180 | ******* |
| 181 | |
| 182 | If you're using GoDaddy for the DNS of your domain, you can use the following |
| 183 | configuration which depends on |
| 184 | `cert-manager-webhook-godaddy <https://github.com/snowdrop/godaddy-webhook>`_. |
| 185 | |
| 186 | .. code-block:: yaml |
| 187 | |
| 188 | cluster_issuer_acme_email: user@example.com |
| 189 | cluster_issuer_acme_solver: godaddy |
| 190 | cluster_issuer_acme_godaddy_api_key: <GODADDY_API_KEY> |
| 191 | cluster_issuer_acme_godaddy_secret_key: <GODADDY_SECRET_KEY> |
| 192 | |
| 193 | Infoblox |
| 194 | ******** |
| 195 | |
| 196 | If you're using Infoblox for the DNS of your domain, you can use the following |
| 197 | configuration which depends on |
| 198 | `cert-manager-webhook-infoblox-wapi <https://github.com/luisico/cert-manager-webhook-infoblox-wapi>`_. |
| 199 | |
| 200 | .. code-block:: yaml |
| 201 | |
| 202 | cluster_issuer_acme_email: user@example.com |
| 203 | cluster_issuer_acme_solver: infoblox |
| 204 | cluster_issuer_acme_infoblox_view: <VIEW> |
| 205 | cluster_issuer_acme_infoblox_host: <HOST> |
| 206 | cluster_issuer_acme_infoblox_username: <USERNAME> |
| 207 | cluster_issuer_acme_infoblox_password: <PASSWORD> |
| 208 | |
| 209 | Venafi |
| 210 | ------ |
| 211 | |
| 212 | Venafi is a commercial certificate authority which can be used with Atmosphere |
| 213 | to issue certificates. Regardless of the way that you authenticate to Venafi, |
| 214 | you will need to configure the issuer. |
| 215 | |
| 216 | .. code-block:: yaml |
| 217 | |
| 218 | cluster_issuer_type: venafi |
Mohammed Naser | c1aac77 | 2024-06-02 20:38:27 -0400 | [diff] [blame^] | 219 | cluster_issuer_venafi_ca: | |
| 220 | -----BEGIN CERTIFICATE----- |
| 221 | MIIDBjCCAe4CCQDQ3Z0Z2Z0Z0jANBgkqhkiG9w0BAQsFADCBhTELMAkGA1UEBhMC |
| 222 | VVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28x |
| 223 | ... |
| 224 | -----END CERTIFICATE----- |
Mohammed Naser | e78b4c5 | 2024-06-01 20:49:40 -0400 | [diff] [blame] | 225 | cluster_issuer_venafi_zone: <ZONE> |
| 226 | cluster_issuer_venafi_tpp_url: <URL> |
| 227 | cluster_issuer_venafi_tpp_ca_bundle: | |
| 228 | -----BEGIN CERTIFICATE----- |
| 229 | MIIDBjCCAe4CCQDQ3Z0Z2Z0Z0jANBgkqhkiG9w0BAQsFADCBhTELMAkGA1UEBhMC |
| 230 | VVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28x |
| 231 | ... |
| 232 | -----END CERTIFICATE----- |
| 233 | |
Mohammed Naser | c1aac77 | 2024-06-02 20:38:27 -0400 | [diff] [blame^] | 234 | .. note:: |
| 235 | |
| 236 | If your issuer is an intermediate certificate, you will need to ensure that |
| 237 | the ``certificate`` key includes the full chain in the correct order of issuer, |
| 238 | intermediate(s), then root. |
| 239 | |
Mohammed Naser | e78b4c5 | 2024-06-01 20:49:40 -0400 | [diff] [blame] | 240 | Authentication |
| 241 | ~~~~~~~~~~~~~~ |
| 242 | |
| 243 | There are two different ways to authenticate to Venafi to issue certificates, |
| 244 | either using a username and password or using an access token. The username and |
| 245 | password method is phased out in newer versions of Venafi, so it is recommended |
| 246 | to use the access token method. |
| 247 | |
| 248 | Username and Password |
| 249 | ********************* |
| 250 | |
| 251 | If you are using a username and password to authenticate to Venafi, you can |
| 252 | configure it with the following variables: |
| 253 | |
| 254 | .. code-block:: yaml |
| 255 | |
| 256 | cluster_issuer_venafi_username: <USERNAME> |
| 257 | cluster_issuer_venafi_password: <PASSWORD> |
| 258 | |
| 259 | Access Token |
| 260 | ************ |
| 261 | |
| 262 | If you are using an access token to authenticate to Venafi, you can configure it |
| 263 | with the following variable: |
| 264 | |
| 265 | .. code-block:: yaml |
| 266 | |
| 267 | cluster_issuer_venafi_access_token: <ACCESS_TOKEN> |
| 268 | |
| 269 | Certificate fields |
| 270 | ~~~~~~~~~~~~~~~~~~ |
| 271 | |
| 272 | If your Venafi zone is strict about the fields that are required or their |
| 273 | values, you can use the `cert-manager supported annotations <https://cert-manager.io/docs/usage/ingress/#supported-annotations>`_ |
| 274 | to configure the certificate values. |
| 275 | |
| 276 | In order to apply these annotations to all ingresses managed by Atmosphere, you |
| 277 | can use the ``ingress_global_annotations`` variable in your inventory which will |
| 278 | apply the annotations to all ingresses. |
| 279 | |
| 280 | .. code-block:: yaml |
| 281 | |
| 282 | ingress_global_annotations: |
| 283 | cert-manager.io/subject-organizations: VEXXHOST, Inc. |
| 284 | cert-manager.io/subject-organizationalunits: Cloud Infrastructure |
| 285 | cert-manager.io/subject-localities: Montreal |
| 286 | cert-manager.io/subject-provinces: Quebec |
| 287 | cert-manager.io/subject-countries: CA |
| 288 | |
| 289 | Using Pre-existing CA |
| 290 | --------------------- |
| 291 | |
| 292 | If you have an existing CA that you'd like to use with Atmosphere, you can |
| 293 | configure it by including the certificate and private key: |
| 294 | |
| 295 | .. code-block:: yaml |
| 296 | |
| 297 | cluster_issuer_type: ca |
| 298 | cluster_issuer_ca_certificate: | |
| 299 | -----BEGIN CERTIFICATE----- |
| 300 | MIIDBjCCAe4CCQDQ3Z0Z2Z0Z0jANBgkqhkiG9w0BAQsFADCBhTELMAkGA1UEBhMC |
| 301 | VVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28x |
| 302 | ... |
| 303 | -----END CERTIFICATE----- |
| 304 | cluster_issuer_ca_private_key: | |
| 305 | -----BEGIN RSA PRIVATE KEY----- |
| 306 | MIIEpAIBAAKCAQEAw3Z0Z2Z0Z0jANBgkqhkiG9w0BAQsFADCBhTELMAkGA1UEBhMC |
| 307 | VVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28x |
| 308 | ... |
| 309 | -----END RSA PRIVATE KEY----- |
| 310 | |
| 311 | .. note:: |
| 312 | |
| 313 | If your issuer is an intermediate certificate, you will need to ensure that |
| 314 | the ``certificate`` key includes the full chain in the correct order of issuer, |
| 315 | intermediate(s), then root. |
| 316 | |
| 317 | Self-signed Certificates |
| 318 | ------------------------ |
| 319 | |
| 320 | If you are in an environment which does not have a trusted certificate authority |
| 321 | and it does not have access to the internet to be able to use LetsEncrypt, you |
| 322 | can use self-signed certificates by adding the following to your inventory: |
| 323 | |
| 324 | .. code-block:: yaml |
| 325 | |
| 326 | cluster_issuer_type: self-signed |
| 327 | |
| 328 | .. warning:: |
| 329 | |
| 330 | Self-signed certificates are not recommended for production environments. |
| 331 | They are only recommended for development and testing environments. |