【问题标题】:Kubernetes ACS engine: containers (pods) do not have internet accessKubernetes ACS 引擎:容器(pod)无法访问互联网
【发布时间】:2017-12-04 14:35:43
【问题描述】:

我正在使用 Kubernetes 集群,使用 ACS-engine 部署在 Azure 上。我的集群由 5 个节点组成。

  • 1 个主机(unix 虚拟机)(v1.6.2)
  • 2 个 unix 代理 (v1.6.2)
  • 2个windows代理(v1.6.0-alpha.1.2959+451473d43a2072)

我创建了一个由以下 YAML 定义的 unix pod

Name:           ping-with-unix
Node:           k8s-linuxpool1-25103419-0/10.240.0.5
Start Time:     Fri, 30 Jun 2017 14:27:28 +0200
Status:         Running
IP:             10.244.2.6
Controllers:    <none>
Containers:
  ping-with-unix-2:
    Container ID:       
    Image:              willfarrell/ping
    Port:
    State:              Running
      Started:          Fri, 30 Jun 2017 14:27:29 +0200
    Ready:              True
    Restart Count:      0
    Environment:
      HOSTNAME: google.com
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-1nrh5 (ro)
Conditions:
  Type          Status
  Initialized   True
  Ready         True
  PodScheduled  True
Volumes:
  default-token-1nrh5:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-1nrh5
    Optional:   false
QoS Class:      BestEffort
Node-Selectors: beta.kubernetes.io/os=linux
Tolerations:    <none>
Events:         <none>

此 pod 无法访问互联网。

2017-06-30T12:27:29.512885000Z ping google.com every 300 sec
2017-06-30T12:27:29.521968000Z PING google.com (172.217.17.78): 56 data bytes
2017-06-30T12:27:39.698081000Z --- google.com ping statistics ---
2017-06-30T12:27:39.698305000Z 1 packets transmitted, 0 packets received, 100% packet loss

我创建了第二个 pod,目标是 windows 容器,带有自定义 docker 映像。此图像实例化一个 HttpClient 并请求一个端点。它也没有互联网接入。我可以访问容器来运行交互式 PowerShell。我无法访问任何 DNS(由于无法访问 Internet)。

PS C:\app> ping github.com
Ping request could not find host github.com. Please check the name and try again.
PS C:\app> ping 192.30.253.112

Pinging 192.30.253.112 with 32 bytes of data:
Request timed out.
Request timed out.

Ping statistics for 192.30.253.112:
    Packets: Sent = 2, Received = 0, Lost = 2 (100% loss),
Control-C

我必须进行哪些配置才能让我的容器访问互联网?
备注:我没有定义任何网络策略。

【问题讨论】:

  • 您使用的集群定义是什么,ACS-Engine 的版本是什么?存在启用 CNI 的集群没有出站互联网连接的问题。
  • 我从ACS-engine repo 自定义了kubernetes-hybrid.json 文件。我只覆盖了 dnsPrefix、adminPassword、linuxProfile/ssh/publicKeys/keyData 值和 servicePrincipalProfile 值。 ACS-Engine 是在我的环境中编译的,使用存储库中的 git commit 449615c8cce1e43f00b9386b3d7f6f4327a54b77(来自 Azure/issue-template-update 的合并拉取请求 #712)。
  • 我注意到documentation 中的“临时解决方法”部分,但我的资源组已经为创建的唯一子网定义了一个路由表。

标签: powershell azure unix docker kubernetes


【解决方案1】:

我已使用 api 版本“2017-07-01”和 kubernetes 版本“1.6.6”更新了我的集群。我的 unix 和 windows pod 都可以访问 Internet。

注意,对于 Windows pod:

  • 在 pod 启动 2 或 3 分钟后可以上网
  • 我无法将 DnsPolicy 设置为“默认”,只有“ClusterFirst”或“ClusterFirstWithHostNet”有效。

【讨论】:

    猜你喜欢
    • 2021-10-09
    • 2016-02-20
    • 2021-01-26
    • 2019-08-01
    • 2020-01-04
    • 2020-10-18
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多