apiVersion: batch/v1
kind: Job
metadata:
  name: team-script-${plugin_id}
spec:
  template:
    spec:
      nodeSelector:
        orbit/usage: teams
        orbit/node-type: ec2
        orbit/attach-security-group: "yes"
      serviceAccountName: ${team}
      securityContext:
        fsGroup: 100
      containers:
      - name: kubectl-aws
        securityContext:
          runAsUser: 1000
        imagePullPolicy: Always
        image: ${account_id}.dkr.ecr.${region}.amazonaws.com/orbit-${env_name}-jupyter-user:${tag}
        env:
          - name: AWS_DEFAULT_REGION
            value: ${region}
          - name: ENV_NAME
            value: ${env_name}
          - name: TEAM
            value: ${team}
          - name: AWS_STS_REGIONAL_ENDPOINTS
            value: regional
        command: ["/bin/bash"]
        args:
          - -c
          - >-
            ln -s /efs/shared /home/jovyan/shared &&
            source /scripts/${plugin_id}-script.sh &&
            echo "DONE EXECUTING SCRIPT"
        volumeMounts:
          - mountPath: /efs
            name: efs-volume
          - name: scripts
            mountPath: /scripts
      volumes:
        - name: efs-volume
          persistentVolumeClaim:
            claimName: jupyterhub
        - name: scripts
          configMap:
            name: ${plugin_id}-script
            defaultMode: 0744
      restartPolicy: ${restart_policy}