---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kutt
spec:
  replicas: 2
  selector:
    matchLabels:
      app: kutt
  template:
    metadata:
      labels:
        app: kutt
    spec:
      imagePullSecrets:
        - name: github-registry-secret
      containers:
      - name: web
        image: kutt/kutt
        ports:
        - containerPort: 3000
          protocol: TCP
        readinessProbe:
          httpGet:
            path: /api/v2/health
            port: 3000
          initialDelaySeconds: 30
          periodSeconds: 5
        livenessProbe:
          httpGet:
            path: /api/v2/health
            port: 3000
          initialDelaySeconds: 20
          periodSeconds: 5
        env:
        - name: DD_AGENT_HOST
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        envFrom:
        - configMapRef:
            name: kutt
        - secretRef:
            name: kutt
      initContainers:
      - name: web-migrate
        image: kutt/kutt
        command: ["npm"]
        args: ["run", "migrate"]
        env:
        - name: DD_AGENT_HOST
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        envFrom:
        - configMapRef:
            name: kutt
        - secretRef:
            name: kutt
