sakamomo554101 / study

勉強用のリポジトリ(記事とかのリンクを貼ったりしていく)
0 stars 0 forks source link

kubeflowについて調べる #1

Open sakamomo554101 opened 3 years ago

sakamomo554101 commented 3 years ago
sakamomo554101 commented 3 years ago

https://cyberagent.ai/blog/research/12898/

kubeflow、Kedro、MLFlowのパイプラインOSSのポジションが分かりやすい。 kubeflow高機能だなぁ。

Apache BeamはRunnerにローカル(Direct)やSparkの選択肢などがあるが、kubeflowの場合はk8s(マネージドやローカル)がRunnerなイメージなのかな。

sakamomo554101 commented 3 years ago

https://qiita.com/f6wbl6/items/f4771efee37658c083cc

kubeflow pipelineでBigQueryをさわる例

sakamomo554101 commented 3 years ago

https://www.kubeflow.org/docs/components/pipelines/overview/pipelines-overview/

sakamomo554101 commented 3 years ago

https://github.com/kubeflow/pipelines/blob/master/samples/core/xgboost_training_cm/xgboost_training_cm.py

上記見ると、各ノード(operator)単位で、処理の詳細がyamlで定義されており、利用するDocker Imageやcontainerへのパラメーターが定まっている。

これはオペレーター単位でコンテナが出来そう。

sakamomo554101 commented 3 years ago

もうちょい調べたい

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/components/pipelines/installation/localcluster-deployment/ 上記でローカル環境でkubeflowの処理を動かすことができそう。

試しに環境作ってみる。

sakamomo554101 commented 2 years ago

https://www.creationline.com/lab/40278 k3s(ローカルkubernetesサービス)でモニタリングする際に役立つかも?

sakamomo554101 commented 2 years ago

https://qiita.com/MahoTakara/items/e546d10bc7b6a306a499 kindについて

sakamomo554101 commented 2 years ago

k3sって、mac対応してないのか・・。 docker使う必要がありそう・・

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/distributions/microk8s/kubeflow-on-microk8s/ microK8S使ってみるかー

sakamomo554101 commented 2 years ago

Docker for Desktop使えば良い疑惑 https://www.docker.com/blog/depend-on-docker-for-kubeflow/

https://github.com/kubeflow/kfctl kfctlはkubeflowのCLIツールかなー

sakamomo554101 commented 2 years ago

https://github.com/liorshk/kfctl 参考になりそう?(ローカルでkubeflowを動かす場合)

sakamomo554101 commented 2 years ago

https://kubernetes.io/ja/docs/setup/learning-environment/minikube/ minikubeを使う手もありか?

sakamomo554101 commented 2 years ago

https://github.com/kubeflow/examples 上記にサンプルあるんか

sakamomo554101 commented 2 years ago

https://knowledge.sakura.ad.jp/20489/ istioについて

sakamomo554101 commented 2 years ago

