apiVersion: apps/v1
kind: DaemonSet
metadata:
  annotations: {}
  labels:
    app.kubernetes.io/name: ztunnel
    app.kubernetes.io/part-of: istio
  name: ztunnel
  namespace: istio-system
spec:
  selector:
    matchLabels:
      app: ztunnel
  template:
    metadata:
      annotations:
        prometheus.io/port: "15020"
        prometheus.io/scrape: "true"
        sidecar.istio.io/inject: "false"
      labels:
        app: ztunnel
        istio.io/dataplane-mode: none
        sidecar.istio.io/inject: "false"
    spec:
      containers:
      - args:
        - proxy
        - ztunnel
        env:
        - name: CA_ADDRESS
          value: istiod.istio-system.svc:15012
        - name: XDS_ADDRESS
          value: istiod.istio-system.svc:15012
        - name: RUST_LOG
          value: info
        - name: RUST_BACKTRACE
          value: "1"
        - name: ISTIO_META_CLUSTER_ID
          value: Kubernetes
        - name: INPOD_ENABLED
          value: "true"
        - name: TERMINATION_GRACE_PERIOD_SECONDS
          value: "30"
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: INSTANCE_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: SERVICE_ACCOUNT
          valueFrom:
            fieldRef:
              fieldPath: spec.serviceAccountName
        - name: ISTIO_META_ENABLE_HBONE
          value: "true"
        image: gcr.io/istio-testing/ztunnel:latest
        name: istio-proxy
        ports:
        - containerPort: 15020
          name: ztunnel-stats
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /healthz/ready
            port: 15021
        resources:
          limits:
            cpu: 200m
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 100Mi
        securityContext:
          allowPrivilegeEscalation: true
          capabilities:
            add:
            - NET_ADMIN
            - SYS_ADMIN
            - NET_RAW
            drop:
            - ALL
          privileged: false
          readOnlyRootFilesystem: true
          runAsGroup: 1337
          runAsNonRoot: false
          runAsUser: 0
        volumeMounts:
        - mountPath: /var/run/secrets/istio
          name: istiod-ca-cert
        - mountPath: /var/run/secrets/tokens
          name: istio-token
        - mountPath: /var/run/ztunnel
          name: cni-ztunnel-sock-dir
        - mountPath: /tmp
          name: tmp
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-node-critical
      serviceAccountName: ztunnel
      terminationGracePeriodSeconds: 30
      tolerations:
      - effect: NoSchedule
        operator: Exists
      - key: CriticalAddonsOnly
        operator: Exists
      - effect: NoExecute
        operator: Exists
      volumes:
      - name: istio-token
        projected:
          sources:
          - serviceAccountToken:
              audience: istio-ca
              expirationSeconds: 43200
              path: istio-token
      - configMap:
          name: istio-ca-root-cert
        name: istiod-ca-cert
      - hostPath:
          path: /var/run/ztunnel
          type: DirectoryOrCreate
        name: cni-ztunnel-sock-dir
      - emptyDir: {}
        name: tmp
  updateStrategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
