首页 > 解决方案 > K8s 教程在我的本地安装中因 i/o 超时而失败

问题描述

我正在使用三个节点进行本地 kubernetes 安装。它们是通过 geerlingguy/kubernetes Ansible 角色安装的(使用默认设置)。我已经多次重新创建了整个虚拟机。我尝试按照https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/explore-interactive/上的 Kubernetes 教程在集群内启动和运行服务并尝试立即访问它们。

# kubectl get nodes 
NAME        STATUS   ROLES    AGE    VERSION
enceladus   Ready    <none>   162m   v1.17.9
mimas       Ready    <none>   162m   v1.17.9
titan       Ready    master   162m   v1.17.9

我用 1.17.9 或 1.18.6 试过,我用https://github.com/geerlingguy/ansible-role-kuberneteshttps://github.com/kubernetes-sigs/kubespray在新鲜的 Debian-破坏者虚拟机。我尝试使用 Flannel 和 Calico 网络插件。没有配置防火墙。

我可以将 kubernetes-bootcamp 和 exec 部署到其中,但是当我尝试通过 kubectl 代理和 curl 访问 pod 时出现错误。

# kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1
# kubectl describe pods

Name:         kubernetes-bootcamp-69fbc6f4cf-nq4tj
Namespace:    default
Priority:     0
Node:         enceladus/192.168.10.12
Start Time:   Thu, 06 Aug 2020 10:53:34 +0200
Labels:       app=kubernetes-bootcamp
              pod-template-hash=69fbc6f4cf
Annotations:  <none>
Status:       Running
IP:           10.244.1.4
IPs:
  IP:           10.244.1.4
Controlled By:  ReplicaSet/kubernetes-bootcamp-69fbc6f4cf
Containers:
  kubernetes-bootcamp:
    Container ID:   docker://77eae93ca1e6b574ef7b0623844374a5b2f3054075025492b708b23fc3474a45
    Image:          gcr.io/google-samples/kubernetes-bootcamp:v1
    Image ID:       docker-pullable://gcr.io/google-samples/kubernetes-bootcamp@sha256:0d6b8ee63bb57c5f5b6156f446b3bc3b3c143d233037f3a2f00e279c8fcc64af
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Thu, 06 Aug 2020 10:53:35 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-kkcvk (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-kkcvk:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-kkcvk
    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  10s   default-scheduler   Successfully assigned default/kubernetes-bootcamp-69fbc6f4cf-nq4tj to enceladus
  Normal  Pulled     9s    kubelet, enceladus  Container image "gcr.io/google-samples/kubernetes-bootcamp:v1" already present on machine
  Normal  Created    9s    kubelet, enceladus  Created container kubernetes-bootcamp
  Normal  Started    9s    kubelet, enceladus  Started container kubernetes-bootcamp

更新服务列表

# kubectl get services
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   4d20h

我可以在部署中执行 curl。它正在运行。

# kubectl exec -ti kubernetes-bootcamp-69fbc6f4cf-nq4tj curl http://localhost:8080/
Hello Kubernetes bootcamp! | Running on: kubernetes-bootcamp-69fbc6f4cf-nq4tj | v=1

但是,当我尝试从主节点卷曲时,响应不好:

curl http://localhost:8001/api/v1/namespaces/default/pods/kubernetes-bootcamp-69fbc6f4cf-nq4tj/proxy/
Error trying to reach service: 'dial tcp 10.244.1.4:80: i/o timeout'

卷曲本身需要大约。30秒返回。版本等可用。代理运行良好。

# curl http://localhost:8001/version
{
  "major": "1",
  "minor": "17",
  "gitVersion": "v1.17.9",
  "gitCommit": "4fb7ed12476d57b8437ada90b4f93b17ffaeed99",
  "gitTreeState": "clean",
  "buildDate": "2020-07-15T16:10:45Z",
  "goVersion": "go1.13.9",
  "compiler": "gc",
  "platform": "linux/amd64"
}

该教程显示kubectl describe pods容器具有开放端口(在我的情况下是<none>):

Port:           8080/TCP
Host Port:      0/TCP

好的,我创建了一个应用文件bootcamp.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kubernetes-bootcamp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kubernetes-bootcamp
  template:
    metadata:
      labels:
        app: kubernetes-bootcamp
    spec:
      containers:
      - name: kubernetes-bootcamp
        image: gcr.io/google-samples/kubernetes-bootcamp:v1
        ports:
        - containerPort: 8080
          protocol: TCP

我删除了以前的部署

# kubectl delete deployments.apps kubernetes-bootcamp --force
# kubectl apply -f bootcamp.yaml

但在那之后,我i/o timeout在新部署上还是一样。

那么,我的问题是什么?

标签: kubernetes

解决方案


推荐阅读