Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connecting to the kubernetes service using curl cmd #8191

Closed
vasanthakumars98 opened this issue May 18, 2020 · 10 comments
Closed

connecting to the kubernetes service using curl cmd #8191

vasanthakumars98 opened this issue May 18, 2020 · 10 comments
Labels
co/docker-driver Issues related to kubernetes in container kind/support Categorizes issue or PR as a support question. os/linux

Comments

@vasanthakumars98
Copy link

minikube start --driver=docker --force

kubectl apply -f kubedemo.yaml

NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/smef-567b56d6ff-lcjnk 1/1 Running 0 34m 172.18.0.6 minikube

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/kubernetes ClusterIP 10.96.0.1 443/TCP 68m
service/smef NodePort 10.110.128.125 8080:30491/TCP 34m app=smef

NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/smef 1/1 1 1 34m smef gcr.io/google-samples/node-hello:1.0 app=smef

NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
replicaset.apps/smef-567b56d6ff 1 1 1 34m smef gcr.io/google-samples/node-hello:1.0 app=smef,pod-template-hash=567b56d6ff

kubectl describe services

Name: smef
Namespace: default
Labels:
Annotations: Selector: app=smef
Type: NodePort
IP: 10.110.128.125
Port: 8080/TCP
TargetPort: 8080/TCP
NodePort: 30491/TCP
Endpoints: 172.18.0.6:8080
Session Affinity: None
External Traffic Policy: Cluster
Events:

root@vasanth:/home/vasanth/Desktop/k8's# curl 172.18.0.6:8080
curl: (7) Failed to connect to 172.18.0.6 port 8080: No route to host

i cant even acces this from the internet
This is my yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
name: smef
labels:
app: smef
spec:
replicas: 1
selector:
matchLabels:
app: smef
template:
metadata:
labels:
app: smef
spec:
#volumes:
# - name: storage
# persistentVolumeClaim:
# claimName: creating-claim
containers:
- name: smef
image: gcr.io/google-samples/node-hello:1.0
ports:
- containerPort: 8080
name: smef
# volumeMounts:
#- mountPath: "/vasanth/data echo > hi"
# name: storage
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"

apiVersion: v1
kind: Service
metadata:
name: smef
spec:
type: NodePort
ports:

  • port: 8080
    selector:
    app: smef

how can i acces this service

@afbjorklund
Copy link
Collaborator

afbjorklund commented May 18, 2020

If you use the docker driver on a VM platform (like Mac or Win), you need to tunnel the ports.

@afbjorklund afbjorklund added triage/duplicate Indicates an issue is a duplicate of other open issue. co/docker-driver Issues related to kubernetes in container labels May 18, 2020
@vasanthakumars98
Copy link
Author

hi @afbjorklund
how to tunnel the port ?
in yaml file ?

@afbjorklund
Copy link
Collaborator

afbjorklund commented May 18, 2020

See https://minikube.sigs.k8s.io/docs/start/ under "Deploy applications"

@vasanthakumars98
Copy link
Author

i have exposed but even though i can access.
but using minikube service smef --url
this url is coming http://172.17.0.3:30871/
and it can be access

@vasanthakumars98
Copy link
Author

kubectl describe service smef

Name: smef
Namespace: default
Labels:
Annotations: Selector: app=smef
Type: NodePort
IP: 10.101.148.177
Port: 8080/TCP
TargetPort: 8080/TCP
NodePort: 30871/TCP
Endpoints: 172.18.0.6:8080
Session Affinity: None
External Traffic Policy: Cluster
Events:
root@vasanth:/home/vasanth/Desktop/k8's# curl 172.18.0.6
curl: (7) Failed to connect to 172.18.0.6 port 80: No route to host

while using endpoint ip i cant access

@afbjorklund
Copy link
Collaborator

NodePort only works on Linux, when using the Docker driver

@priyawadhwa priyawadhwa added the kind/support Categorizes issue or PR as a support question. label May 18, 2020
@vasanthakumars98
Copy link
Author

hi @afbjorklund
am using ubuntu its also like a linux right then how can use endpoint ip to access the services in the chrome as well as in terminal using curl cmd ?

@afbjorklund
Copy link
Collaborator

am using ubuntu its also like a linux

ah, ok. Then the IP should be readily available, for instance through your port 30871 above.

You just seemed to have picked the wrong port, i.e. target port 8080 rather than node port 30491

so something like http://172.18.0.6:30491/ should have worked to access it, sorry about the noise

If you report your minikube version and OS next time, there will be less chance for such confusion

@afbjorklund afbjorklund added os/linux and removed triage/duplicate Indicates an issue is a duplicate of other open issue. labels May 19, 2020
@vasanthakumars98
Copy link
Author

hi @afbjorklund
is there ant possible to deploy and access dashboard using none driver ?
i have enabled dashboard but in i cant access

@afbjorklund
Copy link
Collaborator

There is nothing special when using the "none" driver, maybe that the VM might be missing a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/docker-driver Issues related to kubernetes in container kind/support Categorizes issue or PR as a support question. os/linux
Projects
None yet
Development

No branches or pull requests

3 participants