I create one pod with label:appenv and one service of type node port with a selector as appenv. But when I use kubectl get ep service-name it's showing "no endpoints"(means service is not connecting with that pod).
Here are my pod.yaml and service.yaml
pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod1
labels:
app: appenv
spec:
containers:
- name: app
image: aathith/lbt:v1
ports:
- name: app-port
containerPort: 8082
restartPolicy: Neverservice.yaml
apiVersion: v1
kind: Service
metadata:
name: app
spec:
selector:
app: appenv
type: NodePort
ports:
- name: http
port: 8082
targetPort: 8082
nodePort: 30082
protocol: TCPoutput for kubectl get po --show-labels 
output for kubectl get svc app
Your pod is in "Completed" state - that is the problem. It is not in state "Running". Why? Because command in container was finished with 0 exit code. In normal situation container's running command should not exit unless it's a Job or Cronjob. You see what I mean?