NTNX>日記

個人的な趣味による Nutanix Community Edition 日記。Japanese のみですみません。

Nutanix Kubernetes Engine クラスタに Kubeflow をインストールしてみる。

Nutanix Kubernetes Engine(NKE)の Kubernetes クラスタに、Kubeflow をインストールしてみます。

下記のサイトが参考になります。

今回の内容です。

今回の環境

NKE では Development Kubernetes クラスタを作成してあります。

ノード構成は次のようになっています。ちなみに、GPU は搭載されていません。

  • Control Plane x 1
  • Worker x 3(Worker Node Pool x1)

kubectl でノードを確認した様子です。

$ kubectl get nodes
NAME                     STATUS   ROLES                  AGE     VERSION
nke-01-2539f9-master-0   Ready    control-plane,master   3h21m   v1.26.8
nke-01-2539f9-worker-0   Ready    node                   3h20m   v1.26.8
nke-01-2539f9-worker-1   Ready    node                   66m     v1.26.8
nke-01-2539f9-worker-2   Ready    node                   65m     v1.26.8

作業マシンとして、Linux を利用します。

$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.3 (Plow)

1. 前提ソフトウェアのインストール

1-1. RPM のインストール

root ユーザもしくは sudo で、前提となる RPM をインストールしておきます。

# dnf install git make wget -y

1-2. CLI インストール ディレクトリの作成

今回は、各種 CLI を $HOME/bin ディレクトリにインストールします。CLI のインストール前にディレクトリを作成しておきます。ちなみに、RHEL ではデフォルトで $HOME/bin が PATH に含まれています。

$ mkdir bin

1-3. kubectl のインストール

NKE クラスタのバージョンにあわせて kubectl をダウンロードします。

$ curl -s -o $HOME/bin/kubectl -L https://storage.googleapis.com/kubernetes-release/release/v1.26.8/bin/linux/amd64/kubectl

kubectl に実行権限を付与します。

$ chmod +x $HOME/bin/kubectl

kubectl が実行できるようになったことを確認しておきます。

$ kubectl version --short --client
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.26.8
Kustomize Version: v4.5.7

1-4. kustomize のインストール

kustomize をダウンロードします。

$ curl -OL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz

kustomize のアーカイブを展開します。

$ tar zxvf kustomize_v5.0.3_linux_amd64.tar.gz

kustomize のバイナリをインストールします。

$ install kustomize $HOME/bin/

kustomize が実行できるようになったことを確認しておきます。

$ kustomize version
v5.0.3

2. kubectl の準備

kubeconfig を取得して、kubectl で NKE クラスタにに設定しておきます。

kubectl で、情報取得できることを確認しておきます。

$ kubectl get nodes
NAME                     STATUS   ROLES                  AGE     VERSION
nke-01-2539f9-master-0   Ready    control-plane,master   3h21m   v1.26.8
nke-01-2539f9-worker-0   Ready    node                   3h20m   v1.26.8
nke-01-2539f9-worker-1   Ready    node                   66m     v1.26.8
nke-01-2539f9-worker-2   Ready    node                   65m     v1.26.8

 

3. MetalLB のインストール

Kubeflow UI に LoadBalancer Service 経由でアクセスできるようにするため、MetalLB をインストールします。MetalLB のバージョンは、ドキュメントの手順で紹介されていた v0.13.11 を採用しています。

$ kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.11/config/manifests/metallb-native.yaml
namespace/metallb-system created
customresourcedefinition.apiextensions.k8s.io/addresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bfdprofiles.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgpadvertisements.metallb.io created
customresourcedefinition.apiextensions.k8s.io/bgppeers.metallb.io created
customresourcedefinition.apiextensions.k8s.io/communities.metallb.io created
customresourcedefinition.apiextensions.k8s.io/ipaddresspools.metallb.io created
customresourcedefinition.apiextensions.k8s.io/l2advertisements.metallb.io created
serviceaccount/controller created
serviceaccount/speaker created
role.rbac.authorization.k8s.io/controller created
role.rbac.authorization.k8s.io/pod-lister created
clusterrole.rbac.authorization.k8s.io/metallb-system:controller created
clusterrole.rbac.authorization.k8s.io/metallb-system:speaker created
rolebinding.rbac.authorization.k8s.io/controller created
rolebinding.rbac.authorization.k8s.io/pod-lister created
clusterrolebinding.rbac.authorization.k8s.io/metallb-system:controller created
clusterrolebinding.rbac.authorization.k8s.io/metallb-system:speaker created
configmap/metallb-excludel2 created
secret/webhook-server-cert created
service/webhook-service created
deployment.apps/controller created
daemonset.apps/speaker created
validatingwebhookconfiguration.admissionregistration.k8s.io/metallb-webhook-configuration created

