Skip to content

Commit 8f413e2

Browse files
tcnghiagoogle-prow-robot
authored andcommitted
How to use paid SSL cert with Knative (knative#146)
* Add simple SSL instruction. * Remove whitespaces. * Revise based on the comments * Add license footer * Add LetsEncrypt instructions * Remove TLS limitation
1 parent 6dbe482 commit 8f413e2

File tree

2 files changed

+96
-3
lines changed

2 files changed

+96
-3
lines changed

serving/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ in the Knative Serving repository.
8484
See the [Knative Serving Issues](https://github.com/knative/serving/issues) page for a full list of
8585
known issues.
8686

87-
* **No support for TLS** - Currently the Knative Serving components do not support TLS connections for
88-
inbound HTTPS traffic. See [#537](https://github.com/knative/serving/issues/537) for more details.
89-
9087
---
9188

9289
Except as otherwise noted, the content of this page is licensed under the

serving/using-an-ssl-cert.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Configuring HTTPS with a custom certificate
2+
3+
If you already have an SSL/TLS certificate for your domain you can
4+
follow the steps below to configure Knative to use your certificate
5+
and enable HTTPS connections.
6+
7+
Before you begin, you will need to
8+
[configure Knative to use your custom domain](./using-a-custom-domain.md).
9+
10+
**Note:** due to limitations in Istio, Knative only supports a single
11+
certificate per cluster. If you will serve multiple domains in the same
12+
cluster, make sure the certificate is signed for all the domains.
13+
14+
## Add the Certificate and Private Key into a secret
15+
16+
Assuming you have two files, `cert.pk` which contains your certificate private
17+
key, and `cert.pem` which contains the public certificate, you can use the
18+
following command to create a secret that stores the certificate. Note the
19+
name of the secret, `istio-ingressgateway-certs` is required.
20+
21+
```shell
22+
kubectl create -n istio-system secret tls istio-ingressgateway-certs \
23+
--key cert.pk \
24+
--cert cert.pem
25+
```
26+
27+
## Configure the Knative shared Gateway to use the new secret
28+
29+
Once you have created a secret that contains the certificate,
30+
you need to update the Gateway spec to use the HTTPS.
31+
32+
To edit the shared gateway, run:
33+
34+
```shell
35+
kubectl edit gateway knative-shared-gateway -n knative-serving
36+
```
37+
38+
Change the Gateway spec to include the `tls:` section as shown below, then
39+
save the changes.
40+
41+
```yaml
42+
# Please edit the object below. Lines beginning with a '#' will be ignored.
43+
# and an empty file will abort the edit. If an error occurs while saving this file will be
44+
# reopened with the relevant failures.
45+
apiVersion: networking.istio.io/v1alpha3
46+
kind: Gateway
47+
metadata:
48+
# ... skipped ...
49+
spec:
50+
selector:
51+
knative: ingressgateway
52+
servers:
53+
- hosts:
54+
- '*'
55+
port:
56+
name: http
57+
number: 80
58+
protocol: HTTP
59+
- hosts:
60+
- '*'
61+
port:
62+
name: https
63+
number: 443
64+
protocol: HTTPS
65+
tls:
66+
mode: SIMPLE
67+
privateKey: /etc/istio/ingressgateway-certs/tls.key
68+
serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
69+
```
70+
71+
Once the change has been made, you can now use the HTTPS protocol to access
72+
your deployed services.
73+
74+
75+
## Obtaining an SSL/TLS certificate using LetsEncrypt
76+
77+
If you don't have an existing SSL/TLS certificate, you can use [LetsEncrypt](https://letsencrypt.org)
78+
to obtain a certificate manually.
79+
80+
1. Install the `certbot-auto` script from the [Certbot website](https://certbot.eff.org/docs/install.html#certbot-auto).
81+
1. Use the certbot to request a certificate, using DNS validation. The certbot tool will walk
82+
you through validating your domain ownership by creating TXT records in your domain.
83+
84+
```shell
85+
./certbot-auto certonly --manual --preferred-challenges dns -d '*.default.yourdomain.com'
86+
```
87+
88+
1. When certbot is complete, you will have two output files, `privkey.pem` and `fullchain.pem`. These files
89+
map to the `cert.pk` and `cert.pem` files used above.
90+
91+
---
92+
93+
Except as otherwise noted, the content of this page is licensed under the
94+
[Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/),
95+
and code samples are licensed under the
96+
[Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0).

0 commit comments

Comments
 (0)