{"id":1325,"date":"2019-07-25T18:24:30","date_gmt":"2019-07-25T15:24:30","guid":{"rendered":"https:\/\/artem.services\/?p=1321"},"modified":"2019-07-26T14:01:08","modified_gmt":"2019-07-26T11:01:08","slug":"gke-issuer-dns01-2","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1325&lang=en","title":{"rendered":"GKE &#8212; Issuer DNS01"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-full wp-image-347 aligncenter\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/12\/GCP-Logo.png\" alt=\"\" width=\"955\" height=\"312\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/12\/GCP-Logo.png 955w, https:\/\/artem.services\/wp-content\/uploads\/2018\/12\/GCP-Logo-300x98.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/12\/GCP-Logo-768x251.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/12\/GCP-Logo-954x312.png 954w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\"><strong>GCP<\/strong> will be the <strong>DNS<\/strong> provider.<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<blockquote><p><strong>YOUR_GCP_PROJECT<\/strong> &#8212; <span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Replace with the name of your <strong>GCP<\/strong> project<\/span><\/span><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create an account:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngcloud iam service-accounts create dns01-solver \\\r\n --display-name &quot;dns01-solver&quot;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">We give him access to the <strong>DNS<\/strong> service:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngcloud projects add-iam-policy-binding YOUR_GCP_PROJECT \\\r\n --member serviceAccount:dns01-solver@YOUR_GCP_PROJECT.iam.gserviceaccount.com \\\r\n --role roles\/dns.\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">We generate the key:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngcloud iam service-accounts keys create key.json \\\r\n --iam-account dns01-solver@YOUR_GCP_PROJECT.iam.gserviceaccount.com\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create a secret based on the generated key:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nkubectl create secret generic clouddns-dns01-solver-svc-acct -n cert-manager \\\r\n --from-file=key.json\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create 2 <strong>YAML<\/strong> files for <strong>ClusterIssuer<\/strong>.<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<h3>letsencrypt-staging.yml<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\napiVersion: certmanager.k8s.io\/v1alpha1\r\nkind: ClusterIssuer\r\nmetadata:\r\n  name: letsencrypt-staging\r\nspec:\r\n  acme:\r\n    # The ACME server URL\r\n    server: https:\/\/acme-staging-v02.api.letsencrypt.org\/directory\r\n    # Email address used for ACME registration\r\n    email: noreply@mailserver123.com\r\n    # Name of a secret used to store the ACME account private key\r\n    privateKeySecretRef:\r\n      name: letsencrypt-staging\r\n    solvers:\r\n    - dns01:\r\n        clouddns:\r\n          # The ID of the GCP project\r\n          project: YOUR_GCP_PROJECT\r\n          # This is the secret used to access the service account\r\n          serviceAccountSecretRef:\r\n            name: clouddns-dns01-solver-svc-acct\r\n            key: key.json\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h3>letsencrypt-production.yml<\/h3>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\napiVersion: certmanager.k8s.io\/v1alpha1\r\nkind: ClusterIssuer\r\nmetadata:\r\n  name: letsencrypt-production\r\n  namespace: cert-manager\r\nspec:\r\n  acme:\r\n    server: https:\/\/acme-v02.api.letsencrypt.org\/directory\r\n    # This will register an issuer with LetsEncrypt.  Replace\r\n    # with your admin email address.\r\n    email: noreply@mailserver123.com\r\n    privateKeySecretRef:\r\n      # Set privateKeySecretRef to any unused secret name.\r\n      name: letsencrypt-production\r\n    dns01:\r\n      providers:\r\n      - name: dns\r\n        clouddns:\r\n          # Set this to your GCP project-id\r\n          project: YOUR_GCP_PROJECT\r\n          # Set this to the secret that we publish our service account key\r\n          # in the previous step.\r\n          serviceAccountSecretRef:\r\n            name: clouddns-dns01-solver-svc-acct\r\n            key: key.json\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Do not forget to specify the name of your <strong>GCP<\/strong> project and mailbox.<\/span><\/span><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create a <strong>ClusterIssuer<\/strong>:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nkubectl create -f letsencrypt-staging.yml\r\nkubectl create -f letsencrypt-production.yml\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\"><strong>Ingress<\/strong> example:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\napiVersion: extensions\/v1beta1\r\nkind: Ingress\r\nmetadata:\r\n  annotations:\r\n    kubernetes.io\/ingress.class: nginx\r\n    certmanager.k8s.io\/cluster-issuer: letsencrypt-production\r\n    certmanager.k8s.io\/acme-challenge-type: dns01\r\n    certmanager.k8s.io\/acme-dns01-provider: dns\r\n  name: artem-service-ing\r\n  namespace: staging\r\nspec:\r\n  tls:\r\n  - hosts:\r\n    - artem.services\r\n    secretName: artem.services-tls\r\n  rules:\r\n  - host: artem.services\r\n    http:\r\n      paths:\r\n      - path: \/\r\n        backend:\r\n          serviceName: artem-services-svc\r\n          servicePort: 80\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p><strong>artem-services-svc<\/strong> &#8212; <span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">service name<\/span><\/span><br \/>\n<strong>80<\/strong> &#8212; <span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">service port<\/span><\/span><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; GCP will be the DNS provider. &nbsp; YOUR_GCP_PROJECT &#8212; Replace with the name of your GCP project &nbsp; Create an account: &nbsp; We give him access to the DNS service: &nbsp; We generate the key: &nbsp; Create a secret based on the generated key: &nbsp; Create 2 YAML files for ClusterIssuer. &nbsp; letsencrypt-staging.yml &nbsp; &hellip; <a href=\"https:\/\/artem.services\/?p=1325&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;GKE &#8212; Issuer DNS01&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1021],"tags":[1047,1023,1025,1049,549,551],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1325"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1325"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1325\/revisions"}],"predecessor-version":[{"id":1327,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1325\/revisions\/1327"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}