<p>I setup a kubernetes by kubeadm and everything is ok.
I just get a whim: how do I find out some pods or services dependent on the ports which started by kube-proxy on the localhost ?</p>

<pre><code>[root@k8s-node1 ~]# netstat -tnlp|grep 80
tcp        0      0 172.19.5.38:8080        0.0.0.0:*               LISTEN      13918/kube-proxy    
tcp        0      0 172.19.5.38:80          0.0.0.0:*               LISTEN      13918/kube-proxy 
</code></pre>

<p>I want to know which pod or service the 80 or 8080 belongs to ? assume i already forget which yaml file i submitted to the kubernetes.</p>

<p>thx</p>

adrian ding
<p>You can always <code>describe</code> objects in Kubernetes.</p>

<p>For example if you want to check what ports are using on your services you have to use command below.</p>

<pre><code>$ kubectl get svc -o wide --all-namespaces
NAMESPACE     NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE     SELECTOR
default       kubernetes   ClusterIP   10.96.0.1    &lt;none&gt;        443/TCP                  3m39s   &lt;none&gt;
kube-system   kube-dns     ClusterIP   10.96.0.10   &lt;none&gt;        53/UDP,53/TCP,9153/TCP   3m38s   k8s-app=kube-dns
</code></pre>

<p>If you want to check <code>Ports</code> from deployment you can use <code>kubectl describe deploy &lt;deploymentName&gt;</code> and grep it for context. It will work for <code>Pod</code> also </p>

<pre><code>$ kubectl describe deploy &lt;deploymentName&gt;| grep Port
    Port:         80/TCP
    Host Port:    0/TCP
</code></pre>

<p>In addition, if you dont remember what yaml has been used to create Pod/Deployment you can use <code>edit</code> to check.</p>

<pre><code>$ kubectl edit deployment &lt;deploymentName&gt; -o yaml
</code></pre>

<p>It will show YAML file (in VI) which was deployment based on and some additional statuses.</p>

<p>Let me know if this help or if you have any additional questions.</p>
