Compare languages | The cert-manager module: usage

An example of provisioning a certificate

Пример заказа сертификата

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: example-com # the name of the certificate; you can use it to view the cert’s status namespace: default spec: secretName: example-com-tls # the name of the secret to store a private key and a certificate issuerRef: kind: ClusterIssuer # the link to the certificate “issuer”, see more below name: letsencrypt commonName: example.com # the main certificate domain dnsNames: # additional domains (At least one DNS Name or IP address is required)

  • www.example.com
  • admin.example.com

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: example-com # Имя сертификата, через него потом можно смотреть статус. namespace: default spec: secretName: example-com-tls # Название Secret’а, в который положить приватный ключ и сертификат. issuerRef: kind: ClusterIssuer # Ссылка на “выдаватель” сертификатов, см. подробнее ниже. name: letsencrypt commonName: example.com # Основной домен сертификата. dnsNames: # Дополнительные домены сертификата (как минимум одно DNS-имя или IP-адрес должны быть указаны).

  • www.example.com
  • admin.example.com

Here:

  • a separate Ingress resource is created for the duration of the challenge (thus, authentication and whitelist of the primary Ingress will not interfere with the process),
  • you can issue a single certificate for several Ingress resources (the deletion of the resource based on the tls-acme annotation won’t affect it in any way),
  • you can issue a certificate with multiple DNS names (as in the example above),
  • you can validate different domains that are part of the same certificate using different Ingress controllers.

При этом:

  • создается отдельный Ingress-ресурс на время прохождения challenge’а (соответственно, аутентификация и whitelist основного Ingress не будут мешать);
  • можно заказать один сертификат на несколько Ingress-ресурсов (и он не отвалится при удалении того, в котором была аннотация tls-acme);
  • можно заказать сертификат с дополнительными именами (как в примере);
  • можно валидировать разные домены, входящие в один сертификат, через разные Ingress-контроллеры.

Read more in the cert-manager documentation.

Подробнее можно прочитать в документации cert-manager.

Issuing a DNS wildcard certificate using Cloudflare

Заказ wildcard-сертификата с DNS в Cloudflare

  1. Get the Global API Key and Email Address:
    • Go to https://dash.cloudflare.com/profile.
    • You can find an active Email Address at the very top of the page.
    • Click the View button at the bottom of the page next to the Global API Key.
  1. Получим Global API Key и Email Address:
    • Заходим на страницу: https://dash.cloudflare.com/profile.
    • В самом верху страницы написана ваша почта под Email Address.
    • В самом низу страницы жмем на кнопку View напротив Global API Key.

You will see the key for interacting with the Cloudflare API (as well as the account email).

В результате этого мы получаем ключ для взаимодействия с API Cloudflare и почту, на которую зарегистрирован аккаунт.

  1. Edit the cert-manager module configuration and add the following parameters:
  1. Редактируем настройки модуля cert-manager и добавляем такую секцию:

yaml settings: cloudflareGlobalAPIKey: APIkey cloudflareEmail: some@mail.somedomain

yaml settings: cloudflareGlobalAPIKey: APIkey cloudflareEmail: some@mail.somedomain

or

или

yaml settings: cloudflareAPIToken: some-token cloudflareEmail: some@mail.somedomain

yaml settings: cloudflareAPIToken: some-token cloudflareEmail: some@mail.somedomain

After that, Deckhouse will automatically create ClusterIssuer and Secret for Cloudflare in the d8-cert-manager namespace.

После этого Deckhouse автоматически создаст ClusterIssuer и Secret для Cloudflare в namespace d8-cert-manager.

  • Configuration with APIToken is more secure and recommended for use.
  • Конфигурация с помощью APIToken является рекомендуемой и более безопасной.
  1. Create a Certificate with validation via Cloudflare. Note that you must specify cloudflareGlobalAPIKey and cloudflareEmail in Deckhouse beforehand:
  1. Создаем Certificate с проверкой с помощью провайдера Cloudflare. Данная возможность появится только при указании настройки cloudflareGlobalAPIKey и cloudflareEmail в Deckhouse:

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: domain-wildcard namespace: app-namespace spec: secretName: tls-wildcard issuerRef: name: cloudflare kind: ClusterIssuer commonName: “*.domain.com” dnsNames:

  • “*.domain.com”

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: domain-wildcard namespace: app-namespace spec: secretName: tls-wildcard issuerRef: name: cloudflare kind: ClusterIssuer commonName: “*.domain.com” dnsNames:

  • “*.domain.com”
  1. Create an Ingress:
  1. Создаем Ingress:

yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: domain-wildcard namespace: app-namespace spec: ingressClassName: nginx rules:

  • host: “*.domain.com” http: paths:
  • backend: service: name: svc-web port: number: 80 path: / tls:
  • hosts:
  • “*.domain.com” secretName: tls-wildcard

yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: domain-wildcard namespace: app-namespace spec: ingressClassName: nginx rules:

  • host: “*.domain.com” http: paths:
  • backend: service: name: svc-web port: number: 80 path: / tls:
  • hosts:
  • “*.domain.com” secretName: tls-wildcard

Issuing a DNS wildcard certificate using Route53

Заказ wildcard-сертификата с DNS в Route53

  1. Create a user with the appropriate permissions.
  1. Создаем пользователя с необходимыми правами.
  • For this, go to the policy management page and create a policy as follows:

