All Products
Search
Document Center

Container Compute Service:Ignore the NotReady state of the sidecar container

Last Updated:Jan 26, 2025

Alibaba Cloud Container Compute Service (ACS) allows you to use sidecar containers to achieve a DaemonSet-like effect. If the status of the sidecar container is NotReady, the status of the corresponding pod is NotReady. If you do not want the status of the sidecar container to affect the status of the entire pod, you can use environment variables to ignore the status of the sidecar container.

Introduction

ACS clusters do not support DaemonSets due to the limits of virtual nodes. To achieve a DaemonSet-like effect, you can add sidecar containers to pods in ACS clusters. After you add a sidecar container, if the status of the sidecar container is NotReady, the status of the pod is NotReady.

In some scenarios, you may not want the status of the sidecar container to affect the status of the entire pod. For example, you may want to use a sidecar container to collect logs. If the logging container encounters an issue, the application containers need to continue providing external services.

To address the issue, ACS provides the feature to ignore the NotReady status of a container. If you do not want the status of a container to affect the status of the entire pod, you can add an environment variable to ignore the status of the container. After you add the environment variable, the pod can still enter the Ready state when the container is in the NotReady state.

How to configure

The environment variable that is used to ignore the status of a container is __IGNORE_READY__. A value of true specifies that the status of the container is ignored.

Examples

  1. Write a YAML configuration file for the application, and then use the YAML file to create a Deployment.

    kubectl apply -f test-ignore.yaml

    In the following example, a YAML file named test-ignore.yaml is provided to create a Deployment that contains one pod replica. The pod contains two containers. The app container runs as normal. The sidecar container returns a non-zero status code and cannot enter the Ready state.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: test-ignore
      labels:
        app: test
    spec:
      replicas: 1 
      selector:
        matchLabels:
          app: test
      template:
        metadata:
          labels:
            app: test
        spec:
          containers:
          - name: app
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/busybox:1.28
            command: ["/bin/sh", "-c", "sleep 999"] 
          - name: sidecar
            image: registry-cn-hangzhou.ack.aliyuncs.com/ack-demo/busybox:1.28
            command: ["/bin/sh", "-c", "exit 1"] 
            env:
            - name: __IGNORE_READY__
              value: "true"
  2. View the details of the pod and check the status of the pod.

    kubectk get pod <pod-name> -o yaml

    Expected results:

    ...
    status:
      conditions:
        - lastTransitionTime: '2024-08-02T09:36:14Z'
          status: 'True'
          type: Initialized
        - lastTransitionTime: '2024-08-02T09:36:16Z'
          status: 'True'
          type: Ready
        - lastTransitionTime: '2024-08-02T09:36:16Z'
          status: 'True'
          type: ContainersReady
        - lastTransitionTime: '2024-08-02T09:36:15Z'
          status: 'True'
          type: PodScheduled
        - lastTransitionTime: '2024-08-02T09:36:14Z'
          status: 'True'
          type: ContainerHasSufficientDisk
    ...

    In the response, check the Ready and ContainersReady parameters in the status.conditions section. The status values of the parameters are True, which indicates that the NotReady state of the sidecar container is ignored.