What is the commands to check if a pod attached to any services?

vShyfur:
what is the commands to check if a pod attached to any services?

Mani:
We can get the pod label and check for any services having same label, below command helps
#kubectl get services -l <pod-label>
This is one way

vShyfur:
root@controlplane:~# k get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 54m
my-srv NodePort 10.97.193.254 <none> 80:32327/TCP 7s
root@controlplane:~# k get services -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 54m <none>
my-srv NodePort 10.97.193.254 <none> 80:32327/TCP 14s app=myapp
root@controlplane:~#
root@controlplane:~#
root@controlplane:~# k get services -l myapp
No resources found in default namespace.
root@controlplane:~#

vShyfur:
not working …

vShyfur:
found it. check the endpoinds

vShyfur:
root@controlplane:~# k get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 45m 10.244.0.4 controlplane <none> <none>
nginx1 1/1 Running 0 8m43s 10.244.0.5 controlplane <none> <none>
root@controlplane:~# k get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 62m
my-srv NodePort 10.97.193.254 <none> 80:32327/TCP 7m53s
root@controlplane:~#
root@controlplane:~# k describe services my-srv
Name: my-srv
Namespace: default
Labels: <none>
Annotations: <none>
Selector: app=myapp
Type: NodePort
IP Families: <none>
IP: 10.97.193.254
IPs: 10.97.193.254
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32327/TCP
Endpoints: 10.244.0.4:80,10.244.0.5:80
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>

Fernando Jimenez:

kubectl get endpoints my-srv

unnivkn:
endpoint ip should match with pod ip. k get ep,po -o wide

unnivkn:
k get svc,ep,po -o wide