---
apiVersion: v1
kind: Service
metadata:
  name: obs-worker
  namespace: obs
  labels:
    app: obs-worker
spec:
  ports:
  - port: 44044
    name: obs-worker
  clusterIP: None
  selector:
    app: obs-worker
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: obs-worker
  namespace: obs
spec:
  replicas: 4
  serviceName: obs-worker
  selector:
    matchLabels:
      app: obs-worker
  template:
    metadata:
      labels:
        app: obs-worker
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - store
            topologyKey: "kubernetes.io/hostname"
      containers:
        - name: obs-worker
          image: <my private docker-registry>/obs/obs-worker
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          resources:
            requests:
              cpu: 4
            limits:
              cpu: 4
          livenessProbe:
            initialDelaySeconds: 30
            timeoutSeconds: 5
            exec:
              command:
              - /bin/sh
              - -c
              - ps aux | grep bs_worker | grep -v grep
      nodeSelector:
        prod_services: "true"
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: obs-worker
  namespace: obs
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: StatefulSet
    name: obs-worker
  minReplicas: 2
  maxReplicas: 12
  targetCPUUtilizationPercentage: 5
