What I'm trying to do
Create a Kubernetes environment with a single API gateway service that is mapped to a DNS address.
What I have done:
1) I went to AWS Route53 service and created a subdomain.
2) That subdomain seems to have a static IP. I got this IP by pinging the domain name.
3) I have set up a Kubernetes cluster on AWS with kops.
4) I have a gateway service who's endpoints hit microserviecs within the k8s infrastructure.
This service is of type LoadBalancer
, where the loadBalancerIP
is equal to the static IP from above.
The problem:
With the above setup, the service fails to create with Failed to ensure load balancer for service default/gateway-service: LoadBalancerIP cannot be specified for AWS ELB
.
So then I go reading what look like pretty good resources about K8s Ingress (Also) and an Nginx reverse proxy service. (And this one at the end) (Also this one).
My error has also been asked before as well, and again the answer seems to put another layer between my API gateway and the outside world.
Then after reading a lot about Nginx Ingress controllers, I'm really confused.
My questions
a) Is there a bigger reason to have another layer between the gateway and the outside world apart from compatibility?
b) Would what I tried work in Google Cloud Platform (Is this an AWS deployment specific problem)
c) Nginx ingress controller... What is the difference between an Nginx reverse proxy and the Kubernetes Ingress service? Because to me the words seem to be used interchangeably here.
d) There seem to be so many ways to do this, what is the current best (and easiest) method?
EDIT:
I implemented option-1 of Jonah's answer. Here are the configs in case someone wants something to copy paste.
gateway-service.yaml:
apiVersion: v1
kind: Service
metadata:
name: gateway-service
spec:
ports:
- name: "gateway"
port: 80
targetPort: 5000
selector:
app: "gateway"
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: "gateway"
spec:
replicas: 1
template:
metadata:
labels:
app: "gateway"
spec:
containers:
- image: <account_nr>.dkr.ecr.us-east-1.amazonaws.com/gateway
imagePullPolicy: Always
name: "gateway"
ports:
- containerPort: 5000
protocol: "TCP"
Then, create the subdomain in AWS Route53:
1) Create domain
2) New Record Set
3) Type A
(IPv 4)
4) Alias yes
5) Select the Alias target which matches the Service's external endpoint. (kubectl describe services gateway-service | grep LoadBalancer
)