1

I have following configuration of a service:

apiVersion: v1
kind: Service
metadata:
  name: academy-backend-service
spec:
  selector:
    app: academy-backend-app
  type: NodePort
  ports:
    - port: 8081
      targetPort: 8081
      nodePort: 30081

Behind this service there is a deployment that runs a docker image of a spring boot application that expose port 8081. When I try to reach the application from browser on http://localhost:30081 I don't get anything (not reachable). However if I connect inside minikube cluster, the application is available on http:{servcieip}:8081. Any clues what is not configured properly? I thought that nodePort is enough.

NAME                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
academy-backend-service   NodePort    10.97.44.87      <none>        8081:30081/TCP   34m
Cosmin D
  • 639
  • 1
  • 11
  • 24
  • While Stack Overflow does permit certain questions about Kubernetes, we require that they (like all questions asked here) be specifically related to programming. This question does not appear to be specifically related to programming, but service configuration, which makes it off-topic here. You might be able to ask questions like this one on [sf] or [DevOps](https://devops.stackexchange.com/). – Turing85 Oct 30 '22 at 11:34

1 Answers1

1

Use NodePorts to expose the service nodePort on all nodes in the cluster.

From https://kubernetes.io/docs/concepts/services-networking/service/

NodePort: Exposes the Service on each Node's IP at a static port (the NodePort). To make the node port available, Kubernetes sets up a cluster IP address, the same as if you had requested a Service of type: ClusterIP.

If you want to expose your service outside the cluster, use LoadBalancer type:

LoadBalancer: Exposes the Service externally using a cloud provider's load balancer.

or use ingress-controller which is a reverse-proxy that routs traffics from outside to your cluster: https://github.com/kubernetes/ingress-nginx

Reda E.
  • 653
  • 3
  • 16