【问题标题】:Back-off restarting failed container In Azure AKS在 Azure AKS 中回退重新启动失败的容器
【发布时间】:2020-10-02 06:50:04
【问题描述】:

Linux 容器 pod 使用 Azure 容器注册表中的 docker 映像,始终使用 restartPolicy 重新启动。 Pod 描述如下。

kubectl describe pod example-pod

...

State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 11 Jun 2020 03:27:11 +0000
      Finished:     Thu, 11 Jun 2020 03:27:12 +0000
...
Back-off restarting failed container

这个 pod 是使用秘密创建的,用于访问 ACR 注册表存储库。 原因是 pod 以退出代码 0 成功完成执行。但是,它应该继续侦听特定的端口号。 Microsoft 文档链接位于此 URL Container Group Runtime 标题“容器不断退出并重新启动”下

deployment-example.yml文件内容如下。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
  namespace: development
  labels:
    app: example
spec:
  replicas: 1
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: example
        image: contentocr.azurecr.io/example:latest
        #command: ["ping -t localhost"]
        imagePullPolicy: Always
        ports:
        - name: http-port
          containerPort: 3000
      imagePullSecrets:
        - name: regpass
      restartPolicy: Always
      nodeSelector:
        agent: linux
---
apiVersion: v1
kind: Service
metadata:
  name: example
  namespace: development
  labels:
    app: example
spec:
  ports:
  - name: http-port
    port: 3000
    targetPort: 3000
  selector:
      app: example
  type: LoadBalancer

kubectl get events的输出如下。

3m39s       Normal    Scheduled              pod/example-deployment-5dc964fcf8-gbm5t    Successfully assigned development/example-deployment-5dc964fcf8-gbm5t to aks-agentpool-18342716-vmss000000
2m6s        Normal    Pulling                pod/example-deployment-5dc964fcf8-gbm5t    Pulling image "contentocr.azurecr.io/example:latest"
2m5s        Normal    Pulled                 pod/example-deployment-5dc964fcf8-gbm5t    Successfully pulled image "contentocr.azurecr.io/example:latest"
2m5s        Normal    Created                pod/example-deployment-5dc964fcf8-gbm5t    Created container example
2m49s       Normal    Started                pod/example-deployment-5dc964fcf8-gbm5t    Started container example
2m20s       Warning   BackOff                pod/example-deployment-5dc964fcf8-gbm5t    Back-off restarting failed container
6m6s        Normal    SuccessfulCreate       replicaset/example-deployment-5dc964fcf8   Created pod: example-deployment-5dc964fcf8-2fdt5
3m39s       Normal    SuccessfulCreate       replicaset/example-deployment-5dc964fcf8   Created pod: example-deployment-5dc964fcf8-gbm5t
6m6s        Normal    ScalingReplicaSet      deployment/example-deployment              Scaled up replica set example-deployment-5dc964fcf8 to 1
3m39s       Normal    ScalingReplicaSet      deployment/example-deployment              Scaled up replica set example-deployment-5dc964fcf8 to 1
3m38s       Normal    EnsuringLoadBalancer   service/example                            Ensuring load balancer
3m34s       Normal    EnsuredLoadBalancer    service/example                            Ensured load balancer

Docker 文件入口点类似于 ENTRYPOINT ["npm", "start"]CMD ["tail -f /dev/null/"]

【问题讨论】:

  • 分享 kubectl get 事件的输出
  • 你在图像中运行什么代码(任何脚本)?
  • 我认为问题在于您的形象。需要检查镜像在本地是否可以正常运行。

标签: kubernetes azure-aks linux-containers


【解决方案1】:

它在本地运行。隐含地,它分配了 CI="true" 标志。但是,在 docker-compose stdin_open: truetty: true 中要设置,并且在 Kubernetes 部署文件中,ENV 命名变量 CI 是设置为 "true".

【讨论】:

    【解决方案2】:

    以下命令解决了我的问题:-

    az aks update -n aks-nks-k8s-cluster -g aks-nks-k8s-rg --attach-acr aksnksk8s
    

    执行上述命令后,会显示如下:-

    Add ROLE Propagation done [###############] 100.0000%
    

    然后, Running.. 一段时间后响应跟踪。

    这里,

    aks-nks-k8s-cluster : Cluster name I have created and using
    aks-nks-k8s-rg : Resource Group have created and using
    aksnksk8s : Container Registries which I have created and using
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-05
      • 2019-10-30
      • 2020-05-21
      • 2022-01-15
      • 2021-01-13
      • 2018-05-15
      • 2021-11-21
      • 2021-09-23
      相关资源
      最近更新 更多