apiVersion: apps/v1
kind: Deployment
metadata:
  name: tensorflow-serving
  namespace: jetson-tensorflow-serving
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tensorflow-serving
  template:
    metadata:
      name: tensorflow-serving
      labels:
        app: tensorflow-serving
    spec:
      hostname: tensorflow-serving
      containers:
        - name: tensorflow-serving
          image: max-one.local:5001/jetson/nano/tensorflow-serving
          volumeMounts:
            - mountPath: /dev/nvhost-ctrl
              name: nvhost-ctrl
            - mountPath: /dev/nvhost-ctrl-gpu
              name: nvhost-ctrl-gpu
            - mountPath: /dev/nvhost-prof-gpu
              name: nvhost-prof-gpu
            - mountPath: /dev/nvmap
              name: nvmap
            - mountPath: /dev/nvhost-gpu
              name: nvhost-gpu
            - mountPath: /dev/nvhost-as-gpu
              name: nvhost-as-gpu
          securityContext:
            privileged: true
          ports:
            - containerPort: 80
              name: webservice
            - containerPort: 8500
              name: grpc
            - containerPort: 8501
              name: rest
          readinessProbe:
            httpGet:
              path: /api/v1/health/healthz
              port: 80
              httpHeaders:
                - name: User-Agent
                  value: "k8s (readiness probe)"
            timeoutSeconds: 5
            initialDelaySeconds: 15
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          livenessProbe:
            httpGet:
              path: /api/v1/health/healthz
              port: 80
              httpHeaders:
                - name: User-Agent
                  value: "k8s (liveness probe)"
            timeoutSeconds: 5
            initialDelaySeconds: 15
            periodSeconds: 15
            successThreshold: 1
            failureThreshold: 2
      volumes:
        - name: nvhost-ctrl
          hostPath:
            path: /dev/nvhost-ctrl
        - name: nvhost-ctrl-gpu
          hostPath:
            path: /dev/nvhost-ctrl-gpu
        - name: nvhost-prof-gpu
          hostPath:
            path: /dev/nvhost-prof-gpu
        - name: nvmap
          hostPath:
            path: /dev/nvmap
        - name: nvhost-gpu
          hostPath:
            path: /dev/nvhost-gpu
        - name: nvhost-as-gpu
          hostPath:
            path: /dev/nvhost-as-gpu
      nodeSelector:
        jetson_model: "nano"
