apiVersion: apps/v1
kind: Deployment
metadata:
  name: musicgen
  labels:
    app: musicgen
spec:
  replicas: 1
  selector:
    matchLabels:
      app: musicgen
  template:
    metadata:
      labels:
        app: musicgen
    spec:
      serviceAccountName: composer-service-account
      terminationGracePeriodSeconds: 130
      nodeSelector:
        karpenter.k8s.aws/instance-family: g4dn
      containers:
      - name: musicgen
        image: 035363416972.dkr.ecr.us-east-1.amazonaws.com/minimal:latest
        command: [ "/opt/entrypoint.sh" ]
        env:
        - name: QUEUE_NAME
          value: "musicgen_requests_beta_2"
        - name: MAX_RUNTIME
          value: "120000"
        - name: HEALTHCHECK_PATH
          value: "/musicgen_ready"
        - name: REDIS_HOST
          value: "prod-redis.redis.svc.cluster.local"
        - name: REDIS_PORT
          value: "26379"
        - name: REDIS_SENTINEL_NAME
          value: "wavtoolmaster"
        - name: MUSICGEN_S3_BUCKET
          value: "samples-test-1"
        - name: MUSICGEN_MODEL
          value: "facebook/musicgen-stereo-large"
        envFrom:
        - secretRef:
            name: redis-secret
        resources:
          limits:
            nvidia.com/gpu: 1
        readinessProbe:
          exec:
            command:
              - cat
              - /musicgen_ready
          periodSeconds: 5
          failureThreshold: 10
        volumeMounts:
        - name: persistent-storage
          mountPath: /opt
          subPath: musicgen_2024-05-21
        - name: memory-backed-temp
          mountPath: /tmp
          subPath: musicgen
        lifecycle:
          preStop:
            exec:
              command: [ "/bin/sleep", "120" ]
      volumes:
      - name: persistent-storage
        persistentVolumeClaim:
          claimName: efs-claim
      - name: memory-backed-temp
        emptyDir:
          medium: Memory
          sizeLimit: 4Gi
