0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EKS上のRay ClusterにNLB経由でジョブを投入

Posted at

この記事で作成したRay ClusterにInternal NLB経由でジョブを登録してみます。

前提

設定

Ray clusterのHeadサービスのLabelを取得します。

$ kubectl get service/ray-cluster-kuberay-head-svc -n ray-cluster -o jsonpath='{.metadata.labels}' | jq
{
  "app.kubernetes.io/created-by": "kuberay-operator",
  "app.kubernetes.io/name": "kuberay",
  "ray.io/cluster": "ray-cluster-kuberay",
  "ray.io/identifier": "ray-cluster-kuberay-head",
  "ray.io/node-type": "head"
}

上記の内容を下に以下の設定をすることでNLBが作成されます。

---
apiVersion: v1 
kind: Service
metadata:
  namespace: ray-cluster
  name: ray-nlb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-name: ray-cluster-nlb
    service.beta.kubernetes.io/aws-load-balancer-type: nlb
    service.beta.kubernetes.io/aws-load-balancer-scheme: internal
    service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip"
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "tcp"
    service.beta.kubernetes.io/aws-load-balancer-target-group-attributes: preserve_client_ip.enabled=false
spec:
  type: LoadBalancer
  ports:
  - name: client
    port: 10001
    protocol: TCP
    targetPort: 10001
  selector:
    ray.io/cluster: ray-cluster-kuberay
    ray.io/identifier: ray-cluster-kuberay-head
    ray.io/node-type: head

後は以下のようにNLBのDNSをホスト名に指定して接続確認をします。

import ray
from pprint import pprint
ray.init(address='ray://ray-cluster-nlb-xxxxxxx.elb.ap-northeast-1.amazonaws.com:10001')
pprint(ray.cluster_resources())
### 出力
#{'CPU': 2.0,
# 'memory': 3000000000.0,
# 'node:10.2.2.144': 1.0,
# 'node:10.2.8.136': 1.0,
# 'node:__internal_head__': 1.0,
# 'object_store_memory': 785237605.0}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?