在企业防火墙/代理服务器后面运行kubernetes kubeadm集群

问题描述 投票:1回答:3

我们有一个5节点集群,它移动到我们的企业防火墙/代理服务器后面。

根据这里的指示:setting-up-standalone-kubernetes-cluster-behind-corporate-proxy

我使用以下方法设置代理服务器环境变量

export http_proxy=http://proxy-host:proxy-port/
export HTTP_PROXY=$http_proxy
export https_proxy=$http_proxy
export HTTPS_PROXY=$http_proxy
printf -v lan '%s,' localip_of_machine
printf -v pool '%s,' 192.168.0.{1..253}
printf -v service '%s,' 10.96.0.{1..253}
export no_proxy="${lan%,},${service%,},${pool%,},127.0.0.1";
export NO_PROXY=$no_proxy

现在我们集群中的所有内容都在内部但是,当我尝试创建一个从外部拉下图像的吊舱时,吊舱卡在ContainerCreating上,例如,

[gms@thalia0 ~]$ kubectl apply -f https://k8s.io/examples/admin/dns/busybox.yaml
pod/busybox created

卡在这里:

[gms@thalia0 ~]$ kubectl get pods
NAME                            READY   STATUS              RESTARTS   AGE
busybox                         0/1     ContainerCreating   0          17m

我认为这是由于图像被拉出的主机/域不在我们的公司代理规则中。我们有规则

k8s.io
kubernetes.io
docker.io
docker.com

所以,我不确定需要添加其他主机/域名。

我为busybox做了一个描述pod,并参考了node.kubernetes.io(我正在为*.kubernetes.io提供一个域范围的例外,这对我来说已经足够了)。

这是我从kubectl describe pods busybox得到的:

Volumes:
  default-token-2kfbw:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-2kfbw
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason                  Age   From                          Message
  ----     ------                  ----  ----                          -------
  Normal   Scheduled               73s   default-scheduler             Successfully assigned default/busybox to thalia3.ahc.umn.edu
  Warning  FailedCreatePodSandBox  10s   kubelet, thalia3.ahc.umn.edu  Failed create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container "6af48c5dadf6937f9747943603a3951bfaf25fe1e714cb0b0cbd4ff2d59aa918" network for pod "busybox": NetworkPlugin cni failed to set up pod "busybox_default" network: error getting ClusterInformation: Get https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default: dial tcp 10.96.0.1:443: i/o timeout, failed to clean up sandbox container "6af48c5dadf6937f9747943603a3951bfaf25fe1e714cb0b0cbd4ff2d59aa918" network for pod "busybox": NetworkPlugin cni failed to teardown pod "busybox_default" network: error getting ClusterInformation: Get https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default: dial tcp 10.96.0.1:443: i/o timeout]
  Normal   SandboxChanged          10s   kubelet, thalia3.ahc.umn.edu  Pod sandbox changed, it will be killed and re-created.

我会假设印花布错误是由于这个原因:

Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s

calicocoredns pods似乎有类似的错误到达node.kubernetes.io,所以我认为这是由于我们的服务器无法在重启时拉下新图像。

docker kubernetes http-proxy corporate-policy
3个回答
1
投票

看起来你误解了一些我想在这里帮助澄清的Kubernetes概念。对node.kubernetes.io的引用不是尝试对该域进行任何网络调用。这只是Kubernetes用来指定字符串键的惯例。因此,如果您必须应用标签,注释或宽容,您可以定义自己的密钥,如subdomain.domain.tld/some-key

至于您遇到的Calico问题,它看起来像错误:

network: error getting ClusterInformation: Get https://[10.96.0.1]:443/apis/crd.projectcalico.org/v1/clusterinformations/default: dial tcp 10.96.0.1:443: i/o timeout]

是我们的罪魁祸首。 10.96.0.1是用于引用pod中的Kubernetes API服务器的IP地址。似乎在您的节点上运行的calico/node pod无法访问API服务器。您可以更多地了解如何设置Calico吗?你知道你在运行Calico的哪个版本?

你的calico/node实例试图访问crd.projectcalico.org/v1/clusterinformations资源的事实告诉我它正在使用Kubernetes数据存储区作为其后端。你确定你没有尝试在Etcd模式下运行Calico吗?


0
投票

你应该看到ImagePullBackOff状态似乎没有任何拉动图像的问题。 (虽然可能会在您看到的错误消息之后出现)

您从pod中看到的错误与他们无法在内部连接到kube-apiserver有关。它看起来像是超时,所以很可能在默认命名空间中有kubernetes服务。您可以这样检查,例如:

$ kubectl -n default get svc
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   2d20h

可能是缺少(?)您可以随时重新创建它:

$ cat <<'EOF' | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  labels:
    component: apiserver
    provider: kubernetes
  name: kubernetes
  namespace: default
spec:
  clusterIP: 10.96.0.1
  type: ClusterIP
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: 443
EOF

容忍基本上是说pod可以容忍在具有node.kubernetes.io/not-ready:NoExecutenode.kubernetes.io/unreachable:NoExecute taints的节点上进行调度,但是你的错误看起来与此无关。


0
投票

该问题通常意味着docker守护程序无法响应。

如果有任何其他服务消耗更多的CPU或I / O,则可能会发生此问题。

© www.soinside.com 2019 - 2024. All rights reserved.