apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: {{ .Values.namespace }}
  name: stream-computation
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: stream-computation
  template:
    metadata:
      labels:
        app: stream-computation
    spec:
      nodeSelector:
        {{- range $key, $value := .Values.nodeSelector }}
        {{ $key }}: {{ $value }}
        {{- end }}

      volumes:
      - name: data
        hostPath:
          path: /data/stream-computation/

      containers:
      - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        name: stream-computation
        {{- if eq .Values.namespace "prod-sfox" }}
        imagePullPolicy: Always
        {{- else }}
        imagePullPolicy: IfNotPresent
        {{- end }}
        ports:
          - containerPort: 3000
            hostPort: 30000
        resources:
          requests:
            memory: "100Mi"
          limits:
            memory: "600Mi"
        securityContext:
          privileged: true
          capabilities:
            add:
              - IPC_LOCK
              - SYS_RESOURCE
        env:
        - name: ENV
          value: {{ .Values.env }}
        - name: TZ
          value: "Asia/Shanghai"

        volumeMounts:
        - name: data
          mountPath: /app/data/

      imagePullSecrets:
        - name: aliyun-singapore-registry

  strategy:
    type: Recreate
