If you use a sidecar container to implement an effect that is similar to DaemonSets and the status of the sidecar container is NotReady, the status of the pod is NotReady. In specific scenarios, 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.
Feature description
If you use Elastic Container Instance in Container Service for Kubernetes (ACK) Serverless clusters, Elastic Container Instance does not support the DaemonSet feature of Kubernetes due to the limitation of virtual nodes. If you want to use the DaemonSet feature, you can add a sidecar container to the Elastic Container Instance-based pod to achieve an effect that is similar to DaemonSets. 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, Elastic Container Instance 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.
Configuration description
The environment variable that is used to ignore the status of a container is ECI_CONTAINER_IGNORE_READY
. A value of true
specifies that the status of the container is ignored.
Sample configurations
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. Container c1 can run as expected, and Container c2 cannot enter the Ready state due to the lack of startup commands.
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: c1 image: registry.cn-shanghai.aliyuncs.com/eci_open/perl:5 command: ["/bin/sh", "-c", "sleep 999"] - name: c2 image: registry.cn-shanghai.aliyuncs.com/eci_open/centos:7 env: - name: ECI_CONTAINER_IGNORE_READY value: "true"
View the details of the pod and check the status of the pod.
kubectk get pod <pod-name> -o yaml
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 Container c2 is ignored.