MetalLB の IPAddressPool とL2Advertisement を設定するための YAML ファイルを作成します。

kf_metallb.yml

  • L9: LoadBalancer Service で使用する IP アドレス範囲を指定します。
    • NKE 仮想マシンの Kubernetes Node Network から、IPAM の IP プール範囲外のアドレスを指定します。
    • 今回使用するアドレスは 1つだけですが、余裕を持たせてあります。

gist.github.com

 

YAML を適用します。

$ kubectl apply -f kf_metallb.yml
ipaddresspool.metallb.io/kf-ip-address-pool created
l2advertisement.metallb.io/kf-l2advertisement created

Metallb-system Namespace の Pod が Running になったことを確認します。

$ kubectl get pods -n metallb-system
NAME                          READY   STATUS    RESTARTS   AGE
controller-69c8d4b45b-ngcp7   1/1     Running   0          4m33s
speaker-9plpn                 1/1     Running   0          4m32s
speaker-lhw47                 1/1     Running   0          4m32s
speaker-nmqjd                 1/1     Running   0          4m32s

4. kubeflow のインストール

4-1. Kubeflow のインストール

GitHub から、Kubeflow のマニフェストを取得します。

$ git clone -b release-v1.8 https://github.com/nutanix/kubeflow-manifests.git
Cloning into 'kubeflow-manifests'...
remote: Enumerating objects: 592, done.
remote: Counting objects: 100% (148/148), done.
remote: Compressing objects: 100% (105/105), done.
remote: Total 592 (delta 59), reused 93 (delta 28), pack-reused 444
Receiving objects: 100% (592/592), 1.84 MiB | 8.50 MiB/s, done.
Resolving deltas: 100% (244/244), done.

ダウンロードしたディレクトリに移動します。

$ cd kubeflow-manifests/

make コマンドを実行します。これにより Kubeflow のインストールが実行され、関連のオブジェクトが作成されます。エラーが表示されますが、自動的にリトライされるので、プロンプトが戻るまでしばらく待ちます。

$ make install-vanilla-kubeflow

cert-manager の Pod が起動されたことを確認します。

$ kubectl get pods -n cert-manager
NAME                                       READY   STATUS    RESTARTS   AGE
cert-manager-5d77b478-98f2v                1/1     Running   0          85m
cert-manager-cainjector-576655b654-hx4jm   1/1     Running   0          85m
cert-manager-webhook-795dc979b6-gjxfx      1/1     Running   0          85m

istio の Pod が起動されたことを確認します。

$ kubectl get pods -n istio-system
NAME                                     READY   STATUS    RESTARTS   AGE
cluster-local-gateway-68d65cbd8c-sd9fd   1/1     Running   0          85m
istio-ingressgateway-8f46b776-v5xp8      1/1     Running   0          85m
istiod-788f458f4b-wc8zd                  1/1     Running   0          85m
oidc-authservice-0                       1/1     Running   0          85m

Dex の Pod が起動されたことを確認します。

$ kubectl get pods -n auth
NAME                   READY   STATUS    RESTARTS   AGE
dex-6555448c78-7h769   1/1     Running   0          86m

knative-eventing の Pod が起動されたことを確認します。

$ kubectl get pods -n knative-eventing
NAME                                  READY   STATUS    RESTARTS   AGE
eventing-controller-69c5d5659-zqr2j   1/1     Running   0          86m
eventing-webhook-5496bb69df-2t6jc     1/1     Running   0          86m

knative-serving の Pod が起動されたことを確認します。

