The problem:
I am configuring a Tyk Gateway and Dashboard based on the TykTechnologies/tyk-kubernetes repo:
I now wish to secure both the Gateway and Dashboard K8s services with TLS certificates.
I've purchased a certificate to secure the external URLs (https://api.example.com
and https://dashboard.example.com
) as below but the cert is invalid for the internal k8s service endpoints and so the dashboard and gateway can no longer speak internally:
$ kubectl logs deployment/tyk-dashboard
...
time="Jan 01 00:00:00" level=error msg="Request failed with error Get https://tyk-dashboard.tyk.svc.cluster.local:443/register/node: x509: certificate is valid for *.example.com, not tyk-dashboard.tyk.svc.cluster.local; retrying in 5s"
What I've done so far:
Modified the tyk.conf
and tyk_analytics.conf
to change the listen port and reference the certificates:
{
"listen_port": 443,
"notifications_listen_port": 5000,
"tyk_api_config": {
"Host": "https://tyk-gateway.tyk.svc.cluster.local",
"Port": "443",
...
"http_server_options": {
"use_ssl": true,
"server_name": "api.example.com",
"min_version": 771,
"certificates": [
{
"domain_name": "*.example.com",
"cert_file": "/etc/ssl/gateway-tls/tls.crt",
"key_file": "/etc/ssl/gateway-tls/tls.key"
}
]
},
...
I am mounting the certificates in the tyk pods via K8s TLS secrets (and similarly for the dashboard):
kubectl create secret tls tyk-gateway --cert=example.com.crt --key=example.com.key
And corresponding K8s deployment update:
...
ports:
- containerPort: 443
- containerPort: 5000
volumeMounts:
...
- name: tyk-gateway-tls
readOnly: true
mountPath: "/etc/ssl/gateway-tls"
volumes:
...
- name: tyk-gateway-tls
secret:
secretName: tyk-gateway