Open AmitKumarDas opened 5 years ago
Kubernetes has support for mapping external domains to internal services via Ingress objects. The Ingress object I'm using looks like this:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: doxsey-www
spec:
tls:
- hosts:
- "*.doxsey.net"
secretName: doxsey-net-tls
rules:
- host: www.doxsey.net
http:
paths:
- path: /
backend:
serviceName: doxsey-www
servicePort: 9002
This manifest declares how incoming HTTP traffic should be routed to backend services:
In addition to the Ingress object, we have to install an Ingress Controller.
This Controller is responsible for reading the ingress manifest rules and actually implementing the desired proxy behavior.
In other words, an Ingress manifest is merely a declarative intent.
The default ingress controller is the NGINX Ingress Controller, though there are many others.
Although it was a fun exercise to implement my own, you should probably use one of these.
There can be a lot of subtlety in handling all the edge cases, particularly when dealing with lots of services or rules, and those edge cases and bugs have probably been fixed in more widely used controllers.
https://www.doxsey.net/blog/how-to-build-a-custom-kubernetes-ingress-controller-in-go