Kubernetes | 《Kubernetes in Action中文版》第8章错误

博客内容讲述了在Kubernetes环境中,一个名为`downward`的Pod由于分配的内存资源过低(100Ki)导致无法启动。通过查看Pod详情,发现容器状态为Pending,错误信息提示内存不足。解决方案是调整资源请求和限制,如将内存请求从100Ki增加到64Mi,限制从500m增加到128Mi。
摘要由CSDN通过智能技术生成

Kubernetes | 《Kubernetes in Action中文版》第8章错误

1. 查看容器详情

Name:         downward
Namespace:    default
Priority:     0
Node:         minikube/192.168.64.3
Start Time:   Mon, 29 Nov 2021 09:43:23 +0800
Labels:       <none>
Annotations:  <none>
Status:       Pending
IP:
IPs:          <none>
Containers:
  main:
    Container ID:
    Image:         k8s.gcr.io/busybox
    Image ID:
    Port:          <none>
    Host Port:     <none>
    Command:
      sleep
      9999999
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Limits:
      cpu:     500m
      memory:  4Mi
    Requests:
      cpu:     250m
      memory:  100Ki
    Environment:
      POD_NAME:         downward (v1:metadata.name)
      POD_NAMESPACE:    default (v1:metadata.namespace)
      POD_IP:            (v1:status.podIP)
      NODE_NAME:         (v1:spec.nodeName)
      SERVICE_ACCOUNT:   (v1:spec.serviceAccountName)
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-4js5b (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  kube-api-access-4js5b:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   Burstable
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason                  Age              From               Message
  ----     ------                  ----             ----               -------
  Normal   Scheduled               3s               default-scheduler  Successfully assigned default/downward to minikube
  Warning  FailedCreatePodSandBox  3s               kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "downward": Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:348: copying bootstrap data to pipe caused: write init-p: broken pipe: unknown
  Normal   SandboxChanged          1s (x2 over 2s)  kubelet            Pod sandbox changed, it will be killed and re-created.
  Warning  FailedCreatePodSandBox  1s (x2 over 2s)  kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to start sandbox container for pod "downward": Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: process_linux.go:352: getting the final child's pid from pipe caused: read init-p: connection reset by peer: unknown

2. 原因

给容器分配的内存过低无法启动。

3. 解决办法

  • downward-api-env.yaml
  • downward-api-volume.yaml

修改上面两个文件中下面标注的两处位置。

# ...
spec:
  containers:
  - name: main
    image: busybox
    command: ["sleep", "9999999"]
    resources:
      requests:
        cpu: 15m
        # 修改此处
        memory: 64Mi
      limits:
        cpu: 100m
        # 修改此处
        memory: 128Mi
# ...    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yimtcode

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值