LoginSignup
1
0

More than 1 year has passed since last update.

Harbor の docker registry 機能と helm chart repo 機能を使ってみる

Last updated at Posted at 2022-03-10

Docker Registry

Harbor の主要なユースケースである private docker registry を試してみます。

まずは Harbor にログイン

image.png

admin ユーザでログインし、まずは Project を作ります。
Harbor の Registry は基本 Project 単位で管理していきます。
1 Project = 1 application の感覚で、Project にユーザを参加させ、権限を付与して利用していく流れです。

image.png

Public Project : 誰でも参照、Pull 可能
Private Project : Project Member のみが参照、Pull 可能

Project 作成後、ユーザを追加します。ユーザ追加する際に、role も指定できます。
image.png
image.png

準備が終わったら、docker client から操作してみます。

Harbor に login

$ docker login https://harbor.nfvlab.test

Local registry にある nginx image に tag をつけます。

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
nginx        latest    c919045c4c2b   8 days ago   142MB

$ docker tag nginx harbor.nfvlab.test/test/nginx:v1

$ docker images
REPOSITORY                      TAG       IMAGE ID       CREATED      SIZE
nginx                           latest    c919045c4c2b   8 days ago   142MB
harbor.nfvlab.test/test/nginx   v1        c919045c4c2b   8 days ago   142MB

tag 済みの image を push します。

$ docker push harbor.nfvlab.test/test/nginx:v1

push 済みの image を確認します。
image.png
image.png

1つのイメージが1つの repository となり、tag が変わると、同じ repository のなかに異なるバージョンのイメージが保存されます。

タグが多すぎると、管理しにくくなるので、Harbor は tag retention の機能を提供しています。
例えば最新の5バージョンのみを保存するとか、30日以内に push された image のみ保存するとかのルールを定義することも可能です。

image.png
最新の5バージョンのみを保存するルール
image.png
30日以内に push された image のみ保存するルール
image.png

ルールは1 Project 15つまで設定可能、実行も手動もしくは schedule による自動実施が可能。

Helm Charts Repo

Harbor は docker registry だけではなく、1.6.0 バージョン以降、Helm と連携し、Helm Chart の repo としても使えます。

Harbor に Helm Chart Repo の機能を有効にするためには Harbor install 時に、--with-chartmuseum のオプションをつけて install.sh を実行する必要があります。
既にインストールされた場合、Harbor の再起動プロセスが install.sh に組み込まれているので、もう一度 install.sh を実行すれば OK です。
便宜のために、Notary(イメージ署名) と Clair(イメージ脆弱性の解析) も併せて有効化しておきます。

$ sudo ./install.sh --with-notary --with-clair --with-chartmuseum

したら、Project の画面に Helm Chart が選べるようになりました。
image.png

ここから helm char の upload/download が可能になります。

そして、client 側の helm も連携しておきます。
下記のコマンドを実行すると、Harbor は helm repo として登録されます。
そして、登録された repo から chart を pull したり、install したりすることが可能になります。

$ helm repo add --ca-file /etc/docker/certs.d/harbor.nfvlab.test/ca.crt --username=admin --password=VMware1! myrepo https://harbor.nfvlab.test/chartrepo/

$ helm repo list
NAME    URL
myrepo  https://harbor.nfvlab.test/chartrepo/
stable  https://charts.helm.sh/stable
1
0
1

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
0