Closed gheibia closed 7 years ago
Testing this with a busybox image has the same problem.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: bbd
spec:
template: # create pods using pod definition in this template
metadata:
labels:
app: bba
spec:
containers:
- name: bb
image: busybox:latest
command:
- sleep
- "3600"
---
apiVersion: v1
kind: Service
metadata:
name: bbs
spec:
selector:
app: bba
ports:
- protocol: TCP
port: 80
nodePort: 30067
type: NodePort
Confirming the creation went ok:
$ kubectl get po
NAME READY STATUS RESTARTS AGE
bbd-318937977-c6sxg 1/1 Running 0 7m
$ kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
bbs 10.0.0.133 <nodes> 80:30067/TCP 7m
$ kubectl get ep
NAME ENDPOINTS AGE
bbs 172.17.0.8:80 7m
And making sure the DNS is up and running:
$ kubectl get rc --namespace=kube-system
NAME DESIRED CURRENT READY AGE
kube-dns-v20 1 1 1 14h
kubernetes-dashboard 1 1 1 14h
Now testing:
$ minikube ssh
$ curl -v http://10.0.0.133
> GET / HTTP/1.1
> Host: 10.0.0.133
> User-Agent: curl/7.50.1
> Accept: */*
>
< HTTP/1.0 404 Not Found
< Content-type: text/html
< Date: Wed, 22 Mar 2017 20:12:52 GMT
< Connection: close
<
<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>
<BODY><H1>404 Not Found</H1>
The requested URL was not found
</BODY></HTML>
$ curl -v http://bbs
* Couldn't resolve host 'bbs'
curl: (6) Couldn't resolve host 'bbs'
$
Could you try running kubectl exec <pod> -- nslookup bbs
and see if resolution works inside the pod?
It does:
$ kubectl exec bbd-318937977-c6sxg -- nslookup bbs
Server: 10.0.0.10
Address 1: 10.0.0.10 kube-dns.kube-system.svc.cluster.local
Name: bbs
Address 1: 10.0.0.133 bbs.default.svc.cluster.local
You won't be able to resolve services through their cluster VIPs. Instead you will only be able to access the services through the node ports in minikube if you're outside the cluster.
In this case, you could either do
curl $(minikube service userdeployment --url)
or
curl $(minikube ip):30061
which are both equivalent.
Some users have been using https://docs.traefik.io/user-guide/kubernetes/ to manage name resolution, or other options are discussed #38
Thanks. So what you're saying is that I can either use the NodePort from outside or use service name from inside pods, right?
Thats correct
Thanks! Closing since this isn't a bug, but a misunderstanding.
This a BUG REPORT.
Minikube version: v0.17.1 Environment:
What happened: After creating a service, from within cluster I can access it by its VIP, but not its name.
What you expected to happen: To be able to access the service through its name. How to reproduce it: Use the following Yaml file to create a deployment and its service, ssh into the cluster and hit the service by its name.
Anything else do we need to know: The image in that file is being pulled from a private registry. I can't upload it elsewhere, but this is how I build it.
and the dockerfile is:
the image then is tagged and pushed to the private registry.