Lokesh Sinha:
root@controlplane:~# k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 14m
pod1 ClusterIP 10.102.31.8 <none> 8080/TCP 5m34s
root@controlplane:~# k run tmp --image=nginx:alpine --restart=Never --rm -it -- curl <http://pod1:8080>
curl: (7) Failed to connect to pod1 port 8080: Connection refused
pod "tmp" deleted
pod default/tmp terminated (Error)
root@controlplane:~#
What am I doing wrong? why is it not connecting to the svc?
Please someone help.
unnivkn:
try this first: k run tmp --image=nginx:alpine --restart=Never --rm -it – sh
curl --version
Lokesh Sinha:
k8s@terminal:~$ k run tmp --image=nginx:alpine --restart=Never --rm -it -- sh
If you don't see a command prompt, try pressing enter.
/ # curl --version
curl 7.76.1 (x86_64-alpine-linux-musl) libcurl/7.76.1 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.9 nghttp2/1.42.0
Release-Date: 2021-04-14
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets
/ #
unnivkn:
try this : k run tmp --image=nginx:alpine --restart=Never --rm -it – curl <ip-address-of POD1 here>
unnivkn:
k run tmp --image=nginx:alpine --restart=Never --rm -it – curl <ip-address-of Service here>: <service-port>
Ashok Kumar:
Can you try to do wget with busybox
kubectl run busybox --image busybox sleep 3600
kubectl exec -it busybox sh
wget -qO- http://<service_name>:<port>
Ashok Kumar:
If problem exists check your coredns
pod is perfectly running on kube-system
namespace
Lokesh Sinha:
I got this issue fixed.
Lokesh Sinha:
Sorry guys it was my problem, I exposed a port that was not used by the application in the pod. Once I exposed the correct port, it worked fine.
Lokesh Sinha:
Many thanks @unnivkn and @Ashok Kumar for your replies.