Kubeflow環境をMacで作ってみる

タイトルの通りKubeflowをMacBook Pro(15-inch, 2019) Catalina 10.15.3に構築
基本的に公式ドキュメントに従ってMiniKFを入れて指示に従ってるだけ
MiniKFを入れると、ブラウザでEnter押してるだけでKubeflow環境できちゃう

事前準備

Vagrantのインストール
以下URLにて「macOS 64-bit」のリンクをクリック
https://www.vagrantup.com/downloads.html
ダウンロードされた「vagrant_2.2.7_x86_64.dmg」をダブルクリックして次へを押しまくるとインストール完了した!
ターミナルで以下の通り打ち込んでバージョンが出れば成功してるはず

$ vagrant -v                                                                                                                                                                   [zube275_bq_to_sql]
Vagrant 2.2.7

Vagrantインストール系の記事を見てると
Host Machine(Mac)とVirtualBox上のGuest Machineをよろしく連携してくれるGuest Additionsの自動アップデートをしてくれるvagrant-vbguestなるpluginをインストールしておくこと勧めてる感じだったので入れておく
※よろしく連携:クリップボード、フォルダの共有等

$ vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Fetching: micromachine-3.0.0.gem (100%)
Fetching: vagrant-vbguest-0.23.0.gem (100%)
Installed the plugin 'vagrant-vbguest (0.23.0)'!

VirtualBoxのインストール
以下URLから「OS X hosts」リンクをクリック
https://www.virtualbox.org/wiki/Downloads
ダウンロードした「VirtualBox-6.1.4-136177-OSX.dmg」をダブルクリックして次へを押しまくると「インストールできませんでした」的な結果になる...

「システム環境設定->セキュリティとプライバシー->一般タブ」を開くと
一番下に「開発元"Oracle America, Inc."のシステムソフトウェアの読み込みがブロックされました」なるメッセージが出てるので
左下の鍵ボタンクリックしてMacログイン時のパスワード入力&メッセージ右の許可ボタンクリック!

再度「VirtualBox-6.1.4-136177-OSX.dmg」をダブルクリックからの次へ連打でインストールできた!!

MiniKFのインストール

適当なディレクトリを作成してで以下コマンドを実行

$ vagrant init arrikto/minikf
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$ 
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'arrikto/minikf' could not be found. Attempting to find and install...
   default: Box Provider: virtualbox
   default: Box Version: >= 0
==> default: Loading metadata for box 'arrikto/minikf'
   default: URL: https://vagrantcloud.com/arrikto/minikf
==> default: Adding box 'arrikto/minikf' (v20200217.0.0) for provider: virtualbox
   default: Downloading: https://vagrantcloud.com/arrikto/boxes/minikf/versions/20200217.0.0/providers/virtualbox.box
   default: Download redirected to host: storage.googleapis.com
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

OpenSSL SSL_read: Connection reset by peer, errno 54

こけた

Download 20%くらいまでは見ていたが、トイレに行って戻ってきてスリープ解除したらこけてた。
気を取り直して、vagrant upもう一回やってみるも、またこけた

結局原因は不明だが、いろんなものを一旦消して
以下コマンド実行したら3度目の正直。20分くらいで完了した。
(wifiが弱かったのかな・・。スリープさせずにずっと見張ってたからかな・・。わからん。)

$ # /*って書くとnoteのcode内ではコメントってみなされちゃう
$ # 以下コマンドは#外して実行してください
$ # rm ~/.vagrant.d/tmp/*
$ rm -rf .vagrant
$ rm Vagrantfile
$
$ vagrant init arrikto/minikf
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
$
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'arrikto/minikf' could not be found. Attempting to find and install...
   default: Box Provider: virtualbox
   default: Box Version: >= 0
==> default: Loading metadata for box 'arrikto/minikf'
   default: URL: https://vagrantcloud.com/arrikto/minikf
==> default: Adding box 'arrikto/minikf' (v20200217.0.0) for provider: virtualbox
   default: Downloading: https://vagrantcloud.com/arrikto/boxes/minikf/versions/20200217.0.0/providers/virtualbox.box
   default: Download redirected to host: storage.googleapis.com
==> default: Successfully added box 'arrikto/minikf' (v20200217.0.0) for 'virtualbox'!
Plugin 'vagrant-persistent-storage' is missing, running `vagrant plugin install vagrant-persistent-storage`...
Installing the 'vagrant-persistent-storage --version '>= 0.0.47'' plugin. This can take a few minutes...
Fetching: vagrant-persistent-storage-0.0.48.gem (100%)
Installed the plugin 'vagrant-persistent-storage (0.0.48)'!
Plugin installed successfully, please re-run `vagrant up`.
$
$ # もう一回vagrant upって書いてあるからやってみる
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Using /Users/s.uchiyama/src/github.com/shintaro-uchiyama/kubeflow/minikf-user-data.vdi for persistent storage.
==> default: Importing base box 'arrikto/minikf'...
==> default: Generating MAC address for NAT networking...
==> default: Using /Users/s.uchiyama/src/github.com/shintaro-uchiyama/kubeflow/minikf-user-data.vdi for persistent storage.
==> default: Checking if box 'arrikto/minikf' version '20200217.0.0' is up to date...
==> default: Setting the name of the VM: kubeflow_default_1583574283773_91618
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

(省略)

==> default: Machine 'default' has a post `vagrant up` message. This is a message
==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
==> default:
==> default:     Welcome to MiniKF!
==> default:     Visit http://10.10.10.10/ to get started.
==> default:

MiniKFでKubeflow, Rokを起動

ターミナルで表示された通りChromeでhttp://10.10.10.10/にアクセスしてみる

画像1

いろいろクリックしても反応しないから
「え、何したらいいの」と思ったけどキーボードのEnter押したら
画面上のOKがEnterされて次に進んだ

画像2

キーボードの左ボタン押してEnterで「Accept and Continue」選択

画像3

画面が勝手にこちょこちょ動き始めて、放置してたらUpになった!
「Connect to Kubeflow」をクリックしてみる

画像4

一個前の画面で出てきたUsernameとPassword入力してLogin

画像5

画面でた!

いまいちRokがどう生きるのかまだわかってないけど
とりあえずMiniKFで「Connect to Rok」ボタンをクリック

画像6

同じようにUsernameとPassword入力してLogin

画像7

出た!

まとめ

VirtualBoxって重いイメージがあったから「うげぇ」と思ったけど
ものすごく簡単にKubeflow環境できたんで、ローカル環境作るにはおすすめ
vagrant upがこける現象だけ突破できればスッと構築できた

あと、2020年3月7日時点ではMiniKFでインストールできるKubeflowのバージョンは0.7.0だったので、1.0対応されたらMiniKFアップデートしたい

この記事が気に入ったらサポートをしてみませんか?