2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IBM Cloud Container Registry _ CBR 設定で Public Endpoint を制限する際に Private Endpoint の Context を見落とさないために

2
Last updated at Posted at 2026-07-09

はじめに

IBM Cloud の Context-based restrictions(CBR)を利用すると、IBM Cloud サービスへのアクセスをネットワークコンテキストに基づいて制御できます。

CBR の基本的な考え方や設定手順については、以下の記事が参考になります。

本記事では、CBR の基本機能そのものではなく、IBM Cloud Container Registry(ICR)に対して CBR を設定する際に起こりやすい設定漏れの一例として、Public endpoint / Private endpoint Context の考え方を整理します。

本記事で確認する内容

まず、構成のイメージは以下の通りです。
image.png

実際の利用シーンでは、以下のようなセキュリティ要件が出てくることがあります。

IAM の Access Policy により、ユーザーに対する ICR のアクセス権限はすでに制御しているものの、さらに「ユーザーがオフィス環境からアクセスする場合のみ ICR への image pull / push を許可したい」という要件が考えられます。
言い換えると、開発者が会社の PC を自宅に持ち帰り、自宅ネットワークから ICR にアクセスするようなケースは許可しない、という考え方です。

この場合、オフィス環境から ICR の Public endpoint にインターネット経由でアクセスする構成であれば、CBR rule と Public IP ベースの Network zone を組み合わせて制御する方法が考えられます。

このような要件では、例えば以下のような Context 設定が必要になります。

Context 1:
  Endpoint type:
    Public endpoints

  Network zone:
    許可する Public IP range

Context 2:
  Endpoint type:
    Private endpoints

本記事で特に強調したいのは、Public endpoint 側のアクセス制限に意識が向きすぎるあまり、Context 1 のみを設定してしまいがちな点です。

しかし、Code Engine などの IBM Cloud サービスが ICR から image を pull する場合、Private endpoint 側の Context が必要になるため、Context 2 も忘れずに追加する必要があります。

以下のテストでは、Context の設定内容が Private endpoint 経由のアクセスにどのような影響を与えるかを確認します。

テスト 1: Public endpoint + 特定 Public IP のみを設定した場合

まず、ICR に対して以下のような CBR rule を設定しました。
image.png
以降の CBR 設定画面のスクリーンショットでは、ポイントを分かりやすくするため、主に Context の部分に絞って表示します。
image.png

この設定では、Public endpoint 経由の ICR アクセスは、指定した Public IP のみに制限されます。

まず、許可された Public IP からアクセスしている自分の PC では、以下のように image pull が成功しました。
なお、セキュリティ上の理由により、以下の出力では一部の情報をマスクしています。

helen@xxx:~$ podman pull jp.icr.io/helentestxxxx/helen-test-xxxx:latest
Trying to pull jp.icr.io/helentestxxxx/helen-test-xxxx:latest...
Getting image source signatures
Copying blob 7fbaa614cae8 done   |
Copying blob 6a0ac1617861 done   |
Copying blob dc3bc4856595 done   |
Copying blob a7bcb484613b done   |
Copying blob b5abef4b814c done   |
Copying blob 97c8104718e5 done   |
Copying blob 5d83f7614bcf done   |
Copying blob 24aa55bb89eb done   |
Copying blob 8b97348ac923 done   |
Copying blob 6d164b2009e7 done   |
Copying blob 920782d049c6 done   |
Copying config d7282f0a9d done   |
Writing manifest to image destination
d7282f0a9d95ca516f9721471785cca973e09b132b2fdd7a340dcf7f601fbaa4
helen@xxx:~$ podman images
REPOSITORY                                     TAG         IMAGE ID      CREATED      SIZE
jp.icr.io/helentestxxxx/helen-test-xxxx  latest      d7282f0a9d95  11 days ago  61.5 MB
helen@xxx:~$ 

次に、Context で許可する IP アドレスを現在の PC の Public IP とは異なる値に変更し、同じ PC から再度 image pull を実行しました。

その結果、以下のように You are not authorized to access the specified resource というエラーが返りました。

helen@xxx:~$ podman pull jp.icr.io/helentestxxxx/helen-test-xxxx:latest
Trying to pull jp.icr.io/helentestxxxx/helen-test-xxxx:latest...
Error: unable to copy from source docker://jp.icr.io/helentestxxxx/helen-test-xxxx:latest: initializing source docker://jp.icr.io/helentestxxxx/helen-test-xxxx:latest: reading manifest latest in jp.icr.io/helentestxxxx/helen-test-xxxx: denied: You are not authorized to access the specified resource. See https://cloud.ibm.com/docs/Registry?topic=Registry-troubleshoot-resource
helen@xxx:~$

また、IBM Cloud Portal 上でも、ICR サービスの画面を表示できず、権限がない旨のエラーが表示されました。
image.png

その後、Context の設定を元に戻し、現在の PC の Public IP からのアクセスを許可したところ、Podman による操作および Portal 上での操作が再び問題なく実行できることを確認しました。

以上の結果から、Public endpoint 側で設定した Public IP ベースのアクセス制限は有効に機能していることが確認できました。

一方で、この rule には Private endpoint 用の Context が含まれていません。

この状態で Code Engine Application を作成したところ、Application の作成が失敗しました。
image.png

Code Engine は Application 作成時に ICR から container image を pull します。今回の設定では、Private endpoint 経由のアクセスを許可する Context がないため、Code Engine から ICR への image pull が CBR の条件に合致せず、失敗したものと考えられます。

このように、Public endpoint の制限だけを設定すると、Private endpoint 経由で必要となるアクセスまで止めてしまう結果になります。

テスト 2: CBR rule を無効化すると Application 作成が成功

次に、上記の CBR rule を無効化しました。
image.png

その後しばらくすると、Code Engine Application の作成が成功しました。

image.png

この結果から、Application の定義や container image 自体に問題があったのではなく、
ICR 側の CBR rule が原因で image pull が制限されていたことが確認できました。

また、Code Engine 側では Application 作成時の処理が retry されるため、
CBR rule を無効化したタイミングで再試行が行われ、
結果として Application の作成が成功したことが分かります。

テスト 3: Private endpoint 用の Context を追加した場合

次に、CBR rule を有効にしたまま、同じ rule の中に Private endpoint 用の Context を追加しました。

設定内容は以下の通りです。
image.png

この状態で再度 Code Engine Application を作成したところ、CBR rule が有効なまま Application の作成が成功しました。
image.png
この結果から、Public endpoint 側の IP 制限と、Private endpoint 側のアクセス許可は、同じ CBR rule 内で Context を分けて設定できることを確認できました。

まとめ

ICR に CBR rule を設定して Public endpoint 経由のアクセスを特定 Public IP に制限する場合、Public endpoint 用の Context だけを設定すると、Private endpoint 経由のアクセスが許可されません。

Code Engine など IBM Cloud サービスが ICR から image を pull する構成では、この設定漏れにより Application 作成が失敗することがあります。

そのため、Public endpoint 側を IP 制限する場合でも、Private endpoint 経由のアクセスを維持したい場合は、同じ CBR rule 内に Private endpoint 用の Context を追加する必要があります。
なお、Private endpoint 経由のアクセスについても、必要に応じてさらに細かく制限することが可能です。例えば、Private endpoint の Context に対して Network zone を組み合わせることで、特定のネットワークや IBM Cloud サービスからのアクセスに限定する設計も考えられます。

以上、ICR に CBR を設定する際の注意点として、Public / Private endpoint の Context について確認してみました。
同様の設定を行う際の参考になれば幸いです。

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?