apiVersion: apps/v1
kind: Deployment
metadata:
  name: ray-worker
  namespace: dev
spec:
  replicas: 2
  selector:
    matchLabels:
      component: ray-worker
      type: ray
  template:
    metadata:
      labels:
        component: ray-worker
        type: ray
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchLabels:
                type: ray
            topologyKey: kubernetes.io/hostname
      containers:
        - name: ray-worker
          image: rayproject/examples
          command: ["/bin/bash", "-c", "--"]
          args: ["ray start --node-ip-address=$MY_POD_IP --redis-address=$(python -c 'import socket;import sys; sys.stdout.write(socket.gethostbyname(\"ray-head\"));sys.stdout.flush()'):6379 --object-manager-port=12345 --node-manager-port=12346 --block"]
          ports:
            - containerPort: 12345
            - containerPort: 12346
          env:
            - name: MY_POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
#           resources:
#             requests:
#               cpu: 1
