Skip to content

Commit 1c4e637

Browse files
rawlingsjjenkins-x-bot
authored andcommitted
docs: improve dns and tls docs, giving clearer guidance and explaination, also contains example for enabling TLS in previews
1 parent 463665c commit 1c4e637

File tree

2 files changed

+97
-13
lines changed

2 files changed

+97
-13
lines changed

content/en/v3/admin/guides/infra/tls_dns.md

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,27 @@ aliases:
1010

1111
This section will describe how to enable automated TLS and DNS for your Jenkins X installation.
1212

13-
To achive this we will use a couple of open source projects to help enable automated DNS for your applications.
13+
To achieve this we will use a couple of open source projects to help enable automated DNS for your applications.
1414

1515
For this guide we are going to assume you own a domain called `foo.io` which is managed by Google Cloud DNS, if it is not see [configure cloud dns to manage a domain](/docs/v3/guides/infra/google_cloud_dns).
1616

17-
Jenkins X services will have URLs like `https://hook-jx.bar.foo.io`. The jx-requirements.yml `namespaceSubDomain:` of `-jx` refers to the Kubernetes namespace the service is running in, this helps avoid clashes of the same application running in different namespaces in the same cluster.
17+
18+
A common requirement for domains is to have production services accessed using a parent / [apex domain](https://docs.github.com/en/free-pro-team@latest/github/working-with-github-pages/about-custom-domains-and-github-pages#using-an-apex-domain-for-your-github-pages-site)
19+
for example:
20+
21+
https://foo.com
22+
23+
Many organisations have extra requirements for development and test multi cluster environments to access services at
24+
25+
https://dev.foo.com
26+
and
27+
https://staging.foo.com
28+
29+
These use subdomains.
30+
31+
In this guide below there is a prerequisite that you must already have a domain which is managed by GCP, this is so that you can choose whichever of the scenarios above you need. It also means the dns management of the apex domain happens outside of a single cluster installation and can be shared by multiple installations using a subdomain.
32+
33+
Jenkins X services will have URLs like `https://hook-jx.dev.foo.io`. The jx-requirements.yml `namespaceSubDomain:` of `-jx` which is in the cluster git repository refers to the Kubernetes namespace the service is running in, this avoids clashes of the same application running in different namespaces in the same cluster.
1834

1935
To start with we are focussed on GCP but will expand to other cloud providers.
2036

@@ -23,7 +39,7 @@ To start with we are focussed on GCP but will expand to other cloud providers.
2339
## Prerequisites
2440

2541
- cluster created using Jenkins X [GCP Terraform getting started](/docs/v3/getting-started/gke/)
26-
- own a domain, we will use [Google Domains](https://domains.google.com/registrar/) in this guide but any provider will work
42+
- own a domain and have GCP manage it, [configure cloud dns to manage a domain](/docs/v3/guides/infra/google_cloud_dns)
2743
- latest Jenkins X CLI, Infrastructure and Cluster git repository updates [upgrade](/docs/v3/guides/upgrade)
2844

2945
### Cloud Infrastructure
@@ -43,7 +59,7 @@ Most people prefer to use a subdomain for a specific installation rather than pu
4359
To use a subdomain for this cluster add the following configuration:
4460

4561
```yaml
46-
subdomain = "bar"
62+
subdomain = "dev"
4763
```
4864

4965
Now apply these changes:
@@ -53,20 +69,24 @@ git add values.auto.tfvars
5369
git commit -m 'feat: enable DNS cloud resources'
5470
git push
5571
```
56-
72+
You may want to set two environment variables here so that Terraform does not prompt for values
73+
```
74+
export TF_VAR_jx_bot_username=
75+
export TF_VAR_jx_bot_token=
76+
```
77+
now run
5778
```bash
5879
terraform plan
5980
terraform apply
6081
```
6182

62-
You can now see your managed zone in GCP [here](https://console.cloud.google.com/net-services/dns/zones)
63-
83+
If using a subdomain you will now see your managed zone in GCP [here](https://console.cloud.google.com/net-services/dns/zones)
6484

6585
### Cluster
6686

6787
Next we will configure the cluster requirements:
6888

69-
- Install [external-dns](https://github.com/kubernetes-sigs/external-dns#externaldns) - Kubernetes controller which watches for new Kubernetes Ingress resources and creates A records in Google Cloud DNS which will propogate globally across the internet
89+
- Install [external-dns](https://github.com/kubernetes-sigs/external-dns#externaldns) - Kubernetes controller which watches for new Kubernetes Ingress resources and creates A records in Google Cloud DNS which will propagate globally across the internet
7090
- Install [cert-manager](https://cert-manager.io/docs/) - Kubernetes controller which watches for requests to ask [Let's Encrypt](https://letsencrypt.org/) to issue a new wildcard TLS certificate for your domain and will manage this including renewals
7191

7292
To satisfy these requirements go to your cluster repository (contains helmfile.yaml)
@@ -110,7 +130,7 @@ __NOTE__ this is the top level `ingress:` section and __NOT__ in the `environmen
110130

111131
```bash
112132
ingress:
113-
domain: bar.foo.io
133+
domain: dev.foo.io
114134
externalDNS: false # this is unused and will be deprecated
115135
namespaceSubDomain: -jx.
116136
tls:
@@ -119,7 +139,9 @@ ingress:
119139
production: false
120140
```
121141

122-
When first installing set `tls.production=false` so you use the Lets Encrtpt staging serivce which allows for more API calls before rate limniting requests. They will issue a self-signed certificate so once happy everything is working change this to `tls.production=true`
142+
When first installing set `tls.production=false` so you use the Lets Encrypt staging service which allows for more API calls before rate limiting requests. They will issue a self-signed certificate so once happy everything is working change this to `tls.production=true`.
143+
144+
__NOTE__ Helmfile is not able to skip insecure TLS when adding helm repositories, therefore staging certificates will not work with chartmuseum that is running in the cluster. Therefore once you have verified cert-manager can issue certificates from staging, switch to the production service.
123145

124146
Jenkins X uses a version stream to rollout tested versions of images, charts and default configuration. The `jx-boot` job will apply these versions to your helmfile but you can also run the step yourself to see the defaults.
125147

@@ -128,8 +150,8 @@ jx gitops helmfile resolve
128150
```
129151

130152
```bash
131-
git add values.auto.tfvars
132-
git commit -m 'feat: enable DNS cloud resources'
153+
git add helmfile.yaml
154+
git commit -m 'feat: enable DNS and TLS'
133155
git push
134156
```
135157

@@ -138,6 +160,68 @@ Now tail the admin logs and wait for the job to complete
138160
jx admin logs
139161
```
140162

163+
It can take a short while for DNS to propagate so you may need to wait for 5 - 10 minutes. https://dnschecker.org/ is a useful way to check the status of DNS propagating.
164+
165+
You should be able to verify the TLS certificate from Lets Encrypt in your browser (beware of browser caching if you don't see any changes)
166+
167+
![Working TLS](/images/v3/working_tls.png)
168+
141169
## How to get TLS in my preview environment?
142170

143-
In your applications preview helm chart you can add a Kubernetes [Certificate](https://cert-manager.io/docs/concepts/certificate/) the same as in your `jx` namespace and cert-manager will create the secret needed by an Ingress rule for TLS.
171+
In your applications preview helmfile.yaml you can add the same acme helm chart used above however because your application git repository does not have the version stream your cluster git repository above has you will need to add the default values yourself.
172+
173+
Add this to you applications `./preview/helmfile.yaml`
174+
175+
```
176+
repositories:
177+
- name: jx3
178+
url: https://storage.googleapis.com/jenkinsxio/charts
179+
releases:
180+
- chart: jx3/acme
181+
name: tls
182+
namespace: '{{ requiredEnv "PREVIEW_NAMESPACE" }}'
183+
values:
184+
- jx-values.yaml
185+
- issuer:
186+
cluster: true
187+
```
188+
189+
_Note_ as this will request a certificate that matches your existing domain configured above, cert-manager will reuse a cached certificate rather than issue a new one which can cause rate limitting by Lets Encrypt.
190+
191+
## What if I have a chartmuseum with charts running using nip.io?
192+
193+
It is best to comment out your Jenkins X chartmuseum repository and charts from your helmfile until your new domain and ingress is working. Then uncomment and make sure you update the chartmuseum URL to your new one.
194+
195+
## What if I use a subdomain with an apex domain in a different GCP project?
196+
197+
When using a subdomain Terraform will create a managed zone in GCP, add the recordsets to your parent / apex domain.
198+
199+
If the GCP managed zone for your apex domain is in a different GCP project than the project that your current installation the you will need to set in your infrastructure repository the terraform variable:
200+
201+
```
202+
parent_domain_gcp_project: [your GCP project that is managing your apex domain]
203+
```
204+
205+
If you do not have permission to update the recordset of the apex domain then you will need to manually update it after getting the nameservers created for your subdomain managed zone and disable the automatic way using:
206+
207+
```
208+
apex_domain_integration_enabled: false
209+
```
210+
211+
## How can I check if cert-manager has issued a certificate?
212+
213+
You can check the status of the certificate by running
214+
215+
```
216+
kubectl get cert -n jx
217+
```
218+
```
219+
kubectl describe cert -n jx
220+
```
221+
if `Ready` continues to be `false` after 10-15 mins you can check on the request using
222+
```
223+
kubectl get certificaterequest -n jx
224+
```
225+
```
226+
kubectl describe certificaterequest -n jx
227+
```

static/images/v3/working_tls.png

422 KB
Loading

0 commit comments

Comments
 (0)