$ kubectl get pods -n knative-serving
NAME                                     READY   STATUS    RESTARTS   AGE
activator-57888f4455-6lhtc               2/2     Running   0          84m
autoscaler-55449c6c49-pn4h7              2/2     Running   0          85m
controller-76bfc57447-nqq2w              2/2     Running   0          85m
domain-mapping-687fdbbfd-6qx9d           2/2     Running   0          85m
domainmapping-webhook-758fbc96c6-r7wfq   2/2     Running   0          85m
net-istio-controller-5f66f65c68-7mfv4    2/2     Running   0          85m
net-istio-webhook-5694575876-tcvcg       2/2     Running   0          85m
webhook-8d4d56959-cv229                  2/2     Running   0          85m

kubeflow Namespace の Pod です。

$ kubectl get pod -n kubeflow
NAME                                                     READY   STATUS    RESTARTS     AGE
admission-webhook-deployment-6c9678d48b-pg7vz            1/1     Running   0            8h
cache-server-574ddb7d97-trxkj                            2/2     Running   0            8h
centraldashboard-68c4d7c97c-pvls8                        2/2     Running   0            8h
jupyter-web-app-deployment-64f48b8564-hghl4              2/2     Running   0            8h
katib-controller-78d87df4f-b5ttr                         1/1     Running   0            8h
katib-db-manager-678674f64d-s77ct                        1/1     Running   3 (8h ago)   8h
katib-mysql-66c8cdff4f-vrxc4                             1/1     Running   0            8h
katib-ui-74d9fdb748-7gvz6                                2/2     Running   0            8h
kserve-controller-manager-54896c8c6b-vfhl4               2/2     Running   0            8h
kserve-models-web-app-9fbcd79f5-kbs7n                    2/2     Running   0            8h
kubeflow-pipelines-profile-controller-6f6bc888df-28kp8   1/1     Running   0            8h
metacontroller-0                                         1/1     Running   0            8h
metadata-envoy-deployment-85cc676d57-c4zwk               1/1     Running   0            8h
metadata-grpc-deployment-98fd89ff6-2cn5f                 2/2     Running   7 (8h ago)   8h
metadata-writer-58f578f45d-5p66j                         2/2     Running   3 (8h ago)   8h
minio-549846c488-gf5zt                                   2/2     Running   0            8h
ml-pipeline-6f5f9c79cf-tvrtp                             2/2     Running   5 (8h ago)   8h
ml-pipeline-persistenceagent-66964dbc95-xzkt9            2/2     Running   0            8h
ml-pipeline-scheduledworkflow-5b47b9d5f5-6k9b6           2/2     Running   0            8h
ml-pipeline-ui-85d4f4fb54-w7v9z                          2/2     Running   0            8h
ml-pipeline-viewer-crd-765d85855b-7jvc5                  2/2     Running   1 (8h ago)   8h
ml-pipeline-visualizationserver-6c49dff8dc-fvnjf         2/2     Running   0            8h
mysql-5f968d4688-rr74h                                   2/2     Running   0            8h
notebook-controller-deployment-7d4b968b5-mkmkl           2/2     Running   2 (8h ago)   8h
profiles-deployment-7bf5788f98-g9zxj                     3/3     Running   1 (8h ago)   8h
pvcviewer-controller-manager-66f454bfb9-hvvkd            3/3     Running   2 (8h ago)   8h
tensorboard-controller-deployment-844967d94b-wb2jz       3/3     Running   1 (8h ago)   8h
tensorboards-web-app-deployment-7bff589c99-d6sl5         2/2     Running   0            8h
training-operator-754d664965-6l9hn                       1/1     Running   0            8h
volumes-web-app-deployment-68675f95d9-gkh74              2/2     Running   0            8h
workflow-controller-545cbd7ddb-jsxrr                     2/2     Running   2 (8h ago)   8h

デフォルト ユーザが利用する Namespace の Pod が起動されたことを確認します。

$ kubectl get pods -n kubeflow-user-example-com
NAME                                               READY   STATUS    RESTARTS   AGE
ml-pipeline-ui-artifact-5c4b49cff9-scw98           2/2     Running   0          75m
ml-pipeline-visualizationserver-77f48b88c7-rbxh8   2/2     Running   0          75m

4-2. istio-ingressgateway の Service Type 変更

istio-ingressgateway Service の種類を、LoadBalancer に変更します。

