apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: cloudflared
  namespace: cloudflared
spec:
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: cloudflared
  template:
    metadata:
      labels:
        app: cloudflared
    spec:
      serviceAccountName: cloudflared
      containers:
        - name: cloudflared
          image: cloudflare/cloudflared:2022.1.2
          imagePullPolicy: Always
          args:
            - tunnel
            - --loglevel=debug
            - --metrics=0.0.0.0:3333
            - --no-autoupdate
            - --config=/etc/cloudflared/config/config.yaml
            - --credentials-file=/etc/cloudflared/credentials/credentials.json
            - run
          volumeMounts:
            - name: config
              mountPath: /etc/cloudflared/config
              readOnly: true
            - name: credentials
              mountPath: /etc/cloudflared/credentials
              readOnly: true
          securityContext:
            runAsUser: 11111
            runAsGroup: 11111
            readOnlyRootFilesystem: true
          ports:
            - name: metrics
              containerPort: 3333
          livenessProbe:
            httpGet:
              port: metrics
              path: /ready
            initialDelaySeconds: 3
            periodSeconds: 3
            failureThreshold: 1
          resources:
            requests:
              cpu: 50m
              memory: 50M
            limits:
              cpu: 100m
              memory: 100M
      volumes:
        - name: config
          configMap:
            name: cloudflared
            items:
              - key: config.yaml
                path: config.yaml
        - name: credentials
          secret:
            secretName: cloudflared
            items:
              - key: credentials.json
                path: credentials.json
