---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: camera-tiler
  annotations:
    keel.sh/policy: force
    keel.sh/trigger: poll
spec:
  revisionHistoryLimit: 0
  replicas: 2
  selector:
    matchLabels: &selectorLabels
      app.kubernetes.io/name: camtiler
      component: camera-tiler
  template:
    metadata:
      labels: *selectorLabels
    spec:
      serviceAccountName: camera-tiler
      containers:
        - name: camera-tiler
          image: harbor.k-space.ee/k-space/camera-tiler:latest
          securityContext:
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            runAsUser: 1000
          ports:
            - containerPort: 5001
              name: "http"
          resources:
            requests:
              memory: "200Mi"
              cpu: "100m"
            limits:
              memory: "500Mi"
              cpu: "4000m"
---
apiVersion: v1
kind: Service
metadata:
  name: camera-tiler
  labels:
    app.kubernetes.io/name: camtiler
    component: camera-tiler
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: camtiler
    component: camera-tiler
  ports:
    - protocol: TCP
      port: 5001
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: camera-tiler
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: camera-tiler
rules:
  - apiGroups:
      - ""
    resources:
      - services
    verbs:
      - list
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: camera-tiler
subjects:
  - kind: ServiceAccount
    name: camera-tiler
    apiGroup: ""
roleRef:
  kind: Role
  name: camera-tiler
  apiGroup: ""
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: camtiler
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: camtiler
      component: camera-tiler
  podMetricsEndpoints:
    - port: http
  podTargetLabels:
    - app.kubernetes.io/name
    - component