Kubernetes: Unable to connect to the server

2/28/2017

I am following the Kubernetes guide here: https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-ram-container/

When I run this command:

kubectl create -f http://k8s.io/docs/tasks/configure-pod-container/cpu-ram.yaml

About 30 seconds later, I get this message:

Unable to connect to the server: dial tcp 172.17.0.1:4321: i/o timeout

I have tried lots of suggestions on the web (including here on Stack Overflow), but can't figure it out. I am using Google Cloud Shell on Google Cloud Platform and trying to set up Kubernetes (via the official Kubernetes guides on their website). Here is the output of gcloud info:

Google Cloud SDK [145.0.0]
Platform: [Linux, x86_64]
Python Version: [2.7.9 (default, Jun 29 2016, 13:08:31)  [GCC 4.9.2]]
Python Location: [/usr/bin/python2]
Site Packages: [Disabled]
Installation Root: [/google/google-cloud-sdk]
Installed Components:
  kubectl: []
  app-engine-python: [1.9.50]
  pubsub-emulator: [2017.02.07]
  gsutil-nix: [4.18]
  gsutil: [4.22]
  cloud-datastore-emulator: [1.2.1]
    disable_update_check: [True]
  app-engine-java: [1.9.49]
  gcloud: []
  core: [2017.02.21]
  datalab: [20170215]
  gcloud-deps: [2017.02.21]
  beta: [2016.01.12]
  bq: [2.0.24]
  alpha: [2016.01.12]
  datalab-nix: [20170105]
  core-nix: [2016.11.07]
  app-engine-go-linux-x86_64: [1.9.50]
  app-engine-go: []
  app-engine-php: [ ]
  gcloud-deps-linux-x86_64: [2017.02.21]
  gcd-emulator: [v1beta3-1.0.0]
  kubectl-linux-x86_64: [1.5.2]
  bq-nix: [2.0.24]
System PATH: [/google/google-cloud-sdk/bin:/usr/local/nvm/versions/node/v6.9.2/bin:/home/_removed_/gopath/bin:/google/gopath/bin:/usr/local/go/bin:/gradle-2.12/bin:/apache-maven-3.3.9/bin:/google/google-cloud-sdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/google/go_appengine:/google/google_appengine]
Cloud SDK on PATH: [True]
Kubectl on PATH: [/google/google-cloud-sdk/bin/kubectl]

WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
  /google/google_appengine/endpointscfg.py
  /google/go_appengine/dev_appserver.py
  /google/google_appengine/dev_appserver.py
  /google/go_appengine/endpointscfg.py

Installation Properties: [/google/google-cloud-sdk/properties]
User Config Directory: [/tmp/tmp.XKaUThqtJm]
Active Configuration Name: [cloudshell-29694]
Active Configuration Path: [/tmp/tmp.XKaUThqtJm/configurations/config_cloudshell-29694]

Account: [_removed_@gmail.com]
Project: [_removed_]

Current Properties:
  [metrics]
    environment: [devshell]
  [core]
    check_gce_metadata: [False]
    project: [_removed_]
    account: [_removed_@gmail.com]
    disable_usage_reporting: [False]
  [compute]
    region: [us-central1]
    gce_metadata_read_timeout_sec: [5]
    zone: [us-central1-b]
  [component_manager]
    disable_update_check: [True]

Logs Directory: [/tmp/tmp.XKaUThqtJm/logs]
Last Log File: [/tmp/tmp.XKaUThqtJm/logs/2017.02.27/21.51.45.088860.log]
-- Daniel Malone
google-cloud-platform
google-cloud-shell
google-kubernetes-engine
kubernetes

1 Answer

3/1/2017

You're trying to schedule a Pod in a cluster which does not exist. Prior to creating resources you need to provision the underlying cluster.

I kindly suggest you read the documentation at https://k8s.io in order to understand Kubernetes and its building blocks. The documentation is also a good place to find out how to provision a Kubernetes cluster. On Google Cloud this is pretty trivial.

-- Antoine Cotten
Source: StackOverflow