I'm still new to Kubernetes and Lagom.
I need to invoke my Lagom microservice from an external server. To do that, I think that I need to expose my nginx-ingress for an external access, but I don't know how. Should I configure an "externalIPs"?
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "nginx-ingress"
},
"spec": {
"type": "LoadBalancer",
"ports": [
{
"port": 80,
"name": "http",
"targetPort": 8080
},
{
"port": 443,
"name": "https"
}
],
"externalIPs": [
"192.168.1.120"
],
"selector": {
"k8s-app": "nginx-ingress-lb"
}
}
}
Minikube creates a network for itself and the VM. You need to externally expose your service.
From Op's comment: You get port 30370
for your Service. You need to expose this port.
ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L \*:30370:0.0.0.0:30370
In Minikube, you would use the kubectl expose
command to expose the service for external access per https://kubernetes.io/docs/tutorials/stateless-application/hello-minikube/#create-a-service. Minikube is not used in production.
In production, you have three ways to create the nginx ingress service using kubernetes per https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types and expose it for external access:
LoadBalancer
service type which sets the ExternalIP
automatically. This is used when there is an external non-k8s, cloud-provider's load-balancer like CGE, AWS or Azure, and this external load-balancer would provide the ExternalIP
for the nginx ingress service.
ExternalIPs
per https://kubernetes.io/docs/concepts/services-networking/service/#external-ips.
NodePort
. In this approach, the service can be accessed from outside the cluster using NodeIP:NodePort/url/of/the/service
.
Along with the nginx ingress controller, you'll need an ingress resource too. Refer https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/complete-example for examples.