---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sinker
  namespace: default
  labels:
    app: sinker
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sinker
  template:
    metadata:
      labels:
        app: sinker
    spec:
      serviceAccountName: sinker
      containers:
      - name: sinker
        image: us-central1-docker.pkg.dev/gob-prow/prow-images/sinker:v20250423-91b28ca9b
        args:
        - --config-path=/etc/config/config.yaml
        - --job-config-path=/etc/job-config
        - --dry-run=false
        env:
        # Use KUBECONFIG envvar rather than --kubeconfig flag in order to provide multiple configs to merge.
        - name: KUBECONFIG
          value: "/etc/kubeconfig/config-20240403:/etc/build-openshift-eng/kubeconfig:/etc/build-cloud-kubernetes-node-management-team/kubeconfig:/etc/build-kpt-config-sync/kubeconfig:/etc/build-compute-image-import/kubeconfig:/etc/build-blueprints/kubeconfig:/etc/build-elcarro/kubeconfig:/etc/gke-gcloud-auth-plugin-based/kubeconfigs.yaml"
        ports:
        - name: metrics
          containerPort: 9090
        volumeMounts:
        - mountPath: /etc/build-openshift-eng
          name: build-openshift-eng
          readOnly: true
        - mountPath: /etc/build-cloud-kubernetes-node-management-team
          name: build-cloud-kubernetes-node-management-team
          readOnly: true
        - mountPath: /etc/build-kpt-config-sync
          name: build-kpt-config-sync
          readOnly: true
        - mountPath: /etc/build-compute-image-import
          name: build-compute-image-import
          readOnly: true
        - mountPath: /etc/build-blueprints
          name: build-blueprints
          readOnly: true
        - mountPath: /etc/build-elcarro
          name: build-elcarro
          readOnly: true
        - name: config
          mountPath: /etc/config
          readOnly: true
        - name: job-config
          mountPath: /etc/job-config
          readOnly: true
        - mountPath: /etc/kubeconfig
          name: kubeconfig
          readOnly: true
        - mountPath: /etc/gke-gcloud-auth-plugin-based
          name: kubeconfigs
          readOnly: true
      volumes:
      - name: build-openshift-eng
        secret:
          defaultMode: 420
          secretName: kubeconfig-build-openshift-eng
      - name: build-cloud-kubernetes-node-management-team
        secret:
          defaultMode: 420
          secretName: kubeconfig-build-cloud-kubernetes-node-management-team
      - name: build-kpt-config-sync
        secret:
          defaultMode: 420
          secretName: kubeconfig-build-kpt-config-sync
      - name: build-compute-image-import
        secret:
          defaultMode: 420
          secretName: kubeconfig-build-compute-image-import
      - name: build-blueprints
        secret:
          defaultMode: 420
          secretName: kubeconfig-build-blueprints
      - name: build-elcarro
        secret:
          defaultMode: 420
          secretName: kubeconfig-build-elcarro
      - name: config
        configMap:
          name: config
      - name: job-config
        configMap:
          name: job-config
      - name: kubeconfig
        secret:
          defaultMode: 420
          secretName: kubeconfig
      - name: kubeconfigs
        configMap:
          name: kubeconfigs
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: sinker
  namespace: default
  annotations:
    "iam.gke.io/gcp-service-account": "oss-prow@oss-prow.iam.gserviceaccount.com"
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: sinker
  # namespace: not-namespaced, delete pods in other namespaces
rules:
  - apiGroups:
    - coordination.k8s.io
    resources:
    - leases
    resourceNames:
    - prow-sinker-leaderlock
    verbs:
    - get
    - update
  - apiGroups:
    - coordination.k8s.io
    resources:
    - leases
    verbs:
    - create
  - apiGroups:
      - ""
    resources:
      - pods
    verbs:
      - delete
      - list
      - watch
      - get
      - patch
  - apiGroups:
      - "prow.k8s.io"
    resources:
      - prowjobs
    verbs:
      - delete
      - list
      - watch
      - get
  - apiGroups:
      - ""
    resources:
      - configmaps
    resourceNames:
      - prow-sinker-leaderlock
    verbs:
      - get
      - update
  - apiGroups:
      - ""
    resources:
      - configmaps
      - events
    verbs:
      - create
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: sinker
  namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: "sinker"
subjects:
- kind: ServiceAccount
  name: "sinker"
  namespace: "default"
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sinker
  namespace: default
  name: sinker
spec:
  ports:
    - name: metrics
      port: 9090
  selector:
    app: sinker
