LoginSignup
19
17

More than 5 years have passed since last update.

Kubernetes でプライベートリポジトリのコンテナイメージを使うには

Posted at

Kubernetes でプライベートリポジトリのコンテナイメージを使うには

docker-registry タイプの secret を作成し、pods.spec.imagePullSecrets にその secret を指定すればOK。

例えば、 GitLab.com の場合であれば次のコマンドで secret を作成する。( reggitlab はリソース名を示す任意の文字列を指定して良い)

# 変数は適宜設定する
$ kubectl create secret docker-registry reggitlab \
          --docker-server=https://registry.gitlab.com/ \
          --docker-username=$GLUSER \
          --docker-password=$GLPASSWD \
          --docker-email=$GLEMAIL

これを利用する Pod の manifest からは pods.spec.imagePullSecrets に secret 名を指定して参照する。例えば、次のようにする。

spec:
  containers:
    - image: registry.gitlab.com/example/nginx:latest
      name: nginx
      ports:
        - containerPort: 8080
  imagePullSecrets:
    - name: reggitlab

参考

Pulling an Image from a Private Registry

19
17
0

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
19
17