I'm using minikube version: v1.25.1, win10, k8s version 1.22
There is 1 node, 2 pods on it: main and front, 1 service - svc-main.
I'm trying to exec into front and call main thru service and see some msg confirming connection is ok.
main.yaml:
apiVersion: v1
kind: Pod
metadata:
labels:
app: main
name: main
namespace: default
spec:
containers:
- name: main
image: nginx
command: ["/bin/sh","-c"]
args: ["while true; do echo date; sleep 2; done"]
front.yaml:
apiVersion: v1
kind: Pod
metadata:
labels:
app: front
name: front
spec:
containers:
- image: nginx
name: front
command:
- /bin/sh
- -c
- while true; echo date; sleep 2; done
service is created like this:
k expose pod ngin --name=svc-main --type=ClusterIP --port=80 --target-port=80
k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc-main ClusterIP 10.104.26.249 <none> 80:31775/TCP 11m
When I try to curl from inside front it says "Could not resolve host: svc-main"
k exec front -it -- sh
curl svc-main:80
or this
curl http://svc-main:80
curl 10.104.26.249:80
I tried the port 31775, same result. What am I doing wrong?!