Container 専用のデプロイツール Waypoint を試してみる。

こんにちは k-jun です。今回は、HashiCorp が開発している デプロイツール Waypoint を試してみようと思います。

https://github.com/hashicorp/waypoint

AWSGCP、Azure、Kubernetes 果ては Nomad までの Deploy を管理できるツールのようですが、果たして。

Setup

こちら を参考にインストールしていきます。

$ brew tap hashicorp/tap
$ brew install hashicorp/tap/waypoint
$ which waypoint
/usr/local/bin/waypoint

Run

こちら を参考に、まずは簡単なものから試してみます。

$ waypoint install -platform=docker -accept-tos

お試しで使えるアプリケーションがあるようなので、コチラを clone します。

$ git clone https://github.com/hashicorp/waypoint-examples.git
$ cd waypoint-examples/docker/nodejs

では、waypoint コマンド経由で起動してみます。

$ waypoint init
$ waypoint up
» Building example-nodejs...
Creating new buildpack-based image using builder: heroku/buildpacks:20
Creating new buildpack-based image using builder: heroku/buildpacks:20
✓ Creating pack client
✓ Building image
 │ [exporter] Adding layer 'process-types'[exporter] Adding label 'io.buildpacks.lifecycle.metadata'[exporter] Adding label 'io.buildpacks.build.metadata'[exporter] Adding label 'io.buildpacks.project.metadata'[exporter] Setting default process type 'web'[exporter] Saving example-nodejs...
 │ [exporter] *** Images (22264e01b316):
 │ [exporter]       example-nodejs
 │ [exporter] Adding cache layer 'heroku/nodejs-engine:nodejs'[exporter] Adding cache layer 'heroku/nodejs-engine:toolbox'
✓ Injecting entrypoint binary to image

Generated new Docker image: example-nodejs:latest

» Deploying example-nodejs...
✓ Setting up network...
✓ Starting container
✓ App deployed as container: example-nodejs-01FKKF3P7J70A8PKMWFYQE50W6
✓ Docker image "example-nodejs:latest" up to date!

✓ Finished building report for Docker platform
✓ Finished building report for Docker network resource
✓ Finished building report for Docker container resource
✓ All 2 resources are reporting READY

» Releasing example-nodejs...
No release phase specified, skipping...

The deploy was successful! A Waypoint deployment URL is shown below. This
can be used internally to check your deployment and is not meant for external
traffic. You can manage this hostname using "waypoint hostname."

           URL: https://promptly-divine-peacock.waypoint.run
Deployment URL: https://promptly-divine-peacock--v1.waypoint.run[f:id:K-jun1221:20211104025742p:plain]

f:id:K-jun1221:20211104025742p:plain

docker ps で確認すると container が確認できるので、 ローカルで起動していることは間違いなさそうです。

$ docker ps
CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS         PORTS                              NAMES
0e7944d22fe6   example-nodejs:latest       "/waypoint-entrypoin…"   2 minutes ago   Up 2 minutes   0.0.0.0:55000->3000/tcp            example-nodejs-01FKKF3P7J70A8PKMWFYQE50W6
845eebe4dc0c   hashicorp/waypoint:latest   "/usr/bin/waypoint r…"   8 minutes ago   Up 8 minutes                                      waypoint-runner
816957fab970   hashicorp/waypoint:latest   "/usr/bin/waypoint s…"   8 minutes ago   Up 8 minutes   0.0.0.0:9701-9702->9701-9702/tcp   waypoint-server

では、destroy でもとに戻して他の機能も試してみます。

$ waypoint destroy -auto-approve

ここ を参照すると、Deploy 先の選択肢としては Lambda, ECS, Cloud Run が今の所あるようですね。 KubernetesNomad もできるようですが、ここらへんは群雄割拠ですので今回は Cloud Run に Deploy してみようと思います。

ということで、ここ に従っていく。

$ git clone https://github.com/hashicorp/waypoint-examples.git
$ cd waypoint-examples/gcp/google-cloud-run/nodejs

デプロイする GCP の プロジェクトID を設定する。gcloud も必要になるようなので、存在しない場合は適宜インストールと設定を。 今回自分も諸々の設定が足りていなかったので以下のようにコマンドを実行。

$ sed -i -e 's/<my-project-id>/<YOUR_GCP_ID>/g' waypoint.hcl

$ gcloud services enable containerregistry.googleapis.com
$ gcloud auth configure-docker
$ waypoint init
$ waypoint up
...
» Releasing example-nodejs...


The deploy was successful! A Waypoint deployment URL is shown below. This
can be used internally to check your deployment and is not meant for external
traffic. You can manage this hostname using "waypoint hostname."

   Release URL: https://example-nodejs-6nrl32uqta-ue.a.run.app

良い感じにデプロイが完了したようです。コンソールから確認した限りでも大丈夫そうです。設定ファイルの中身を見ても簡単そうですし、イメージの Build と Push も自動でやってくれて便利そうです。 Waypoint 結構便利ですね。それでは今回はこのへんで。