Cannot set up Kubernetes local cluster via Docker

I followed http://kubernetes.io/docs/getting-started-guides/docker/. Here are the commands I literally run:

export K8S_VERSION=$(curl -sS https://storage.googleapis.com/kubernetes-release/release/stable.txt)
export ARCH=amd64
docker run -d \
--volume=/:/rootfs:ro \
--volume=/sys:/sys:rw \
--volume=/var/lib/docker/:/var/lib/docker:rw \
--volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
--volume=/var/run:/var/run:rw \
--net=host \
--pid=host \
--privileged \
gcr.io/google_containers/hyperkube-${ARCH}:${K8S_VERSION} \
/hyperkube kubelet \
    --containerized \
    --hostname-override=127.0.0.1 \
    --api-servers=http://localhost:8080 \
    --config=/etc/kubernetes/manifests \
    --cluster-dns=10.0.0.10 \
    --cluster-domain=cluster.local \
    --allow-privileged --v=2
curl -sSL "http://storage.googleapis.com/kubernetes-release/release/v1.2.0/bin/linux/amd64/kubectl" > /usr/bin/kubectl
chmod +x /usr/bin/kubectl
kubectl config set-cluster test-doc --server=http://localhost:8080
kubectl config set-context test-doc --cluster=test-doc
kubectl config use-context test-doc

Then I followed https://github.com/kubernetes/kubernetes/tree/release-1.2/examples/nodesjs-mongodb:

  • Stop Minecraft server in Docker when container stops
  • Docker port binding error
  • how does Docker Embedded DNS resolver work?
  • Can't connect to database with docker-compose with mysql and php 7
  • Rails docker - Bundle with custom path not able to access gems
  • Docker compose error while creating a portus demo environment why?
  • kubectl create -f web-service.yaml
    kubectl create -f web-controller.yaml
    kubectl create -f mongo-service.yaml
    kubectl create -f mongo-controller.yaml
    

    I have a Python flask app, so I replace the image with my own and the args with ['export DOCKER=True && cd commandcenter/ && python app.py']

    This is the reult of kubectl get services:

    NAME         CLUSTER-IP   EXTERNAL-IP   PORT(S)     AGE
    kubernetes   10.0.0.1     <none>        443/TCP     3d
    mongo        10.0.0.167   <none>        27017/TCP   14m
    web          10.0.0.119                 80/TCP      6m
    

    Reult of kubectl get pods:

    NAME                     READY     STATUS    RESTARTS   AGE
    k8s-etcd-127.0.0.1       1/1       Running   0          3d
    k8s-master-127.0.0.1     4/4       Running   0          3d
    k8s-proxy-127.0.0.1      1/1       Running   0          3d
    mongo-controller-3b8q5   1/1       Running   0          5m
    nginx-198147104-9w444    1/1       Running   0          25m
    web-controller-6nzpn     1/1       Running   3          2m
    web-controller-uot1s     1/1       Running   3          2m
    

    Result of kubectl logs web-controller-6nzpn:

    DEBUG 2016-06-09 17:57:49,279 Starting up server 
    INFO 2016-06-09 17:57:49,285  * Running on http://0.0.0.0:3000/ (Press CTRL+C to quit)
    

    Result of kubectl get nodes:

    NAME        STATUS    AGE
    127.0.0.1   Ready     3d
    

    Result of docker ps:

    CONTAINER ID        IMAGE                                             COMMAND                  CREATED             STATUS              PORTS                      NAMES
    78330abb3cbc        gcr.io/google_containers/pause:2.0                "/pause"                 5 minutes ago       Up 5 minutes                                   k8s_POD.6079054c_web-controller-6nzpn_default_208f7237-2e65-11e6-98e4-f80f41fc0776_e72a59d6
    8f41e68e0dbb        gcr.io/google_containers/pause:2.0                "/pause"                 5 minutes ago       Up 5 minutes                                   k8s_POD.6079054c_web-controller-uot1s_default_208f587f-2e65-11e6-98e4-    f80f41fc0776_6861905a
    d0d8696f8757        mongo                                             "/entrypoint.sh mongo"   8 minutes ago       Up 8 minutes                                   k8s_mongo.a8042bbb_mongo-controller-3b8q5_default_b21552c0-2e64-11e6-98e4-f80f41fc0776_835c7956
    83701f56b225        gcr.io/google_containers/pause:2.0                "/pause"                 9 minutes ago       Up 9 minutes        0.0.0.0:27017->27017/tcp   k8s_POD.683503f7_mongo-controller-3b8q5_default_b21552c0-2e64-11e6-98e4-f80f41fc0776_a07aaf2b
    bdf64b18dbf0        nginx                                             "nginx -g 'daemon off"   29 minutes ago      Up 29 minutes                                  k8s_nginx.cd4c2839_nginx-198147104-9w444_default_dab5019f-2e61-11e6-98e4-f80f41fc0776_04c0a7dc
    15cfd30b3280        gcr.io/google_containers/pause:2.0                "/pause"                 29 minutes ago      Up 29 minutes                                  k8s_POD.cf58006d_nginx-198147104-9w444_default_dab5019f-2e61-11e6-98e4-f80f41fc0776_aae25ba3
    4409962a7123        gcr.io/google_containers/hyperkube:v0.21.2        "/hyperkube proxy --m"   44 minutes ago      Up 44 minutes                                  stupefied_yonath
    0a8b91c41e68        gcr.io/google_containers/hyperkube-amd64:v1.2.4   "/setup-files.sh IP:1"   49 minutes ago      Up 49 minutes                                  k8s_setup.eb843218_k8s-master-127.0.0.1_default_721118f359852533089009890ac21208_22bec1b0
    6a91a6e7620c        gcr.io/google_containers/hyperkube-amd64:v1.2.4   "/hyperkube scheduler"   49 minutes ago      Up 49 minutes                                  k8s_scheduler.dbfcc0_k8s-master-127.0.0.1_default_721118f359852533089009890ac21208_feeb19b7
    4ca45bc03c89        gcr.io/google_containers/hyperkube-amd64:v1.2.4   "/hyperkube apiserver"   49 minutes ago      Up 49 minutes                                  k8s_apiserver.1082c1e0_k8s-master-127.0.0.1_default_721118f359852533089009890ac21208_16592f39
    a5a4cf124d74        gcr.io/google_containers/hyperkube-amd64:v1.2.4   "/hyperkube controlle"   49 minutes ago      Up 49 minutes                                  k8s_controller-manager.76914b67_k8s-master-127.0.0.1_default_721118f359852533089009890ac21208_d2dffc43
    3f0c3c342a12        gcr.io/google_containers/etcd:2.2.1               "/usr/local/bin/etcd "   49 minutes ago      Up 49 minutes                                  k8s_etcd.7e452b0b_k8s-etcd-127.0.0.1_default_1df6a8b4d6e129d5ed8840e370203c11_82b244e9
    3bca02d310dc        gcr.io/google_containers/hyperkube-amd64:v1.2.4   "/hyperkube proxy --m"   49 minutes ago      Up 49 minutes                                  k8s_kube-proxy.a1014855_k8s-proxy-127.0.0.1_default_0cda4a663a246109121ac68b3c7e82b7_c610ef5f
    cf83efe4cf4e        gcr.io/google_containers/pause:2.0                "/pause"                 49 minutes ago      Up 49 minutes                                  k8s_POD.6059dfa2_k8s-master-127.0.0.1_default_721118f359852533089009890ac21208_2864939a
    51b02dab5bcd        gcr.io/google_containers/pause:2.0                "/pause"                 49 minutes ago      Up 49 minutes                                  k8s_POD.6059dfa2_k8s-etcd-127.0.0.1_default_1df6a8b4d6e129d5ed8840e370203c11_9cf2fc4d
    5256fcfbd3d2        gcr.io/google_containers/pause:2.0                "/pause"                 49 minutes ago      Up 49 minutes                                  k8s_POD.6059dfa2_k8s-proxy-127.0.0.1_default_0cda4a663a246109121ac68b3c7e82b7_86be1d4f
    b41dfb03d56d        gcr.io/google_containers/hyperkube-amd64:v1.2.4   "/hyperkube kubelet -"   50 minutes ago      Up 50 minutes                                  kickass_fermat
    

    The machine has a public IP address, and my goal is to access the demo website from outside. I can access mongo via http://public_IP_address:27017 and curl 10.0.0.167:27017, because as shown above, mongo has 0.0.0.0:27017->27017/tcp.However, when I run curl 10.0.0.119:3000, it is like an infinite loop and eventually it says time out. Why is that?

    Thus, my question is: how to expose web so that it also has a non-empty PORTS field?

    I do not have much knowledge on networking, so any help is greatly appreciated. Thank you very much!

  • Can the Docker driver on OpenStack coexist with libvirt.LibvirtDriver?
  • UnknownHostException in Kubernetes-Container
  • How to pull a single image from any docker repository?
  • Apache not running automatically on docker compose up
  • Change Elastic Beanstalk Configuration To Docker
  • Best practice for connecting to a vpn though docker [closed]
  • One Solution collect form web for “Cannot set up Kubernetes local cluster via Docker”

    If you look at https://github.com/kubernetes/kubernetes/blob/release-1.2/examples/nodesjs-mongodb/web-service.yaml, you’ll see that the service type is LoadBalancer. This is intended to work with cloud providers like AWS and GCE.

    In your case, you need to expose services using NodePorts. Specify type: NodePort and nodePort: 3xxxx (some port greater than 30000) and you can access the service at <NodeIP>:NodePort.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.