apiVersion: apps/v1
kind: Deployment
metadata:
  name: rustdesk-server
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: rustdesk
  template:
    metadata:
      labels:
        app: rustdesk
    spec:
      containers:
        # id Server (HBBS)
        - name: hbbs
          image: rustdesk/rustdesk-server:latest
          env:
            - name: RELAY_HOST
              value: "rustdesk.yourdomain.tld"
          command: ["hbbs", "-r", "$(RELAY_HOST):21117", "-k", "_"]
          volumeMounts:
            - mountPath: /root
              name: rustdesk-data
          ports:
            - containerPort: 21115
            - containerPort: 21116
              protocol: TCP
            - containerPort: 21116
              protocol: UDP
            - containerPort: 21118

        # Relay Server (HBBR)
        - name: hbbr
          image: rustdesk/rustdesk-server:latest
          command: ["hbbr", "-k", "_"]
          volumeMounts:
            - mountPath: /root
              name: rustdesk-data
          ports:
            - containerPort: 21117
            - containerPort: 21119

      volumes:
        - name: rustdesk-data
          persistentVolumeClaim:
            claimName: rustdesk-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: rustdesk-service
spec:
  type: LoadBalancer # Or NodePort
  selector:
    app: rustdesk
  ports:
    - name: hbbs-tcp
      port: 21115
      targetPort: 21115
      protocol: TCP
    - name: hbbs-udp
      port: 21116
      targetPort: 21116
      protocol: UDP
    - name: hbbs-tcp-main
      port: 21116
      targetPort: 21116
      protocol: TCP
    - name: hbbr-tcp
      port: 21117
      targetPort: 21117
      protocol: TCP
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: rustdesk-pvc
spec:
  accessModes:
    - ReadWriteOnce # RWM would be available only with pro version
  resources:
    requests:
      storage: 1Gi
