Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes ingress: How to enable HTTPS to backend service

A typical ingress with TLS configuration is like below:

apiVersion: extensions/v1beta1 kind: Ingress metadata: name: no-rules-map spec: tls: - secretName: testsecret backend: serviceName: s1 servicePort: 80

By default, the load balancer will talk to backend service in HTTP. Can I configure Ingress so that the communication between load balancer and the backend service is also HTTPS?

Update:

Found GLBC talking about enabling HTTPS backend for GCE Ingress. Excerpt from the document:

"Backend HTTPS

For encrypted communication between the load balancer and your Kubernetes service, you need to decorate the service's port as expecting HTTPS. There's an alpha Service annotation for specifying the expected protocol per service port. Upon seeing the protocol as HTTPS, the ingress controller will assemble a GCP L7 load balancer with an HTTPS backend-service with a HTTPS health check."

It is not clear if the load balancer accepts 3rd party signed server certificate, self-signed, or both. How CA cert should be configured on load balancer to do backend server authentication. Or it will bypass authentication check.

like image 440
aaskey Avatar asked Oct 17 '17 22:10

aaskey


People also ask

How do I make HTTPS ingress in Kubernetes?

Create a Kubernetes secret with server. crt certificate and server. key private key file. Add the TLS block to the ingress resource with the exact hostname used to generate cert that matches the TLS certificate.

How do I configure ingress TLS SSL certificates in Kubernetes?

Set the services type to ClusterIP. Choose the host names to provide access to the services. Provide SSL/TLS certificates that match the host names and package them as Kubernetes secrets. Create your own Ingress resource to expose the ClusterIP services on the host names that you have chosen.

Is ingress only for HTTP?

Ingress resource only supports rules for directing HTTP(S) traffic.


2 Answers

On ingress-nginx you can use the nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" annotation and point it to the HTTPS port on the service.

This is ingress controller specific and other ingress controllers might not provide the option (or provide an option that works differently)

With this setup, the ingress controller decrypts the traffic. (This allows the ingress controller to control things like ciphers and the certificate presented to the user and do path-based routing, which SSL passthrough does not allow)

It is possible to configure certificate validation with serveral other (ingress-nginx-specific) annotations: Docs

  • nginx.ingress.kubernetes.io/proxy-ssl-verify (it defaults to "off")
  • nginx.ingress.kubernetes.io/proxy-ssl-verify-depth
  • nginx.ingress.kubernetes.io/proxy-ssl-ciphers (ciphers, not validation related)
  • nginx.ingress.kubernetes.io/proxy-ssl-name (Override the name that the cert is checked against)
  • nginx.ingress.kubernetes.io/proxy-ssl-protocols (SSL / TLS versions)
  • nginx.ingress.kubernetes.io/proxy-ssl-server-name (SNI passthrough)
like image 85
Gert van den Berg Avatar answered Sep 23 '22 02:09

Gert van den Berg


Follow the instructions in "Backend HTTPS" section of GLBC, GCP HTTP(S) load balancer will build a HTTPS connection with the backend, traffic will be encrypted. There is no need to configure CA certificate on LB side (Actually you can't). This implies the load balancer will skip server certificate authentication.

like image 33
aaskey Avatar answered Sep 25 '22 02:09

aaskey