1

我正在尝试使用此处的图像在 kubernetes 集群中运行基于 windows (server 2019) 的 docker 容器mcr.microsoft.com/windows/servercore:1809

该节点被集群识别并显示为就绪。

当我尝试将任何 pod 部署到集群时,它可以正常运行,但无法访问与服务关联的暴露端口。

kube-proxy在 Windows 工作节点上运行似乎存在问题。该节点的日志显示:

Failed create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "kube-proxy-nwclf": Error response from daemon: network host not found

关于我在哪里出错的任何想法?

更新:刚刚注意到 windows 机器上的 kube-proxy pod 有一个基于集群的 ip 地址 ( 10.244.5.2) 而不是来自我的本地网络 ( 192.168.1.X)。这在解决问题方面是否相关?

NAMESPACE     NAME                                 READY   STATUS              RESTARTS   AGE   IP             NODE              NOMINATED NODE   READINESS GATES
kube-system   kube-proxy-9jq8w                     1/1     Running             1          15d   192.168.1.9   k8s-mr        <none>           <none>
kube-system   kube-proxy-h5gx7                     0/1     ContainerCreating   0          13s   10.244.5.2     wins2019-worker   <none>           <none>

来自描述窗格的详细信息如下所示。

user@k8s-mr:~/kube_projects/testdemo-4.1/app$ kubectl -n kube-system describe pod kube-proxy-nwclf
Name:               kube-proxy-nwclf
Namespace:          kube-system
Priority:           2000001000
PriorityClassName:  system-node-critical
Node:               wins2019-worker/192.168.1.10
Start Time:         Wed, 17 Apr 2019 13:35:30 +0100
Labels:             controller-revision-hash=b7775b676
                    k8s-app=kube-proxy
                    pod-template-generation=1
Annotations:        <none>
Status:             Pending
IP:                 192.168.1.10
Controlled By:      DaemonSet/kube-proxy
Containers:
  kube-proxy:
    Container ID:
    Image:         k8s.gcr.io/kube-proxy:v1.14.0
    Image ID:
    Port:          <none>
    Host Port:     <none>
    Command:
      /usr/local/bin/kube-proxy
      --config=/var/lib/kube-proxy/config.conf
      --hostname-override=$(NODE_NAME)
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:
      NODE_NAME:   (v1:spec.nodeName)
    Mounts:
      /lib/modules from lib-modules (ro)
      /run/xtables.lock from xtables-lock (rw)
      /var/lib/kube-proxy from kube-proxy (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-proxy-token-f4tqx (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-proxy:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      kube-proxy
    Optional:  false
  xtables-lock:
    Type:          HostPath (bare host directory volume)
    Path:          /run/xtables.lock
    HostPathType:  FileOrCreate
  lib-modules:
    Type:          HostPath (bare host directory volume)
    Path:          /lib/modules
    HostPathType:
  kube-proxy-token-f4tqx:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  kube-proxy-token-f4tqx
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:
                 CriticalAddonsOnly
                 node.kubernetes.io/disk-pressure:NoSchedule
                 node.kubernetes.io/memory-pressure:NoSchedule
                 node.kubernetes.io/network-unavailable:NoSchedule
                 node.kubernetes.io/not-ready:NoExecute
                 node.kubernetes.io/pid-pressure:NoSchedule
                 node.kubernetes.io/unreachable:NoExecute
                 node.kubernetes.io/unschedulable:NoSchedule
Events:
  Type     Reason                  Age                From                      Message

------

  Normal   Scheduled               70s                default-scheduler         Successfully assigned kube-system/kube-proxy-nwclf to wins2019-worker
  Normal   SandboxChanged          2s (x12 over 61s)  kubelet, wins2019-worker  Pod sandbox changed, it will be killed and re-created.
  Warning  FailedCreatePodSandBox  0s (x13 over 62s)  kubelet, wins2019-worker  Failed create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "kube-proxy-nwclf": Error response from daemon: network host not found
4

1 回答 1

1

现在修复它,我误解了kube-proxy根本不应该在 windows 节点上运行。

我必须修改 kubernetes master 并应用 aNodeSelector以确保根据其操作系统为每个节点设置适当的 pod。

wget https://raw.githubusercontent.com/Microsoft/SDN/master/Kubernetes/flannel/l2bridge/manifests/node-selector-patch.yml
kubectl patch ds/kube-proxy --patch "$(cat node-selector-patch.yml)" -n=kube-system
于 2019-04-18T09:57:29.633 回答