apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-api-ningbo
  labels:
    app.kubernetes.io/name: easyai-api
    app.kubernetes.io/component: api
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-api
      easyai.io/site: ningbo
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-api
        app.kubernetes.io/component: api
        app.kubernetes.io/part-of: easyai-ai-gateway
        easyai.io/site: ningbo
    spec:
      serviceAccountName: easyai-ai-gateway
      terminationGracePeriodSeconds: 90
      nodeSelector:
        easyai.io/site: ningbo
        easyai.io/workload: "true"
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        fsGroup: 10001
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: api
          image: easyai-api
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: easyai-ai-gateway-config
            - secretRef:
                name: easyai-ai-gateway-runtime
          env:
            - name: AI_GATEWAY_PROCESS_ROLE
              value: api
            - name: AI_GATEWAY_ASYNC_QUEUE_WORKER_ENABLED
              value: "false"
            - name: AI_GATEWAY_ASYNC_ADMISSION_DISPATCHER_ENABLED
              value: "true"
            - name: AI_GATEWAY_DATABASE_MAX_CONNS
              value: "32"
            - name: AI_GATEWAY_DATABASE_CRITICAL_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_RIVER_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_MIN_IDLE_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_MAX_CONN_IDLE_SECONDS
              value: "30"
            - name: AI_GATEWAY_MEDIA_REQUEST_CONCURRENCY
              value: "16"
            - name: AI_GATEWAY_MEDIA_MATERIALIZATION_CONCURRENCY
              value: "8"
            - name: AI_GATEWAY_MEDIA_IMAGE_NORMALIZATION_CONCURRENCY
              value: "2"
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_KEY_ID
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_SECRET
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_SECRET_KEY
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
            - name: EASYAI_SITE
              value: ningbo
          ports:
            - name: http
              containerPort: 8088
          startupProbe:
            httpGet:
              path: /api/v1/healthz
              port: http
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 120
          readinessProbe:
            httpGet:
              path: /api/v1/readyz
              port: http
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /api/v1/healthz
              port: http
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "sleep 10"]
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
            limits:
              cpu: "2"
              memory: 2Gi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: application-data
              mountPath: /app/data
            - name: temporary-files
              mountPath: /tmp
      volumes:
        - name: application-data
          emptyDir:
            sizeLimit: 5Gi
        - name: temporary-files
          emptyDir:
            sizeLimit: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-capacity-controller
  labels:
    app.kubernetes.io/name: easyai-capacity-controller
    app.kubernetes.io/component: capacity-controller
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-capacity-controller
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-capacity-controller
        app.kubernetes.io/component: capacity-controller
        app.kubernetes.io/part-of: easyai-ai-gateway
    spec:
      serviceAccountName: easyai-capacity-controller
      terminationGracePeriodSeconds: 30
      nodeSelector:
        easyai.io/site: ningbo
        easyai.io/workload: "true"
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        fsGroup: 10001
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: capacity-controller
          image: easyai-api
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: easyai-ai-gateway-config
          env:
            - name: AI_GATEWAY_PROCESS_ROLE
              value: capacity-controller
            - name: AI_GATEWAY_DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: easyai-ai-gateway-runtime
                  key: AI_GATEWAY_DATABASE_URL
            - name: AI_GATEWAY_DATABASE_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_CRITICAL_MAX_CONNS
              value: "0"
            - name: AI_GATEWAY_DATABASE_RIVER_MAX_CONNS
              value: "0"
            - name: AI_GATEWAY_DATABASE_MIN_IDLE_CONNS
              value: "1"
            - name: AI_GATEWAY_WORKER_DATABASE_MAX_CONNS
              value: "32"
            - name: AI_GATEWAY_POSTGRES_NON_WORKER_CONNECTION_BUDGET
              value: "36"
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
          ports:
            - name: health
              containerPort: 8088
          startupProbe:
            httpGet:
              path: /healthz
              port: health
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 24
          readinessProbe:
            httpGet:
              path: /readyz
              port: health
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /healthz
              port: health
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 200m
              memory: 256Mi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: temporary-files
              mountPath: /tmp
      volumes:
        - name: temporary-files
          emptyDir:
            sizeLimit: 64Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-api-hongkong
  labels:
    app.kubernetes.io/name: easyai-api
    app.kubernetes.io/component: api
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-api
      easyai.io/site: hongkong
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-api
        app.kubernetes.io/component: api
        app.kubernetes.io/part-of: easyai-ai-gateway
        easyai.io/site: hongkong
    spec:
      serviceAccountName: easyai-ai-gateway
      terminationGracePeriodSeconds: 90
      nodeSelector:
        easyai.io/site: hongkong
        easyai.io/workload: "true"
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        fsGroup: 10001
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: api
          image: easyai-api
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: easyai-ai-gateway-config
            - secretRef:
                name: easyai-ai-gateway-runtime
          env:
            - name: AI_GATEWAY_PROCESS_ROLE
              value: api
            - name: AI_GATEWAY_ASYNC_QUEUE_WORKER_ENABLED
              value: "false"
            - name: AI_GATEWAY_ASYNC_ADMISSION_DISPATCHER_ENABLED
              value: "true"
            - name: AI_GATEWAY_DATABASE_MAX_CONNS
              value: "32"
            - name: AI_GATEWAY_DATABASE_CRITICAL_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_RIVER_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_MIN_IDLE_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_MAX_CONN_IDLE_SECONDS
              value: "30"
            - name: AI_GATEWAY_MEDIA_REQUEST_CONCURRENCY
              value: "16"
            - name: AI_GATEWAY_MEDIA_MATERIALIZATION_CONCURRENCY
              value: "8"
            - name: AI_GATEWAY_MEDIA_IMAGE_NORMALIZATION_CONCURRENCY
              value: "2"
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_KEY_ID
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_SECRET
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_SECRET_KEY
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
            - name: EASYAI_SITE
              value: hongkong
          ports:
            - name: http
              containerPort: 8088
          startupProbe:
            httpGet:
              path: /api/v1/healthz
              port: http
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 120
          readinessProbe:
            httpGet:
              path: /api/v1/readyz
              port: http
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /api/v1/healthz
              port: http
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "sleep 10"]
          resources:
            requests:
              cpu: 250m
              memory: 512Mi
            limits:
              cpu: "2"
              memory: 2Gi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: application-data
              mountPath: /app/data
            - name: temporary-files
              mountPath: /tmp
      volumes:
        - name: application-data
          emptyDir:
            sizeLimit: 5Gi
        - name: temporary-files
          emptyDir:
            sizeLimit: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-worker-ningbo
  labels:
    app.kubernetes.io/name: easyai-worker
    app.kubernetes.io/component: worker
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-worker
      easyai.io/site: ningbo
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-worker
        app.kubernetes.io/component: worker
        app.kubernetes.io/part-of: easyai-ai-gateway
        easyai.io/site: ningbo
    spec:
      serviceAccountName: easyai-ai-gateway
      terminationGracePeriodSeconds: 90
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - topologyKey: kubernetes.io/hostname
              labelSelector:
                matchLabels:
                  app.kubernetes.io/name: easyai-worker
                  easyai.io/site: ningbo
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: kubernetes.io/hostname
          whenUnsatisfiable: DoNotSchedule
          labelSelector:
            matchLabels:
              app.kubernetes.io/name: easyai-worker
              easyai.io/site: ningbo
      nodeSelector:
        easyai.io/site: ningbo
        easyai.io/workload: "true"
        easyai.io/worker: "true"
      tolerations:
        - key: easyai.io/worker-only
          operator: Equal
          value: "true"
          effect: NoSchedule
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        fsGroup: 10001
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: worker
          image: easyai-api
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: easyai-ai-gateway-config
            - secretRef:
                name: easyai-ai-gateway-runtime
          env:
            - name: AI_GATEWAY_PROCESS_ROLE
              value: worker
            - name: AI_GATEWAY_ASYNC_QUEUE_WORKER_ENABLED
              value: "true"
            - name: AI_GATEWAY_ASYNC_ADMISSION_DISPATCHER_ENABLED
              value: "false"
            - name: AI_GATEWAY_DATABASE_MAX_CONNS
              value: "32"
            - name: AI_GATEWAY_DATABASE_CRITICAL_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_RIVER_MAX_CONNS
              value: "8"
            - name: AI_GATEWAY_DATABASE_MIN_IDLE_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_MAX_CONN_IDLE_SECONDS
              value: "30"
            - name: AI_GATEWAY_ASYNC_WORKER_INSTANCE_HARD_LIMIT
              value: "24"
            - name: AI_GATEWAY_ASYNC_ADMISSION_MICROBATCH_SIZE
              value: "8"
            - name: AI_GATEWAY_MEDIA_MATERIALIZATION_CONCURRENCY
              value: "24"
            - name: AI_GATEWAY_MEDIA_REQUEST_CONCURRENCY
              value: "24"
            - name: AI_GATEWAY_MEDIA_IMAGE_NORMALIZATION_CONCURRENCY
              value: "2"
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_KEY_ID
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_SECRET
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_SECRET_KEY
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
            - name: EASYAI_SITE
              value: ningbo
          ports:
            - name: health
              containerPort: 8088
          startupProbe:
            httpGet:
              path: /healthz
              port: health
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 120
          readinessProbe:
            httpGet:
              path: /readyz
              port: health
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /healthz
              port: health
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "sleep 10"]
          resources:
            requests:
              cpu: 500m
              memory: 1536Mi
            limits:
              cpu: "2"
              memory: 2Gi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: application-data
              mountPath: /app/data
            - name: temporary-files
              mountPath: /tmp
      volumes:
        - name: application-data
          emptyDir:
            sizeLimit: 5Gi
        - name: temporary-files
          emptyDir:
            sizeLimit: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-worker-hongkong
  labels:
    app.kubernetes.io/name: easyai-worker
    app.kubernetes.io/component: worker
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-worker
      easyai.io/site: hongkong
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-worker
        app.kubernetes.io/component: worker
        app.kubernetes.io/part-of: easyai-ai-gateway
        easyai.io/site: hongkong
    spec:
      serviceAccountName: easyai-ai-gateway
      terminationGracePeriodSeconds: 90
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - topologyKey: kubernetes.io/hostname
              labelSelector:
                matchLabels:
                  app.kubernetes.io/name: easyai-worker
                  easyai.io/site: hongkong
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: kubernetes.io/hostname
          whenUnsatisfiable: DoNotSchedule
          labelSelector:
            matchLabels:
              app.kubernetes.io/name: easyai-worker
              easyai.io/site: hongkong
      nodeSelector:
        easyai.io/site: hongkong
        easyai.io/workload: "true"
        easyai.io/worker: "true"
      tolerations:
        - key: easyai.io/worker-only
          operator: Equal
          value: "true"
          effect: NoSchedule
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        fsGroup: 10001
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: worker
          image: easyai-api
          imagePullPolicy: IfNotPresent
          envFrom:
            - configMapRef:
                name: easyai-ai-gateway-config
            - secretRef:
                name: easyai-ai-gateway-runtime
          env:
            - name: AI_GATEWAY_PROCESS_ROLE
              value: worker
            - name: AI_GATEWAY_ASYNC_QUEUE_WORKER_ENABLED
              value: "true"
            - name: AI_GATEWAY_ASYNC_ADMISSION_DISPATCHER_ENABLED
              value: "false"
            - name: AI_GATEWAY_DATABASE_MAX_CONNS
              value: "32"
            - name: AI_GATEWAY_DATABASE_CRITICAL_MAX_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_RIVER_MAX_CONNS
              value: "8"
            - name: AI_GATEWAY_DATABASE_MIN_IDLE_CONNS
              value: "4"
            - name: AI_GATEWAY_DATABASE_MAX_CONN_IDLE_SECONDS
              value: "30"
            - name: AI_GATEWAY_ASYNC_WORKER_INSTANCE_HARD_LIMIT
              value: "24"
            - name: AI_GATEWAY_ASYNC_ADMISSION_MICROBATCH_SIZE
              value: "8"
            - name: AI_GATEWAY_MEDIA_MATERIALIZATION_CONCURRENCY
              value: "24"
            - name: AI_GATEWAY_MEDIA_REQUEST_CONCURRENCY
              value: "24"
            - name: AI_GATEWAY_MEDIA_IMAGE_NORMALIZATION_CONCURRENCY
              value: "2"
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_KEY_ID
            - name: AI_GATEWAY_MEDIA_OSS_ACCESS_KEY_SECRET
              valueFrom:
                secretKeyRef:
                  name: easyai-oss-backup
                  key: ACCESS_SECRET_KEY
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_UID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.uid
            - name: EASYAI_SITE
              value: hongkong
          ports:
            - name: health
              containerPort: 8088
          startupProbe:
            httpGet:
              path: /healthz
              port: health
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 120
          readinessProbe:
            httpGet:
              path: /readyz
              port: health
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /healthz
              port: health
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "sleep 10"]
          resources:
            requests:
              cpu: 500m
              memory: 1536Mi
            limits:
              cpu: "2"
              memory: 2Gi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: application-data
              mountPath: /app/data
            - name: temporary-files
              mountPath: /tmp
      volumes:
        - name: application-data
          emptyDir:
            sizeLimit: 5Gi
        - name: temporary-files
          emptyDir:
            sizeLimit: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-web-ningbo
  labels:
    app.kubernetes.io/name: easyai-web
    app.kubernetes.io/component: web
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-web
      easyai.io/site: ningbo
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-web
        app.kubernetes.io/component: web
        app.kubernetes.io/part-of: easyai-ai-gateway
        easyai.io/site: ningbo
    spec:
      automountServiceAccountToken: false
      terminationGracePeriodSeconds: 30
      nodeSelector:
        easyai.io/site: ningbo
        easyai.io/workload: "true"
      securityContext:
        runAsNonRoot: true
        runAsUser: 101
        runAsGroup: 101
        fsGroup: 101
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: web
          image: easyai-web
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
          readinessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 500m
              memory: 256Mi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
              add: ["NET_BIND_SERVICE"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: nginx-cache
              mountPath: /var/cache/nginx
            - name: nginx-run
              mountPath: /var/run
      volumes:
        - name: nginx-cache
          emptyDir:
            sizeLimit: 128Mi
        - name: nginx-run
          emptyDir:
            sizeLimit: 16Mi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: easyai-web-hongkong
  labels:
    app.kubernetes.io/name: easyai-web
    app.kubernetes.io/component: web
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-web
      easyai.io/site: hongkong
  template:
    metadata:
      labels:
        app.kubernetes.io/name: easyai-web
        app.kubernetes.io/component: web
        app.kubernetes.io/part-of: easyai-ai-gateway
        easyai.io/site: hongkong
    spec:
      automountServiceAccountToken: false
      terminationGracePeriodSeconds: 30
      nodeSelector:
        easyai.io/site: hongkong
        easyai.io/workload: "true"
      securityContext:
        runAsNonRoot: true
        runAsUser: 101
        runAsGroup: 101
        fsGroup: 101
        fsGroupChangePolicy: OnRootMismatch
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: web
          image: easyai-web
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
          readinessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 6
          livenessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 500m
              memory: 256Mi
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: ["ALL"]
              add: ["NET_BIND_SERVICE"]
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: nginx-cache
              mountPath: /var/cache/nginx
            - name: nginx-run
              mountPath: /var/run
      volumes:
        - name: nginx-cache
          emptyDir:
            sizeLimit: 128Mi
        - name: nginx-run
          emptyDir:
            sizeLimit: 16Mi
---
apiVersion: v1
kind: Service
metadata:
  name: api
  labels:
    app.kubernetes.io/name: easyai-api
    app.kubernetes.io/component: api
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name: easyai-api
  ports:
    - name: http
      port: 8088
      targetPort: http
      nodePort: 30088
---
apiVersion: v1
kind: Service
metadata:
  name: web
  labels:
    app.kubernetes.io/name: easyai-web
    app.kubernetes.io/component: web
    app.kubernetes.io/part-of: easyai-ai-gateway
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name: easyai-web
  ports:
    - name: http
      port: 80
      targetPort: http
      nodePort: 30178
---
apiVersion: v1
kind: Service
metadata:
  name: api-ningbo-edge
  labels:
    app.kubernetes.io/name: easyai-api
    app.kubernetes.io/component: api
    app.kubernetes.io/part-of: easyai-ai-gateway
    easyai.io/site: ningbo
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name: easyai-api
    easyai.io/site: ningbo
  ports:
    - name: http
      port: 8088
      targetPort: http
      nodePort: 31088
---
apiVersion: v1
kind: Service
metadata:
  name: api-hongkong-edge
  labels:
    app.kubernetes.io/name: easyai-api
    app.kubernetes.io/component: api
    app.kubernetes.io/part-of: easyai-ai-gateway
    easyai.io/site: hongkong
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name: easyai-api
    easyai.io/site: hongkong
  ports:
    - name: http
      port: 8088
      targetPort: http
      nodePort: 31089
---
apiVersion: v1
kind: Service
metadata:
  name: web-ningbo-edge
  labels:
    app.kubernetes.io/name: easyai-web
    app.kubernetes.io/component: web
    app.kubernetes.io/part-of: easyai-ai-gateway
    easyai.io/site: ningbo
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name: easyai-web
    easyai.io/site: ningbo
  ports:
    - name: http
      port: 80
      targetPort: http
      nodePort: 31178
---
apiVersion: v1
kind: Service
metadata:
  name: web-hongkong-edge
  labels:
    app.kubernetes.io/name: easyai-web
    app.kubernetes.io/component: web
    app.kubernetes.io/part-of: easyai-ai-gateway
    easyai.io/site: hongkong
spec:
  type: NodePort
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name: easyai-web
    easyai.io/site: hongkong
  ports:
    - name: http
      port: 80
      targetPort: http
      nodePort: 31179
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: easyai-api
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-api
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: easyai-web
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-web
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: easyai-capacity-controller
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-capacity-controller
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: easyai-worker
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: easyai-worker
