Kubernetes is not discovering the service through feignclient

Hello all,

I created two spring boot services named servicea and serviceb, and I am calling the serviceb endpoint in servicea through feign client. if I deploy locally it is working fine as expected. but when I am deploying the same services in Kubernetes it is throwing 404 not found.

Error: service A failed with exception: status 404 reading ServiceBClient

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version:
Cloud being used: (put bare-metal if not on a public cloud)
Installation method:
Host OS:
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

Can you provide the yaml for the pods and services?

apiVersion: v1
kind: Pod
metadata:
name: servicea
labels:
app: servicea
spec:
containers:
- name: servicea
image:
ports:
- containerPort: 8085


kind: Service
apiVersion: v1
metadata:
name: servicea
labels:
app: servicea
annotations:
version: 10.0.0.0.1
spec:
selector:
app: servicea
type: NodePort
ports:
- name: port
protocol: TCP
nodePort: 30001
port: 8085
targetPort: 8085
sessionAffinity: ClientIP


apiVersion: v1
kind: Pod
metadata:
name: serviceb
labels:
app: serviceb
spec:
containers:
- name: serviceb
image:
ports:
- containerPort: 8086


kind: Service
apiVersion: v1
metadata:
name: serviceb
labels:
app: serviceb
annotations:
version: 10.0.0.0.1
spec:
selector:
app: serviceb
type: NodePort
ports:
- name: port
protocol: TCP
nodePort: 30002
port: 8086
targetPort: 8086
sessionAffinity: ClientIP

Hi Sunil,
how are you calling the service endpoints?

If your apps work locally then (as an example) you should be able to make a request to “serviceb” pod by doing something like this:

curl http://serviceb:8086/

If serviceb and servicea are in the same namespace.
Is that what you are doing?

Hi,

I am using feignclient for communication

What do the urls that you are using in feignclient look like?
Can you share a snippet of how you want servicea to talk to serviceb?