GoogleContainerTools / kubehost

Expose web services directly on GKE nodes during development.
Apache License 2.0
115 stars 16 forks source link

Failed to set up again after deleting an existing setup #8

Closed ahmetb closed 5 years ago

ahmetb commented 5 years ago

I was basically playing with kubehost bind, and I had some services bind'ed with that.

Then I decided to nuke everything with kubectl delete deploy,service --all.

Next time I brought up a sample container and did kubehost bind, it no longer worked.

Repro steps

➜  ~ kubectl run hello-server --image gcr.io/google-samples/hello-app:1.0 --port 8080
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/hello-server created
➜  ~ kubectl expose deploy hello-server
service/hello-server exposed
$ kubehost bind hello-server
NAME           TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
hello-server   ClusterIP   10.19.255.65   <none>        8080/TCP   16m
Creating hostPort deployment 'hello-server-hostport' for service 'hello-server' (TCP:8080).
kubectl run --generator=deployment/apps.v1beta1 is DEPRECATED and will be removed in a future version. Use kubectl create instead.
deployment.apps/hello-server-hostport created
Waiting for available replicas of deployment 'hello-server-hostport'
Creating ingress firewall rule from TCP:8080 to instances with tag gke-demo-1b59f56c-node.
Creating firewall...⠧Created [https://www.googleapis.com/compute/v1/projects/ahmetb-samples-playground/global/firewalls/default-hello-server-rule].
Creating firewall...done.
NAME                       NETWORK  DIRECTION  PRIORITY  ALLOW     DENY  DISABLED
default-hello-server-rule  default  INGRESS    1000      tcp:8080        False
Service exposed on 35.184.7.16
curl http://35.184.7.16/
curl: (7) Failed to connect to 35.184.7.16 port 80: Connection refused
$ kubectl get nodes,deployment,svc
NAME                                       STATUS   ROLES    AGE    VERSION
node/gke-demo-default-pool-8ada0d4e-4g7m   Ready    <none>   112d   v1.10.4-gke.0
node/gke-demo-default-pool-8ada0d4e-5tpw   Ready    <none>   112d   v1.10.4-gke.0
node/gke-demo-default-pool-8ada0d4e-86gx   Ready    <none>   112d   v1.10.4-gke.0
node/gke-demo-default-pool-8ada0d4e-8nvn   Ready    <none>   112d   v1.10.4-gke.0
node/gke-demo-default-pool-8ada0d4e-hm8d   Ready    <none>   112d   v1.10.4-gke.0

NAME                                          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.extensions/hello-server            1         1         1            1           3m
deployment.extensions/hello-server-hostport   1         1         1            1           3m

NAME                   TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/hello-server   ClusterIP   10.19.248.190   <none>        8080/TCP   3m
service/kubernetes     ClusterIP   10.19.240.1     <none>        443/TCP    3m
WilliamDenniss commented 5 years ago

It worked, it just bound to port 8080.

$ curl "http://35.184.7.16:8080/"
Hello, world!
Version: 1.0.0
Hostname: hello-server-7cdbcc599b-7j7s9

If you expose your service with a clusterIP on port 80, then you'll get the behavior you expected.

ahmetb commented 5 years ago

I think the script should print the port number at the end then?