无法从 Kubernetes host-Openshift Origin-oc 获取 TCP 端口信息

Cannot get TCP port information from Kubernetes host-Openshift Origin-oc

我一直在关注 Openshift 的 Local Cluster Management 文档。 在我运行oc cluster up

之后
[root@user ~]# oc cluster up
Starting OpenShift using openshift/origin:v3.6.0 ...
-- Checking OpenShift client ... OK
-- Checking Docker client ... OK
-- Checking Docker version ... 
   WARNING: Docker version is 1.21, it needs to be >= 1.22
-- Checking for existing OpenShift container ... OK
-- Checking for openshift/origin:v3.6.0 image ... OK
-- Checking Docker daemon configuration ... OK
-- Checking for available ports ... FAIL
   Error: Cannot get TCP port information from Kubernetes host
   Caused By:
     Error: cannot create container using image openshift/origin:v3.6.0
     Caused By:
       Error: Error response from daemon: SHM size must be greater then 0
[root@ip-172-31-0-186 ~]# oc cluster up --loglevel=5
-- Checking OpenShift client ... 
-- Checking Docker client ... 
I0803 04:30:33.543172    1417 up.go:590] No Docker environment variables found. Will attempt default socket.
I0803 04:30:33.543221    1417 up.go:595] No Docker host (DOCKER_HOST) configured. Will attempt default socket.
-- Checking Docker version ... 
I0803 04:30:33.543240    1417 helper.go:114] Retrieving Docker version
I0803 04:30:33.554087    1417 helper.go:120] Docker version results: &types.Version{Version:"1.9.1", APIVersion:"1.21", GitCommit:"78ee77d/1.9.1", GoVersion:"go1.4.2", Os:"linux", Arch:"amd64", KernelVersion:"3.10.0-693.el7.x86_64", Experimental:false, BuildTime:""}
I0803 04:30:33.554126    1417 helper.go:124] APIVersion: 1.21
I0803 04:30:33.554158    1417 up.go:686] Checking that docker API version is at least 1.22

   WARNING: Docker version is 1.21, it needs to be >= 1.22
-- Checking for existing OpenShift container ... 
I0803 04:30:33.554181    1417 helper.go:171] Inspecting docker container "origin"
I0803 04:30:33.555084    1417 helper.go:175] Container "origin" was not found
-- Checking for openshift/origin:v3.6.0 image ... 
I0803 04:30:33.555101    1417 helper.go:143] Inspecting Docker image "openshift/origin:v3.6.0"
I0803 04:30:33.556444    1417 helper.go:146] Image "openshift/origin:v3.6.0" found: &types.ImageInspect{ID:"c6d16974c8a3a5da3ab799533daa2dbd54e56b1f0ebbad59345154fc8e836ff2", RepoTags:[]string{"docker.io/openshift/origin:v3.6.0"}, RepoDigests:[]string{}, Parent:"395d30169bc02cca2e7083926b0fd6f2e6b7034a6de41a811cce0ab7c7473fca", Comment:"", Created:"2017-08-01T18:34:13.736398725Z", Container:"ae53137cc1b98b2f93051589d6aee252e505ac82f8e7a31f5ab49bfc0e9dc91a", ContainerConfig:(*container.Config)(0xc420277b00), DockerVersion:"1.12.6", Author:"", Config:(*container.Config)(0xc4202e2120), Architecture:"amd64", Os:"linux", Size:611206034, VirtualSize:974248741, GraphDriver:types.GraphDriverData{Name:"devicemapper", Data:map[string]string{"DeviceId":"7", "DeviceName":"docker-202:2-25214823-c6d16974c8a3a5da3ab799533daa2dbd54e56b1f0ebbad59345154fc8e836ff2", "DeviceSize":"107374182400"}}, RootFS:types.RootFS{Type:"", Layers:[]string(nil), BaseLayer:""}}
-- Checking Docker daemon configuration ... 
I0803 04:30:33.556503    1417 helper.go:65] Retrieving Docker daemon info
I0803 04:30:33.681753    1417 helper.go:71] Docker daemon info: &types.Info{ID:"IITV:S6LY:XNQS:LA63:VAH6:POZR:RGCW:MFWK:OTI7:DEII:AQK5:FDC6", Containers:0, ContainersRunning:0, ContainersPaused:0, ContainersStopped:0, Images:6, Driver:"devicemapper", DriverStatus:[][2]string{[2]string{"Pool Name", "docker-202:2-25214823-pool"}, [2]string{"Pool Blocksize", "65.54 kB"}, [2]string{"Base Device Size", "107.4 GB"}, [2]string{"Backing Filesystem", ""}, [2]string{"Data file", "/dev/loop0"}, [2]string{"Metadata file", "/dev/loop1"}, [2]string{"Data Space Used", "1.091 GB"}, [2]string{"Data Space Total", "107.4 GB"}, [2]string{"Data Space Available", "18.09 GB"}, [2]string{"Metadata Space Used", "1.339 MB"}, [2]string{"Metadata Space Total", "2.147 GB"}, [2]string{"Metadata Space Available", "2.146 GB"}, [2]string{"Udev Sync Supported", "true"}, [2]string{"Deferred Removal Enabled", "false"}, [2]string{"Deferred Deletion Enabled", "false"}, [2]string{"Deferred Deleted Device Count", "0"}, [2]string{"Data loop file", "/var/lib/docker/devicemapper/devicemapper/data"}, [2]string{"Metadata loop file", "/var/lib/docker/devicemapper/devicemapper/metadata"}, [2]string{"Library Version", "1.02.140-RHEL7 (2017-05-03)"}}, SystemStatus:[][2]string(nil), Plugins:types.PluginsInfo{Volume:[]string(nil), Network:[]string(nil), Authorization:[]string(nil)}, MemoryLimit:true, SwapLimit:true, KernelMemory:false, CPUCfsPeriod:true, CPUCfsQuota:true, CPUShares:false, CPUSet:false, IPv4Forwarding:true, BridgeNfIptables:true, BridgeNfIP6tables:true, Debug:false, NFd:15, OomKillDisable:true, NGoroutines:25, SystemTime:"2017-08-03T04:30:33.681150233-04:00", ExecutionDriver:"native-0.2", LoggingDriver:"json-file", CgroupDriver:"", NEventsListener:0, KernelVersion:"3.10.0-693.el7.x86_64", OperatingSystem:"Red Hat Enterprise Linux Server 7.4 (Maipo)", OSType:"", Architecture:"", IndexServerAddress:"https://index.docker.io/v1/", RegistryConfig:(*registry.ServiceConfig)(0xc4210fb700), NCPU:2, MemTotal:3973541888, DockerRootDir:"/var/lib/docker", HTTPProxy:"", HTTPSProxy:"", NoProxy:"", Name:"ip-172-31-0-186.us-west-2.compute.internal", Labels:[]string(nil), ExperimentalBuild:false, ServerVersion:"1.9.1", ClusterStore:"", ClusterAdvertise:"", SecurityOptions:[]string(nil)}
I0803 04:30:33.681847    1417 helper.go:42] Looking for "172.30.0.0/16" in []*registry.NetIPNet{(*registry.NetIPNet)(0xc4210f1a10), (*registry.NetIPNet)(0xc4210f1a70)}
I0803 04:30:33.681859    1417 helper.go:46] Found "172.30.0.0/16"
-- Checking for available ports ... 
I0803 04:30:33.681920    1417 run.go:181] Creating container named ""
config:
  image: openshift/origin:v3.6.0
  entry point:
    /bin/bash
  command:
    -c
    cat /proc/net/tcp && ( [ -e /proc/net/tcp6 ] && cat /proc/net/tcp6 || true)