json { “Version”: “2012-10-17”, “Statement”: [ { “Effect”: “Allow”, “Action”: “route53:GetChange”, “Resource”: “arn:aws:route53:::change/” }, { “Effect”: “Allow”, “Action”: “route53:ChangeResourceRecordSets”, “Resource”: “arn:aws:route53:::hostedzone/” }, { “Effect”: “Allow”, “Action”: “route53:ListHostedZonesByName”, “Resource”: “*” } ] }

json { “Version”: “2012-10-17”, “Statement”: [ { “Effect”: “Allow”, “Action”: “route53:GetChange”, “Resource”: “arn:aws:route53:::change/” }, { “Effect”: “Allow”, “Action”: “route53:ChangeResourceRecordSets”, “Resource”: “arn:aws:route53:::hostedzone/” }, { “Effect”: “Allow”, “Action”: “route53:ListHostedZonesByName”, “Resource”: “*” } ] }

  1. Edit the cert-manager module configuration and add the following parameters:
  1. Редактируем настройки модуля cert-manager и добавляем такую секцию:

yaml settings: route53AccessKeyID: AKIABROTAITAJMPASA4A route53SecretAccessKey: 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

yaml settings: route53AccessKeyID: AKIABROTAITAJMPASA4A route53SecretAccessKey: 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

After that, Deckhouse will automatically create ClusterIssuer and Secret for route53 in the d8-cert-manager namespace.

После этого Deckhouse автоматически создаст ClusterIssuer и Secret для route53 в namespace d8-cert-manager.

  1. Create a Certificate with validation via route53. Note that you must specify route53AccessKeyID and route53SecretAccessKey in Deckhouse beforehand:
  1. Создаем Certificate с проверкой с помощью провайдера route53. Данная возможность появится только при указании настроек route53AccessKeyID и route53SecretAccessKey в Deckhouse:

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: domain-wildcard namespace: app-namespace spec: secretName: tls-wildcard issuerRef: name: route53 kind: ClusterIssuer commonName: “*.domain.com” dnsNames:

  • “*.domain.com”

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: domain-wildcard namespace: app-namespace spec: secretName: tls-wildcard issuerRef: name: route53 kind: ClusterIssuer commonName: “*.domain.com” dnsNames:

  • “*.domain.com”

Issuing a DNS wildcard certificate using Google

Заказ wildcard-сертификата с DNS в Google

  1. Create a service account with the appropriate role:
  1. Создаем ServiceAccount с необходимой ролью:
  • Go to the policy management page.
  • Select your project.
  • Create a service account with the desired name (e.g., dns01-solver).
  • Switch to the service account created.
  • Add a key by clicking the “Add key” button.
  • The .json file with the key data will be saved to your computer.
  • Encode the resulting file using the base64 algorithm:
  • Заходим на страницу управления политиками.
  • Выбираем нужный проект.
  • Создаем ServiceAccount с желаемым названием, например dns01-solver.
  • Заходим в созданный ServiceAccount.
  • Создаем ключ по кнопке «Добавить ключ».
  • Будет скачан .json-файл с данными ключа имени.
  • Закодируем полученный файл в строку base64:

shell base64 project-209317-556c656b81c4.json

shell base64 project-209317-556c656b81c4.json

  1. Use the resulting base-64 string for setting the cloudDNSServiceAccount module parameter.
  1. Сохраняеем полученную base64-строку в параметр модуля cloudDNSServiceAccount.

After that, Deckhouse will automatically create ClusterIssuer and Secret for cloudDNS in the d8-cert-manager namespace.

После этого Deckhouse автоматически создаст ClusterIssuer и Secret для cloudDNS в namespace d8-cert-manager.

  1. Create a Certificate with validation via cloudDNS:
  1. Создаем Certificate с валидацией через cloudDNS:

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: domain-wildcard namespace: app-namespace spec: secretName: tls-wildcard issuerRef: name: clouddns kind: ClusterIssuer dnsNames:

  • “*.domain.com”

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: domain-wildcard namespace: app-namespace spec: secretName: tls-wildcard issuerRef: name: clouddns kind: ClusterIssuer dnsNames:

  • “*.domain.com”

Issuing a self-signed certificate

Заказ self-signed-сертификата

In this case, the entire process is even more straightforward than that of LetsEncypt. Simply replace the issuer name (letsencrypt) with selfsigned:

Все еще проще, чем с LetsEncypt. Просто меняем letsencrypt на selfsigned:

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: example-com # the name of the certificate; you can use it to view the cert’s status namespace: default spec: secretName: example-com-tls # the name of the secret to store a private key and a certificate issuerRef: kind: ClusterIssuer # the link to the certificate “issuer”, see more below name: selfsigned commonName: example.com # the main certificate domain dnsNames: # additional certificate domains (optional)

  • www.example.com
  • admin.example.com

yaml apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: example-com # Имя сертификата, через него потом можно смотреть статус. namespace: default spec: secretName: example-com-tls # Название Secret’а, в который положить приватный ключ и сертификат. issuerRef: kind: ClusterIssuer # Ссылка на “выдаватель” сертификатов, см. подробнее ниже. name: selfsigned commonName: example.com # Основной домен сертификата. dnsNames: # Дополнительные домены сертификата, указывать необязательно.

  • www.example.com
  • admin.example.com