Google Container Registryを使う
Kubernetesを利用するにあたって、Containerイメージはどこからか必要になる。現時点で利用したことがあるRegistryは以下。
GoogleもContainer Registryサービスが存在するらしい(そりゃそうだよね)ので、こちらを利用してみる。
Setup
GCPで提供されているDocekr Container Registryサービス。初めの手順で入れた gcloud
でそのままセットアップ等が可能らしい。まずはRegistryへの認証を通しておく。
$ gcloud auth configure-docker The following settings will be added to your Docker config file located at [/your/path/.docker/config.json]: { "credHelpers": { "gcr.io": "gcloud", "us.gcr.io": "gcloud", "eu.gcr.io": "gcloud", "asia.gcr.io": "gcloud", "staging-k8s.gcr.io": "gcloud", "marketplace.gcr.io": "gcloud" } } Do you want to continue (Y/n)? Y Docker configuration file updated.
Build Docker Image
kubernetes勉強会のサンプルDocker Imageを使う。
$ docker build ./ -t understanding-k8s-chap02 Sending build context to Docker daemon 484.9kB Step 1/11 : FROM python:3.6 ---> 2e84eb3792eb Step 2/11 : LABEL maintainer "Shiho ASA" ---> Using cache ---> 6724c79a2c2a Step 3/11 : RUN pip install --upgrade pip ---> Using cache ---> 361f492de236 Step 4/11 : ENV APP_PATH /opt/photoview ---> Using cache ---> f05eda089c30 Step 5/11 : COPY requirements.txt $APP_PATH/ ---> Using cache ---> aba66cf56867 Step 6/11 : RUN pip install --no-cache-dir -r $APP_PATH/requirements.txt ---> Using cache ---> 7a63043d1103 Step 7/11 : COPY app.py $APP_PATH/ ---> Using cache ---> cff0fc1c74f3 Step 8/11 : COPY templates/ $APP_PATH/templates/ ---> Using cache ---> a0858b2dd8f6 Step 9/11 : COPY static/ $APP_PATH/static/ ---> Using cache ---> e58b900bf41d Step 10/11 : EXPOSE 80 ---> Using cache ---> b3ee9bba10a3 Step 11/11 : CMD ["python", "/opt/photoview/app.py"] ---> Using cache ---> 1b596535edd7 Successfully built 1b596535edd7 Successfully tagged understanding-k8s-chap02:latest
作成完了。
Regsitryの情報を追加してタグうち。
Docker Imageサイズがでかいのでシュリンクさせたい。
$ docker tag understanding-k8s-chap02 gcr.io/YOUR_PROJECT_ID/understanding-k8s-chap02:2.0
RegistryへPushする。
$ docker push gcr.io/YOUR_PROJECT_ID/understanding-k8s-chap02:2.0 The push refers to repository [gcr.io/YOUR_PROJECT_ID/understanding-k8s-chap02] 2cc580f15e7a: Pushed e4e32be5bfc8: Pushed 057a44c60978: Pushed 6776f921f2da: Pushed 656446dc3d1e: Pushed 5b3eef0724da: Pushed 46425e9e6acd: Pushed 1af02041f4bd: Pushed 03f5680f0fd5: Pushed 66bc2c9720b4: Pushed 8c487c756d71: Pushed 05c027e771c8: Pushed e9313b51f46d: Pushed 46601dcd4114: Pushed 31b0e148310d: Pushed 2.0: digest: sha256:e23d91ac49ee944ff1206729552ef00632c0aea8c6406acdaa598592cb4dbdd3 size: 3471
Push完了。
参考図書
しくみがわかるKubernetes Azureで動かしながら学ぶコンセプトと実践知識
- 作者: 阿佐志保,真壁徹
- 出版社/メーカー: 翔泳社
- 発売日: 2019/01/23
- メディア: 単行本(ソフトカバー)
- この商品を含むブログを見る