Configuring Kubernetes Native Sidecar Containers (Native Definition)
Scenarios
If the CCE Cloud Bursting Engine for CCI add-on is used, Kubernetes native sidecar containers are supported. Different from dynamic injection through the add-on, this section describes how to directly define native sidecar containers in the YAML file for creating a workload. You can set restartPolicy to Always in initContainers of a pod to start the container as a sidecar container. This type of container is ready before the main service container is started and run throughout the entire lifecycle of the pod. They do not block the startup of the main service container.
Constraints
- The required label (for example, bursting.cci.io/burst-to-cci: enforce) must be configured for the pods scheduled to CCI 2.0.
- This function depends on the CCE Cloud Bursting Engine for CCI add-on v1.5.80 or later.
Procedure
In the YAML file for creating a pod, add container configurations to the spec.template.spec.initContainers field and set restartPolicy to Always to enable Kubernetes native sidecar containers.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-1
namespace: test
labels:
bursting.cci.io/burst-to-cci: enforce # Forcibly schedules the pod to CCI 2.0.
spec:
replicas: 1
selector:
matchLabels:
appName: test-1
template:
metadata:
labels:
appName: test-1
spec:
# Configure the sidecar container.
initContainers:
- name: container2
image: nginx:latest # Replace it with the actual image path.
restartPolicy: Always # If restartPolicy is set to Always in initContainers, the init container becomes a sidecar container.
# Configure the main service container.
containers:
- image: nginx:latest
name: container-1
command:
- /bin/sh
- '-c'
- while true ;do echo hello ;sleep 3; done
resources:
requests:
cpu: 10m
memory: 200Mi
imagePullSecrets:
- name: default-secret
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 35%
maxSurge: 35% Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot