apiVersion: apps/v1
kind: Deployment
metadata:
  name: dedicated-metering-server
  namespace: metering
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dedicated-metering-server
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: network-metering-server
      labels:
        app: dedicated-metering-server
        azure.workload.identity/use: "true"
    spec:
      containers:
        - env:
            - name: API_GATEWAY_AUTH_KEY
              valueFrom:
                secretKeyRef:
                  name: api-gateway-auth
                  key: api-gateway-auth-key
            - 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::385595570414:role/azure-billing-nightly-reporter
          image: tidbclouddev.azurecr.io/tidbcloud/network-metering-server:dev-v4
          name: network-metering-server
          ports:
            - containerPort: 8080
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - "ALL"
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8081
            initialDelaySeconds: 15
            periodSeconds: 20
          readinessProbe:
            httpGet:
              path: /readyz
              port: 8081
            initialDelaySeconds: 5
            periodSeconds: 10
          imagePullPolicy: Always
          volumeMounts:
            - name: networkmetering
              mountPath: /configs/
            - mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount/
              name: aws-token
          resources:
            limits:
              cpu: 500m
              memory: 1024Mi
            requests:
              cpu: 100m
              memory: 256Mi
      volumes:
        - name: networkmetering
          configMap:
            name: networkmetering
        - name: aws-token
          projected:
            defaultMode: 420
            sources:
              - serviceAccountToken:
                  audience: sts.amazonaws.com
                  expirationSeconds: 86400
                  path: token
      terminationGracePeriodSeconds: 10
      serviceAccountName: dedicated-metering-server-manager
