apiVersion: apps/v1
kind: Deployment
metadata:
  name: doorbell
spec:
  replicas: 1
  strategy: { type: Recreate }
  selector: { matchLabels: { app: doorbell } }
  template:
    metadata:
      labels: { app: doorbell }
      annotations: { prometheus.io/scrape: "false" }
    spec:
      containers:
        - name: doorbell
          image: bang5:5000/doorbell_image
          args:
            - pdm
            - run
            - python
            - doorbell_to_mqtt.py 
            - /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900cepU-if00-port0
          securityContext: { privileged: true }

          volumeMounts:
            - { name: dev, mountPath: /dev }
      volumes:
        - { name: dev, hostPath: { path: /dev, type: Directory } }

      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            { nodeSelectorTerms: [{ matchExpressions: [{ key: "kubernetes.io/hostname", operator: In, values: ["bang"] }] }] }

---
apiVersion: v1
kind: Service
metadata:
  name: doorbell
spec:
  ports:
  - {port: 80, targetPort: 8000}
  selector:
    app: doorbell