istioはenvoyを各podに配置して、トラフィックを監視する(pod間の) そのため、サイドカーパターン(https://kubernetes.io/docs/concepts/cluster-administration/logging/#sidecar-container-with-logging-agent が例)を利用して、podのメインコンテナと付随して、proxyコンテナを追加している。

※よって、メインアプリと同一コンテナでenvoyを別プロセスで稼働させるわけじゃなくて、別コンテナから監視されている(はず)

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/components/central-dash/customizing-menu/ kubeflowのダッシュボードはカスタマイズができるっぽい。

sakamomo554101 commented 2 years ago

cm -> configmap

sakamomo554101 commented 2 years ago

https://github.com/kubernetes-sigs/kustomize kustomizeについて

sakamomo554101 commented 2 years ago
$ kubectl kustomize --help

上記で、kubectlに含まれるkustomizeのコマンドが見れる。 ※別途kustomizeのリポジトリから手動でインストールする方法もありそう。

kustomizeは環境(商用、devなど)を変更したい際にマニフェストを管理しやすいツールなイメージ。

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/distributions/ibm/deploy/deployment-process/#install-kfctl kfctlをまずは入れてみる

sakamomo554101 commented 2 years ago

https://github.com/kubeflow/manifests k8sのコンポーネントをkubeflowで拡張しているものは上記マニフェストを見ればわかりそう。 ※マニフェストでkustomize使っての定義となっている

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/distributions/operator/introduction/ kubeflowのoperetaor周りの説明は上記ドキュメントから。

sakamomo554101 commented 2 years ago

https://github.com/kubeflow/kfctl/blob/master/operator.md ローカルでのデプロイ時に参考になりそう?

sakamomo554101 commented 2 years ago

今の想定

sakamomo554101 commented 2 years ago

試しに、kfctl init --helpしてみたら、以下のレスポンスがきた(applyでやれや、ということらしい)

'kfctl init' has been removed.
Please switch to new semantics.
To install run -> kfctl apply -f ${CONFIG}
For more information, run 'kfctl apply -h' or read the docs at www.kubeflow.org.

Usage:
  kfctl init [flags]

Flags:
  -h, --help   help for init
sakamomo554101 commented 2 years ago

kfctl のバージョン kfctl v1.2.0-0-gbc038f9

sakamomo554101 commented 2 years ago

https://github.com/kubeflow/kfctl/blob/master/cmd/kfctl/README.md#usage やはり、kfctlコマンドでオンプレにkubeflowが構築できそうね。 試す

sakamomo554101 commented 2 years ago

試すこと

試したこと

試した結果

TBD

特に参考になるサイト

TBD

sakamomo554101 commented 2 years ago

https://github.com/kubeflow/examples/blob/master/mnist/mnist_vanilla_k8s.ipynb 参考になりそう

sakamomo554101 commented 2 years ago

https://github.com/pachyderm/kfdata/blob/master/kfctl_k8s_istio.v1.1.0.yaml 上記をkfctl applyすれば、kubeflow環境ができそう?

sakamomo554101 commented 2 years ago

kfctl apply --helpで、めっちゃ丁寧にマニフェストの捕捉されてるやんけ!

'kfctl apply' builds and deploys a kubeflow application from a KFDef config.
To install run -> kfctl apply -f ${CONFIG}
For more information, run 'kfctl apply -h' or read the docs at www.kubeflow.org.

Usage:
  kfctl apply -f ${CONFIG} [flags]

Flags:
      --context string   Optional kubernetes context to use when applying resources. Currently not used by KFDef resources.
  -f, --file string      Static config file to use. Can be either a local path:
                                export CONFIG=./kfctl_gcp_iap.yaml
                            or a URL:
                                export CONFIG=https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_gcp_iap.v1.0.0.yaml
                                export CONFIG=https://raw.githubusercontent.com/kubeflow/manifests/v1.2-branch/kfdef/kfctl_istio_dex.v1.2.0.yaml
                                export CONFIG=https://raw.githubusercontent.com/kubeflow/manifests/v1.2-branch/kfdef/kfctl_aws.v1.2.0.yaml
                                export CONFIG=https://raw.githubusercontent.com/kubeflow/manifests/v1.2-branch/kfdef/kfctl_k8s_istio.v1.2.0.yaml
                            kfctl apply -V --file=${CONFIG}
  -h, --help             help for apply
  -V, --verbose          verbose output default is false
sakamomo554101 commented 2 years ago

下記エラーが出て、kfappが削除できん。 ※ローカルでkubeflowは動いたっぽい。

Error: couldn't delete KfApp:  (kubeflow.error): Code 500 with message: kfApp Delete failed for kustomize:  (kubeflow.error): Code 400 with message: cluster name doesn't match: KfDef() v.s. current-context(docker-desktop)
sakamomo554101 commented 2 years ago

https://github.com/kubeflow/kubeflow/issues/4815#issuecomment-663914633 上記コメントの対応で治りそう

sakamomo554101 commented 2 years ago

kfctlはリポジトリから取得して、kubeflowの環境構築する方が良さそう ※クラスタ名を明示的に指定した方が削除が楽なため。

sakamomo554101 commented 2 years ago

再度ローカルのyamlを指定して、kfctl applyしたら、kubeflow環境が作られたっぽい? 初回はリポジトリのkustomize情報が必要なのかも(定義ファイルだけあっても、オペレーターの詳細情報がないと、作れないしなぁ)

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/components/pipelines/sdk/install-sdk/ kubeflowのSDKのセットアップが必要かな

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/components/pipelines/sdk/component-development/ 上記が参考になりそう。

ローカルでkubeflowの環境を作ったら、kubeflow SDKを使って、パイプラインをビルドし、デプロイすればいけそうかも。

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/components/pipelines/sdk/connect-api/ port-forwardして、ローカルkubeflowと通信できるようすれば良さそう? ※ただ、すでに設定されている可能性もありそう?

sakamomo554101 commented 2 years ago

おぉー。 下記コマンドで、kubeflowのダッシュボードにlocalhost経由でアクセスできるね!

$ kubectl port-forward svc/ml-pipeline-ui 3000:80 --namespace kubeflow

http://localhost:3000 にアクセス

sakamomo554101 commented 2 years ago
sakamomo554101 commented 2 years ago

https://kubeflow-pipelines.readthedocs.io/en/latest/source/kfp.client.html#kfp-client-class 上記見ると、client取得時にhost名を指定できるが、ローカルクラスターが取得されそう?

sakamomo554101 commented 2 years ago

https://www.kubeflow.org/docs/components/pipelines/sdk/connect-api/ じょうきでまさにサンプルコート書いてあった!(kfp.Clientでローカルホスト指定している。その前に、ダッシュボードのポートをforwardしている)

sakamomo554101 commented 2 years ago

ローカルのマシンで、全然kubeflowが立ち上がってこないな・・。

下記warningが関係してそう?

WARN[0143] Encountered error applying application cert-manager:  (kubeflow.error): Code 500 with message: Apply.Run : error when creating "/tmp/kout738669044": Internal error occurred: failed calling webhook "webhook.cert-manager.io": the server is currently unable to handle the request  filename="kustomize/kustomize.go:284"
WARN[0143] Will retry in 24 seconds.                     filename="kustomize/kustomize.go:285"
sakamomo554101 commented 2 years ago

mpi-operator-d5bfb8489-dvgcsがCrashLoopBackOffになっていてるのが問題?

sakamomo554101 commented 2 years ago

別のPCだと、とりあえずmpi-operatorはクラッシュしているが、他コンポーネントは動いていそう。

kfp.client.list_experimentsで下記エラー

ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'X-Powered-By': 'Express', 'content-type': 'application/json', 'trailer': 'Grpc-Trailer-Content-Type', 'date': 'Fri, 24 Sep 2021 15:39:37 GMT', 'x-envoy-upstream-service-time': '14', 'server': 'envoy', 'connection': 'close', 'transfer-encoding': 'chunked'})
HTTP response body: {"error":"Invalid input error: Invalid resource references for experiment. Namespace is empty.","message":"Invalid input error: Invalid resource references for experiment. Namespace is empty.","code":3,"details":[{"@type":"type.googleapis.com/api.Error","error_message":"Invalid resource references for experiment. Namespace is empty.","error_details":"Invalid input error: Invalid resource references for experiment. Namespace is empty."}]}
sakamomo554101 commented 2 years ago

