If I have a domain name www.domain.com
registered and I have fresh kubernetes cluster up and running. I have successfully lauched Deployments
and Services
to expose the requirements.
The service is creating a LoadBalancer
on my GCE cluster and when I try to access my APP
through the the external IP its working.
But this is what I wanted to achieve ideally :
To route all the traffic for my apps as www.app.domain.com
, www.app2.domain.com
. Upon research I have found that I need an Ingress Controller
preferably NGINX
server, I have been try to do this and failing miserably.
This is the service exposing JSON for my deployments:
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": 'node-js-srv'
},
"spec": {
"type": 'LoadBalancer',
"label": {
'app': 'node-js-srv'
},
"ports": [
{
"targetPort": 8080,
"protocol": "TCP",
"port": 80,
"name": "http"
},
{
"protocol": "TCP",
"port": 443,
"name": "https",
"targetPort": 8080
}
],
"selector": {
"app": 'node-js'
},
}
}
GCE/GKE have already a
Ingress Controller
and you could use that one.You must specify your service as type
NodePort
and create a ressource from typeIngress
See: https://kubernetes.io/docs/user-guide/ingress/You find a example for GCE here https://github.com/kubernetes/ingress/tree/master/examples/deployment/gce
Service:
Ingress: