Reputation: 120998
I have an endpoints
that I can see via (for example) :
kubectl get endpoints busybox-service
This endpoints is "backed" by a service
:
kubectl get services busybox-service
Is there a way for me via the endpoints
object, to find the "backing" service, without finding it by name?
What I mean by that, is having just the information from (for example):
kubectl get endpoints busybox-service -o=json
or anything like that, to be able to tell what the metadata.uid
of the service is?
So, if I do : kubectl get endpoints busybox-service -o=json
, I would get:
"metadata": {
"annotations": {
"endpoints.kubernetes.io/last-change-trigger-time": "2023-03-19T19:40:08Z"
},
"creationTimestamp": "2023-03-19T19:40:08Z",
"labels": {
"a": "b"
},
"name": "busybox-service",
"namespace": "default",
"resourceVersion": "277476",
"uid": "8d76841b-ad74-4697-8d47-e7449b2cea24"
}
that is, I get the uid
of the endpoints
: "uid": "8d76841b-ad74-4697-8d47-e7449b2cea24"
. Is there an extended call of some kind to the endpoints that would give me the uid
of the service that this endpoints is based on.
Something like this does not exist, but may be there is a certain call that I miss:
"metadata": {
"annotations": {
"endpoints.kubernetes.io/last-change-trigger-time": "2023-03-19T19:40:08Z"
},
"creationTimestamp": "2023-03-19T19:40:08Z",
"labels": {
"a": "b"
},
"name": "busybox-service",
"namespace": "default",
"resourceVersion": "277476",
"uid": "8d76841b-ad74-4697-8d47-e7449b2cea24"
"ownerReference": "<UID_OF_THE_SERVICE>"
}
Notice the last field: "ownerReference": "<UID_OF_THE_SERVICE>"
- in reality it does not exist, but may be I miss some kind of a call that would give me this information.
Thank you.
Upvotes: 0
Views: 398
Reputation: 1012
Endpointslice object may suit this kind of requirement as it has the ownerRefernce
metadata and also the annotations like kubernetes.io/servie-name
and endpointslice.kubernetes.io/managed-by
which helps to get the source metadata.
endpointslice.kubernetes.io/managed-by
which can be used to indicate controller or operator which is
managing the Endpointslice
object.You can use kubectl describe command to get the details of ownerReferences and annotations as shown here
ownerReferences:
$ kubectl get endpointslice <endpointslice-name> -o=jsonpath='{.metadata.ownerReferences}'
Annotations:
$ kubectl describe enpointslice <endpointslice-name> | grep kubernetes.io/servie-name
$ kubectl describe enpointslice <endpointslice-name> | grep endpointslice.kubernetes.io/managed-by
For more detailed information refer to these documents Endpointslice, Ownerships
Upvotes: 1