Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS (HTTPS) section to gke.md #148

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions deploy/gke.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,61 @@ spec:
serviceName: kong-admin
servicePort: 8001" | kubectl apply -f -
```

#### Setup TLS (HTTPS)

You need to set your API with HTTPS in order to expose your service securely. In this section, I will explain how to secure it with [Let’s Encrypt](https://letsencrypt.org/).

##### 1. Register fyour domain
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyour -> your


First of all, you must register your domain with any domain registration services such as [Google Domains](https://domains.google/).

##### 2. Follow instructions of Let’s Encrypt on GKE

[Let’s Encrypt on GKE](https://github.com/ahmetb/gke-letsencrypt) is a tutorial for installing `cert-manager` to get HTTPS certificates from Let’s Encrypt. There is an important things you need to configure, if you want to accomplish correctly. You should apply [KongIngress](https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/custom-types.md#kongingress) and set `preserve_host` configuration `true` at the [4th step](https://github.com/ahmetb/gke-letsencrypt/blob/master/40-deploy-an-app.md) so that you could keep hostname in request headers.

[cert-manager](https://github.com/jetstack/cert-manager) checks equality of hostname and domain name when it creates HTTPS certificates. However, Kong remove hostname as default. I recommend you to create a `KongIngress` spec file to avoid the following error.

```
[dummy.kong.example] Invalid host 'xxx.xxx.xxx.xxx'
```

These are examples of `KongIngress` and `Ingress` spec.

```sh
echo -n "
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: sample-kong-ingress
namespace: kong
proxy:
path: /
route:
protocols:
- https
- http
strip_path: false
preserve_host: true" | kubectl apply -f -
```

```sh
echo -n "
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dummy
namespace: dummy
annotations:
kubernetes.io/ingress.class: "nginx"
configuration.konghq.com: sample-kong-ingress
spec:
rules:
- host: dummy.kong.example
http:
paths:
- path: "/"
backend:
serviceName: http-svc
servicePort: http" | kubectl apply -f -
```