host config:
  pid mode: host
  user mode: 
  network mode: host

FAIL
   Error: Cannot get TCP port information from Kubernetes host
   Caused By:
     Error: cannot create container using image openshift/origin:v3.6.0
     Caused By:
       Error: Error response from daemon: SHM size must be greater then 0

我已将 kubernetes 配置文件放在 .kube/config 中。仍然遇到同样的错误。 Kubernetes 集群应该在同一台机器上?

UPDATE-1

  1. docker docs

  2. 安装最新版本
  3. 解决依赖关系,安装container-selinux (sudo yum install ftp://fr2.rpmfind.net/linux/centos/7.3.1611/extras/x86_64/Packages/container-selinux-2.9-4.el7.noarch.rpm)

  4. 在我尝试使用 oc cluster up 启动集群之后。这次,它在 docker 配置失败。

    [root@ip-172-31-0-186 ~]# oc 集群起来 使用 openshift/origin:v3.6.0 启动 OpenShift ... -- 检查 OpenShift 客户端 ... OK -- 检查 Docker 客户端 ... OK -- 检查 Docker 版本 ... OK -- 检查现有的 OpenShift 容器...确定 -- 正在检查 openshift/origin:v3.6.0 图像 ... OK -- 正在检查 Docker 守护程序配置...失败 错误:未在 Docker 守护程序上检测到 --insecure-registry 参数 解决方案:

    确保 Docker 守护程序是 运行 以下参数: --insecure-registry 172.30.0.0/16

文档说,更新 /etc/sysconf/docker 中的 --insecure-registry 172.30.0.0/16。但是对于 docker 的新版本,该位置没有文件。我以任何方式创建和更新了 /etc/sysconf/docker。但是还是出现上面的错误。

好的,问题是注册表配置不安全。在 /etc/docker 中的 daemon.json 中使用以下配置指定不安全注册表

{
   "insecure-registries": [
     "172.30.0.0/16"
   ]
}

这也是最新的 docker。

对于任何特定版本的 Kubernetes 或 OpenShift,受支持的 Docker 版本稍有落后。

所以我建议您安装 docker 而不是 docker 文档中的最新版本。但是使用 linux 发行版的包管理器进行安装。对于 Fedora 和 CentOS 只需执行:

sudo yum install -y docker

完成后,所有依赖项管理都将得到处理,您无需手动安装任何其他内容。

现在您已经使用包管理器安装了 docker,您将找到 /etc/sysconfig/docker。您可以添加该行 --insecure-registry 172.30.0.0/16.

HTH.