apiVersion: apps/v1
kind: Deployment
metadata:
  name: <SANDBOX>
  labels:
    app: <SANDBOX>
spec:
  replicas: 1
  selector:
    matchLabels:
      app: <SANDBOX>
  template:
    metadata:
      labels:
        app: <SANDBOX>
    spec:
      volumes:
        - name: workspace-volume
          emptyDir: {}
      containers:
        - name: runner
          image: ishaan1013/sandbox:latest
          ports:
            - containerPort: 4000
            - containerPort: 3000
          volumeMounts:
            - name: workspace-volume
              mountPath: /workspace
          resources:
            requests:
              cpu: "1"
              memory: "1Gi"
            limits:
              cpu: "1"
              memory: "1Gi"
            env:
              - name: CF_API_TOKEN
                value: <CF_API_TOKEN>
              - name: CF_USER_ID
                value: <CF_USER_ID>

---
apiVersion: v1
kind: Service
metadata:
  name: <SANDBOX>
spec:
  selector:
    app: <SANDBOX>
  ports:
    - protocol: TCP
      name: ws
      port: 4000
      targetPort: 4000
    - protocol: TCP
      name: user
      port: 3000
      targetPort: 3000
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: <SANDBOX>
spec:
  ingressClassName: nginx
  rules:
    - host: <SANDBOX>.ws.ishaand.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: <SANDBOX>
                port:
                  number: 4000
    - host: <SANDBOX>.s.ishaand.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: <SANDBOX>
                port:
                  number: 3000
