Where can I see list of services registered in Kubernetes Discovery?

12/23/2020

In case of using eureka (+ Spring Boot) you can reach special endpoint where list of currently registered instances can be found. E.g.: Instances currently registered with Eureka

Does Kubernetes service discovery have such endpoint or may be other mechanism to see all currently registered instances? UPD: Does kubernetes api have any possibilities to do this, may be via kubectl?

-- Alex
discovery
kubernetes
microservices
netflix-eureka
spring-cloud

3 Answers

12/23/2020

Kubernetes has an HTTP-based API that you can interact with in many ways (e.g.: kubectl), of course you can use curl too.
Here's how: Access Clusters Using the Kubernetes API

If you are curious about your pods, you can do:

  • kubectl get pods or kubectl get pods -o json
  • curl http://localhost:8080/api/v1/pods

If you mean services (and their registered targets):

  • kubectl get services or kubectl services pods -o json
  • curl http://localhost:8080/api/v1/services
-- Jonatan Ivanov
Source: StackOverflow

7/9/2021

I managed to solve problem after a while.

  1. Add endpoint in of your microservices. Example here
  2. Add roles to your kubernetes cluster:
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: yours
  name: service-reader
rules:
  - apiGroups: [""] # "" indicates the core API group
    resources: ["services"]
    verbs: ["get", "watch", "list"]

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: service-reader-pod
subjects:
  - kind: ServiceAccount
    name: default
    namespace: yours
roleRef:
  kind: ClusterRole
  name: service-reader
  apiGroup: rbac.authorization.k8s.io
-- Alex
Source: StackOverflow

12/23/2020

No. Eureka is a service discovery AND registration system. The spring cloud implementation of service discovery on kubernetes only reads from the kubernetes api. You could probably get the information via kubectl.

-- spencergibb
Source: StackOverflow