$ kubectl -n istio-system  patch service istio-ingressgateway -p '{"spec": {"type": "LoadBalancer"}}'
service/istio-ingressgateway patched

istio-ingressgateway に、MetalLB による外部 IP アドレスが設定されたことを確認します。

$ kubectl -n istio-system get svc istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0]}' | more
{"ip":"192.168.12.211"}

外部 IP アドレス(192.168.12.211)に Web ブラウザから HTTP でアクセスすると、Kubeflow UI の Dex ログイン画面が開けるようになります。

4-3. istio-ingressgateway 証明書の作成

cert-manager で証明書を作成するための YAML を作成します。

kf_certificate.yml

  • L10: istio-ingressgateway の外部 IP アドレスを指定します。

gist.github.com

証明書を作成します。

$ kubectl apply -f kf_certificate.yml
certificate.cert-manager.io/istio-ingressgateway-certs created

証明書が作成されました。

$ kubectl -n istio-system get certificate
NAME                         READY   SECRET                       AGE
istio-ingressgateway-certs   True    istio-ingressgateway-certs   19s

4-4. HTTPS アクセスの設定

kubeflow-gateway Gateway の設定を変更します。

設定変更前の Gateway の設定です。

$ kubectl -n kubeflow get gateways.networking.istio.io kubeflow-gateway -o yaml
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1alpha3","kind":"Gateway","metadata":{"annotations":{},"name":"kubeflow-gateway","namespace":"kubeflow"},"spec":{"selector":{"istio":"ingressgateway"},"servers":[{"hosts":["*"],"port":{"name":"http","number":80,"protocol":"HTTP"}}]}}
  creationTimestamp: "2024-03-08T18:50:03Z"
  generation: 1
  name: kubeflow-gateway
  namespace: kubeflow
  resourceVersion: "38934"
  uid: f9dc2954-ab52-4091-a362-94f2c375aa54
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: http
      number: 80
      protocol: HTTP

設定変更します。

$ kubectl -n kubeflow edit gateways.networking.istio.io kubeflow-gateway
gateway.networking.istio.io/kubeflow-gateway edited

ここでは、下記を追記します。

    tls:
      httpsRedirect: true
  - hosts:
    - '*'
    port:
      name: https
      number: 443
      protocol: HTTPS
    tls:
      mode: SIMPLE
      privateKey: /etc/istio/ingressgateway-certs/tls.key
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt

設定変更後の状態です。

$ kubectl -n kubeflow get gateways.networking.istio.io kubeflow-gateway -o yaml
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"networking.istio.io/v1alpha3","kind":"Gateway","metadata":{"annotations":{},"name":"kubeflow-gateway","namespace":"kubeflow"},"spec":{"selector":{"istio":"ingressgateway"},"servers":[{"hosts":["*"],"port":{"name":"http","number":80,"protocol":"HTTP"}}]}}
  creationTimestamp: "2024-03-08T18:50:03Z"
  generation: 2
  name: kubeflow-gateway
  namespace: kubeflow
  resourceVersion: "256392"
  uid: f9dc2954-ab52-4091-a362-94f2c375aa54
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: http
      number: 80
      protocol: HTTP
    tls:
      httpsRedirect: true
  - hosts:
    - '*'
    port:
      name: https
      number: 443
      protocol: HTTPS
    tls:
      mode: SIMPLE
      privateKey: /etc/istio/ingressgateway-certs/tls.key
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt

istio-ingressgateway Deployment の Pod を再起動します。

$ kubectl rollout restart deployment -n istio-system istio-ingressgateway
deployment.apps/istio-ingressgateway restarted

5. Kubeflow UI へのログイン

HTTPS で、istio-ingressgateway Service の外部 IP アドレスにアクセスすると、Dex のログイン画面が表示されます。

デフォルトのユーザでログインします。

  • Email Address: user@example.com
  • Password: 12341234

Kubeflow UI にログインできました。

証明書を確認すると、cert-manager で istio-ingressgateway に発行したものが利用されています。

「証明書のサブジェクトの代替名」には、YAML で指定した外部 IP アドレスが設定されています。

つづく。

 

©2023 gowatana
クリエイティブ・コモンズ・ライセンスこの 作品 は クリエイティブ・コモンズ 表示 4.0 国際 ライセンスの下に提供されています。