apiVersion: apps/v1
kind: Deployment
metadata:
  name: eleuther-megatron
spec:
  strategy:
    type: Recreate
  replicas: 4
  selector:
    matchLabels:
      app.kubernetes.io/name: eleuther-megatron
  template:
    metadata:
      labels:
        app.kubernetes.io/name: eleuther-megatron
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: neox
        command: ["sudo"]
        args: ["/usr/sbin/sshd", "-D"]
        tty: true
        image: leogao2/megatron-3d
        ports:
          - name: sshd
            containerPort: 2222
            protocol: TCP
        volumeMounts:
          - mountPath: /dev/shm
            name: dshm
          - name: secret-volume
            readOnly: true
            mountPath: "/secrets"
          - name: data-storage
            mountPath: /mnt/ssd-0
            readOnly: true
          - name: cluster-storage
            mountPath: /mnt/ssd-cluster
            readOnly: false
        resources:
          requests:
            cpu: 30
            memory: 40Gi
          limits:
            nvidia.com/gpu: 8
        lifecycle:
          postStart:
            exec:
              command: [ "/bin/bash", "/secrets/post_start_script.sh" ]

      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              # Edit for different GPU
              - key: gpu.nvidia.com/model
                operator: In
                values:
                  - GeForce_RTX_2080_Ti
              - key: failure-domain.beta.kubernetes.io/region
                operator: In
                values:
                  - ORD1
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
        - name: secret-volume
          secret:
            secretName: ----secret-name----
            defaultMode: 0777
        - name: data-storage
          persistentVolumeClaim:
            claimName: eleuther-ssd-0
            readOnly: true
        - name: cluster-storage
          persistentVolumeClaim:
            claimName: eleuther-ssd-cluster
            readOnly: false
      restartPolicy: Always
