apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: dedicated-metering-server
  namespace: metering
spec:
  persistentVolumeClaimRetentionPolicy:
    whenDeleted: Retain
    whenScaled: Retain
  podManagementPolicy: OrderedReady
  replicas: 1
  selector:
    matchLabels:
      app: dedicated-metering-server
  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:19661eb212cef93565bd10445494be886369349d
        imagePullPolicy: Always
        args: ["networkmetering"]
        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
        - name: data
          mountPath: /data/
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      serviceAccount: dedicated-metering-server-manager
      serviceAccountName: dedicated-metering-server-manager
      terminationGracePeriodSeconds: 10
      volumes:
      - name: networkmetering
        configMap:
          name: networkmetering-config
      - name: aws-token
        projected:
          defaultMode: 420
          sources:
          - serviceAccountToken:
              audience: sts.amazonaws.com
              expirationSeconds: 86400
              path: token
  volumeClaimTemplates:
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        creationTimestamp: null
        name: data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 200Gi
        storageClassName: default
        volumeMode: Filesystem
