1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Kubeflowでのプロファイルによるリソース制限

1
Posted at

はじめに

本記事では、KubeflowでユーザまたはグループごとにGPU等の使用可能なリソースを制限するため、プロファイル機能を利用します。
Kubeflowの導入手順はこちらの記事をご参照下さい。

目次

  1. 検証環境
  2. 前提条件
  3. ユーザの作成
  4. プロファイルの作成
  5. Contributorの追加
  6. まとめ
  7. 参考文献

検証環境

以下のKubeflowがデプロイされたKubernetesクラスタにおいて、プロファイル機能を利用します。
k8s-env.png

前提条件

以下の作業が完了していることを想定しています。

  • Kubernetesクラスタが構築済み
  • Kubeflowがデプロイ済み

ユーザの作成

現在のユーザ認証設定をファイルに保存します。

# kubectl get configmap dex -n auth -o jsonpath='{.data.config\.yaml}' > dex-config.yaml

作成したいユーザの初期パスワードのハッシュ値を取得します。 (例えば、入力した文字列のハッシュ値を計算してくれるWebサイトを利用することも可能です)

保存したyamlファイルを編集し、ユーザを追記します。(下の例では、user1@example.com, user2@example.comを追加)

# vi dex-config.yaml

- email: user1@example.com
  hash: $2a$12$/5r3glMmYUi0jBFhfhSKCeoRV7rNI3c/06om/OQ2Txr0pyFRc3Zqy
  username: user1
- email: user2@example.com
  hash: $2a$12$/5r3glMmYUi0jBFhfhSKCeoRV7rNI3c/06om/OQ2Txr0pyFRc3Zqy
  username: user2

編集したyamlファイルを適用し、ユーザ追加を有効化します。

# kubectl create configmap dex --from-file=config.yaml=dex-config.yaml -n auth --dry-run -o yaml | kubectl apply -f -
# kubectl rollout restart deployment dex -n auth

プロファイルの作成

プロファイルを定義したyamlファイルを作成します。以下の例では、profile1とprofile2を定義しています。各プロファイルで必要なCPU/メモリー/GPU/Volume容量を指定します。

# vi profile.yaml

apiVersion: kubeflow.org/v1beta1
kind: Profile
metadata:
  name: profile1
spec:
  owner:
    kind: User
    name: user1@example.com

  resourceQuotaSpec:
   hard:
     cpu: "5"
     memory: 10Gi
     requests.nvidia.com/gpu: "1"
     persistentvolumeclaims: "5"
     requests.storage: "40Gi"
---
apiVersion: kubeflow.org/v1beta1
kind: Profile
metadata:
  name: profile2
spec:
  owner:
    kind: User
    name: user2@example.com

  resourceQuotaSpec:
   hard:
     cpu: "10"
     memory: 10Gi
     requests.nvidia.com/gpu: "1"
     persistentvolumeclaims: "5"
     requests.storage: "30Gi"

定義したプロファイルを適用します。

# kubectl create -f profile.yaml

プロファイルが作成されたかどうか確認します。

# kubectl get profile
NAME                        AGE
kubeflow-user-example-com   9m26s
profile1                    4s
profile2                    4s

試しに、プロファイルで定義した以上のリソースを割り当てようとした場合、Notebook ServerをLaunchをクリックした後、ServerがQuota制限により起動できないことを確認できました。
over-quota-limit.png

Contributorの追加

作成済みプロファイルに別のユーザをContributorとして追加したい場合、左メニューのManage Contributorsを選択し、Contributors to your namespaceに、追加したいユーザ名を入力します。
contributor.png

まとめ

今回はKubeflowのプロファイル機能を使って、ユーザやグループごとの使用可能なリソース制限を行いました。Quotaで設定した以上のリソースが割り当てられないことが確認できました。

参考文献

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?