apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ name }}
  labels:
  {% for key, value in labels.items() %}
    {{ key }}: {{ value }}
  {% endfor %}
spec:
  replicas: {{ replicas }}
  selector:
    matchLabels:
    {% for key, value in labels.items() %}
      {{ key }}: {{ value }}
    {% endfor %}
  template:
    metadata:
      labels:
      {% for key, value in labels.items() %}
        {{ key }}: {{ value }}
      {% endfor %}
      annotations:
        io.kubernetes.cri-o.TrustedSandbox: "{{ trusted }}"
    spec:
      terminationGracePeriodSeconds: 5
      automountServiceAccountToken: false
      volumes:
      - name: package-folder
        emptyDir: {}
      - name: cgroup-folder
        hostPath:
          path: /sys/fs/cgroup
      containers:
      - name: {{ container_name }}
        image: {{ image }}
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9090
        volumeMounts:
          - name: package-folder
            mountPath: /var/qinling/packages
          - name: cgroup-folder
            mountPath: /qinling_cgroup
        env:
          - name: POD_UID
            valueFrom:
              fieldRef:
                fieldPath: metadata.uid
          - name: QOS_CLASS
            value: "BestEffort"
      - name: sidecar
        image: {{ sidecar_image }}
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 9091
        volumeMounts:
          - name: package-folder
            mountPath: /var/qinling/packages