https://github.com/kubeflow-kale/kale/issues/210#issuecomment-727018461 上記で治るかも?

もしくはclient取得時にnamespaceを明示的に指定すれば良いかも。

sakamomo554101 commented 2 years ago

うーむ、違うエラーが出てきた・・

ApiException: (409)
Reason: Conflict
HTTP response headers: HTTPHeaderDict({'X-Powered-By': 'Express', 'content-type': 'application/json', 'trailer': 'Grpc-Trailer-Content-Type', 'date': 'Fri, 24 Sep 2021 15:51:29 GMT', 'x-envoy-upstream-service-time': '3', 'server': 'envoy', 'connection': 'close', 'transfer-encoding': 'chunked'})
HTTP response body: {"error":"Failed to authorize with API resource references: Bad request.: BadRequestError: Request header error: there is no user identity header.: Request header error: there is no user identity header.","message":"Failed to authorize with API resource references: Bad request.: BadRequestError: Request header error: there is no user identity header.: Request header error: there is no user identity header.","code":10,"details":[{"@type":"type.googleapis.com/api.Error","error_message":"Request header error: there is no user identity header.","error_details":"Failed to authorize with API resource references: Bad request.: BadRequestError: Request header error: there is no user identity header.: Request header error: there is no user identity header."}]}
sakamomo554101 commented 2 years ago

kubeflowのダッシュボード経由でも以下のエラー。 ※experimentsを作ろうとした。

{"error":"Validate experiment request failed.: Invalid input error: Invalid resource references for experiment. Expect one namespace type with owner relationship. Got: []","message":"Validate experiment request failed.: Invalid input error: Invalid resource references for experiment. Expect one namespace type with owner relationship. Got: []","code":3,"details":[{"@type":"type.googleapis.com/api.Error","error_message":"Invalid resource references for experiment. Expect one namespace type with owner relationship. Got: []","error_details":"Validate experiment request failed.: Invalid input error: Invalid resource references for experiment. Expect one namespace type with owner relationship. Got: []"}]}