apiVersion: apps/v1
kind: Deployment
metadata:
  name: dedicated-metering-server
  namespace: metering
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: dedicated-metering-server
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: network-metering-server
      creationTimestamp: null
      labels:
        app: dedicated-metering-server
        azure.workload.identity/use: "true"
    spec:
      containers:
        - env:
            - name: API_GATEWAY_AUTH_KEY
              valueFrom:
                secretKeyRef:
                  key: api-gateway-auth-key
                  name: api-gateway-auth
            - name: AWS_DEFAULT_REGION
              value: us-west-2
            - name: AWS_REGION
              value: us-west-2
            - name: AWS_WEB_IDENTITY_TOKEN_FILE
              value: /var/run/secrets/eks.amazonaws.com/serviceaccount/token
            - name: AWS_ROLE_ARN
              value: arn:aws:iam::380838443567:role/azure-japaneast-billing-prod-reporter
          image: tidbcloudprod.azurecr.io/tidbcloud/network-metering-server:prod-v3
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 8081
              scheme: HTTP
            initialDelaySeconds: 15
            periodSeconds: 20
            successThreshold: 1
            timeoutSeconds: 1
          name: network-metering-server
          ports:
            - containerPort: 8080
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /readyz
              port: 8081
              scheme: HTTP
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          resources:
            limits:
              cpu: 500m
              memory: 1Gi
            requests:
              cpu: 100m
              memory: 256Mi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /configs/
              name: networkmetering
            - mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount/
              name: aws-token
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: dedicated-metering-server-manager
      serviceAccountName: dedicated-metering-server-manager
      terminationGracePeriodSeconds: 10
      volumes:
        - configMap:
            defaultMode: 420
            name: networkmetering
          name: networkmetering
        - name: aws-token
          projected:
            defaultMode: 420
            sources:
              - serviceAccountToken:
                  audience: sts.amazonaws.com
                  expirationSeconds: 86400
                  path: token
