<p>I created a service via <code>kubectl expose deployment nginx</code></p>
<p>The command created this endpoint:</p>
<pre><code>root@k8scp:~# k get endpoints nginx -o yaml
apiVersion: v1
kind: Endpoints
metadata:
  annotations:
    endpoints.kubernetes.io/last-change-trigger-time: &quot;2022-01-25T20:39:38Z&quot;
  creationTimestamp: &quot;2022-01-25T20:39:38Z&quot;
  labels:
    app: nginx
  name: nginx
  namespace: default
  resourceVersion: &quot;294091&quot;
  uid: 675cdb2f-6dfe-4fd1-8880-05d43924edca
subsets:
- addresses:
  - ip: 172.16.171.70
    nodeName: worker
    targetRef:
      kind: Pod
      name: nginx-77c58f65f9-5pgfp
      namespace: default
      resourceVersion: &quot;192490&quot;
      uid: a175543a-4460-4f4e-9ff9-2e505a0821cf
  - ip: 172.16.171.71
    nodeName: worker
    targetRef:
      kind: Pod
      name: nginx-77c58f65f9-r7grc
      namespace: default
      resourceVersion: &quot;195670&quot;
      uid: 616d2044-212a-4956-a5f0-74b6852e0c83
  ports:
  - port: 8080
    protocol: TCP
</code></pre>
<p>In this case I know that the service nginx created the endpoints. But in a different environment I might not know this.</p>
<p>Is there a way to find the creator/controller for this endpoint?</p>
<p>Background: I am just playing/learning K8s on my laptop.</p>

guettli
<p>When you executed <code>kubectl expose deployment nginx</code> it does not only create the endpoint object but <strong>also</strong> created a service object called <code>nginx</code>. In Kubernetes, the endpoint is only supposed to be referenced only by service to get the IP addresses of the Pods. Applications are not supposed(they can) to directly talk to the endpoints. The endpoint is created by using the selector field of the service and all the pods matching the selector will get added to the list of endpoints.</p>
<p>This command should result in the name of the &quot;service&quot;(parent object) which is managing the endpoint named &quot;nginx&quot;</p>
<pre><code>kubectl get svc -l $(kubectl get ep nginx  --show-labels --no-headers |awk '{print $NF}')
</code></pre>
