apiVersion: apps/v1
kind: Deployment 
metadata:
  name: rank
spec:
  replicas: 1
  selector:
    matchLabels:
      app: rank 
  template:
    metadata:
      labels: 
        app: rank 
    spec:
      terminationGracePeriodSeconds: 5
      containers:
      - name: rs-rank
        image:  rs/rank:latest
        ports:
          - name: http
            containerPort: 5400
        resources:
          requests: 
            cpu: 500m
            memory: 512Mi
          limits:
            cpu: 2000m
            memory: 2048Mi
        env:
          - name: REDIS_HOST
            value: $(MESSGE_BROKER_REDIS_HOST)
          - name: REDIS_PORT
            value: $(MESSGE_BROKER_REDIS_PORT)
          - name: RANK_PORT
            value: "5400"
      - name: rs-rank-plugin
        image:  rs/rank-plugin:latest
        ports:
          - name: http
            containerPort: 50051
        resources:
          requests: 
            cpu: 2000m
            memory: 4096Mi
          limits:
            cpu: 4000m
            memory: 8192Mi
        env:
          - name: LOCAL_DATA_FOLDER
            value: $(LOCAL_DATA_FOLDER)
          - name: MODEL_EXTRACT_DIR
            value: /opt/ml/model/  
          - name: NEWS_ID_ENTITY_IDS
            value: news_id_entity_ids_dict.pickle
          - name: NEWS_ID_WORD_IDS
            value: news_id_word_ids_dict.pickle
          - name: ENTITY_EMBEDDING_NPY
            value: dkn_entity_embedding.npy
          - name: CONTEXT_EMBEDDING_NPY
            value: dkn_context_embedding.npy
          - name: WORD_EMBEDDING_NPY
            value: dkn_word_embedding.npy
          - name: AWS_REGION
            value: $(AWS_REGION)
          - name: S3_BUCKET
            value: $(S3_BUCKET)
          - name: S3_PREFIX
            value: $(S3_PREFIX)
          - name: METHOD
            value: $(METHOD)
        volumeMounts:
          - name: persistent-storage
            mountPath: /rs-data
      volumes:
        - name: persistent-storage
          persistentVolumeClaim:
            claimName: efs-claim