---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: mapping-backfill
  name: execution
spec:
  selector:
    matchLabels:
      app: work-queue
  template:
    metadata:
      labels:
        app: work-queue
    spec:
      containers:
        - name: work-queue
          image: redis
          env:
            - name: MASTER
              value: "true"
          ports:
            - containerPort: 6379
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  namespace: mapping-backfill
  name: work-queue
spec:
  selector:
    app: work-queue
  ports:
    - protocol: TCP
      port: 6379
      targetPort: 6379
---
apiVersion: v1
kind: ServiceAccount
metadata:
  namespace: mapping-backfill
  name: dispatch-svc
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: mapping-backfill
  name: job-creator
rules:
  - apiGroups:
      - ""
    resources:
      - pods
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - batch
    resources:
      - jobs
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - batch
    resources:
      - jobs
    verbs:
      - create
      - delete
      - deletecollection
      - patch
      - update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: mapping-backfill
  name: create-jobs
subjects:
  - kind: ServiceAccount
    name: dispatch-svc
    namespace: mapping-backfill
roleRef:
  kind: Role
  name: job-creator
  apiGroup: rbac.authorization.k8s.io
