0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

OpenShift - oc-mirror - mirror release images

Last updated at Posted at 2024-08-08

oc-mirror

OpenShift をインターネット非接続環境に導入 (disconnected installation) する際に、oc-mirror plugin が利用できます。

oc-mirror OpenShift CLI(oc) プラグインを使用すると、単一のツールを使用して、必要なすべての OpenShift Container Platform コンテンツおよびその他のイメージをミラーレジストリーにミラーリングできます。次の機能を提供します。

  • OpenShift Container Platform のリリース、Operator、ヘルムチャート、およびその他のイメージをミラーリングするための一元化された方法を提供します。
  • OpenShift Container Platform および Operator の更新パスを維持します。
  • 宣言型イメージセット設定ファイルを使用して、クラスターに必要な OpenShift Container Platform リリース、Operator、およびイメージのみを含めます。
  • 将来のイメージセットのサイズを縮小するインクリメンタルミラーリングを実行します。
  • 前回の実行以降にイメージセット設定から除外されたターゲットミラーレジストリーからのイメージをプルーニングします。
  • オプションで、OpenShift Update Service (OSUS) を使用する際のサポートアーティファクトを生成します。

ここでは、oc-mirror を使用して Release image を Private Registry に登録する方法をご紹介します。

Create ImageSetConfiguration

以下を参考にして ImageSetConfiguration を作成します。

$ oc mirror init --registry myhost.com:5000/ocp4/release > ./OCP_Release_Images.yaml
$ cat ./OCP_Release_Images.yaml
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
  registry:
    imageURL: myhost.com:5000/ocp4/release
    skipTLS: false
mirror:
  platform:
    channels:
    - name: stable-4.16
      type: ocp
  operators:
  - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.17
    packages:
    - name: serverless-operator
      channels:
      - name: stable
  additionalImages:
  - name: registry.redhat.io/ubi8/ubi:latest
  helm: {}

例として、OCP 4.16 の Release image を取得するために、以下を参考にして修正します。

kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
  registry:
    imageURL: myhost.com:5000/ocp4/release
    skipTLS: false
mirror:
  platform:
    channels:
    - name: stable-4.16
      type: ocp
  additionalImages:
  - name: registry.redhat.io/ubi8/ubi:latest
  helm: {}

Mirror Release image

以下の要領で、Release image の取得と Private Registry への Push を同時に行います。

$ oc mirror --config=./OCP_Release_Images.yaml docker://myhost.com:5000/ocp4/release 
Checking push permissions for myhost.com:5000
Creating directory: oc-mirror-workspace/src/publish
Creating directory: oc-mirror-workspace/src/v2
Creating directory: oc-mirror-workspace/src/charts
Creating directory: oc-mirror-workspace/src/release-signatures
No metadata detected, creating new workspace
 :
  stats: shared=4 unique=445 size=18.41GiB ratio=0.99
 :
sha256:fe3cba1698c39549f9c3b67d272d89fc6246bfa0bbf70aa9a8765309194f6cf1 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-ironic-static-ip-manager
sha256:2d50634579d0c9be102647fa2eeca253f99e381002695b08fe22ae309b0f456d myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-must-gather
sha256:73ef8d5fb16834acf6f377780ce149c61cef0146463a5fe8b864845745fff5ec myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-policy-controller
sha256:ffbe0d4c61d5a2e42923b1d063179bbd99fe2bf7a679c5a2f1ae444ba0d5d6c6 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-capi-operator
sha256:4c6719ff6521f0caa2b8324ced5fa0d12c0cf5a50d64279c87ba47bf0c32254d myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-oauth-apiserver
sha256:3a74d91fcace9d61aafcd1d29d9360d42994a5f5b1805b84282d68e08d7794a5 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-container-networking-plugins
sha256:9ffc37fb5bef1c49ab01142d0107dc0fb376c6a318d87c1471ceb50f047feaf2 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-ironic-machine-os-downloader
sha256:dcbad65875d8e49051c911710d47d97ee5e6e39111ab3db3ad73e0045f427679 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-vsphere-cluster-api-controllers
sha256:ccaccb80b00c01f6f4dd90eccb710d3d17b5b6dd620c9836ab18b21c79c64b26 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-version-operator
sha256:adef0938ea2b70c0817b860ec1ffc4cb3fe2cd951c13cda9ce6c660fa9d5d541 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-csi-external-resizer
sha256:3dbd93709e891c2ef31f0e53facfe97b1e8aa3746cddc3b80783ebce150a25ed myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-kube-scheduler-operator
sha256:3e108a538a7dac61f139d4adc16b4879b85d8d1de66e25d007ea78cc1cf50a48 myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-route-controller-manager
mounted: myhost.com:5000/ocp4/release/openshift/release-images sha256:b958cf13e572cbd92209b5c01a8e65203cf88c4b017258ec8ff9bfd5d722b715 46.96MiB
mounted: myhost.com:5000/ocp4/release/openshift/release-images sha256:ca1636478fe5b8e2a56600e24d6759147feb15020824334f4a798c1cb6ed58e2 74.55MiB
mounted: myhost.com:5000/ocp4/release/openshift/release-images sha256:9a0e86afac7b17960e2411a55e234d639aead65defac982719003eaa242da807 9.988MiB
mounted: myhost.com:5000/ocp4/release/openshift/release-images sha256:576f409819a05ac1cfe5e3dd2f6a5d431310d459f482d4d940a51c2578518da3 27.1MiB
uploading: myhost.com:5000/ocp4/release/openshift/release-images sha256:eaa4073efc111a38c37c378c898b85ce692f975aaa202dc7982cccc320ab0425 1.357MiB
sha256:ac78ebf77f95ab8ff52847ecd22592b545415e1ff6c7ff7f66bf81f158ae4f5e myhost.com:5000/ocp4/release/openshift/release-images:4.16.5-x86_64
info: Mirroring completed in 7m3.46s (46.69MB/s)
Writing image mapping to oc-mirror-workspace/results-1723098542/mapping.txt
Writing ICSP manifests to oc-mirror-workspace/results-1723098542

完了時点のディスク使用量は、以下のようになっています。

$ du -csh ./*
4.0K    OCP_Release_Images.yaml
352K    oc-mirror-workspace
356K    total

oc-mirror-workspace/results-1723098542 サブディレクトリーに各種情報が作成されたことが分かります。mapping.txt には、Release image 毎の対応が記録されています。

$ head oc-mirror-workspace/results-1723098542/mapping.txt
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:b9ae6cde773f404daae603ab57e01264bc911f0a3e4f743bf45963d9cd51c0cd=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-kube-metrics-server
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:2e5e00eea76d46fdb88c1a971a3dc3c564e5040f2fb493b9366c200369d943e1=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-azure-disk-csi-driver-operator
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:eccfafc098bcd10d6b0f31f619a55e6032354f83a6b0b425d54a281af6250b02=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-installer-artifacts
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:d9adae98c4e8878016a57df5e7b5932cf7949b12ec5eab53eac8a5e8e8913c36=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-kube-controller-manager-operator
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:c4422638982f2daec9402c963eb24c845c045f1f8c4d533f1eae17fd38d09759=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-csi-snapshot-controller-operator
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:afbb0c3b7acea9ce893971d3d446ca4950e8b8dd4047c214c72f80eab9555a13=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-capi-controllers
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:6c0e9cda082b7be60357ac343effb93b2cdb49ad7456c277c754181a198fe1eb=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-monitoring-operator
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:cab44d120b4d0709fc244193b337655f3e167ce075fd6d3b86ca745f7f91a4d8=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-cluster-control-plane-machine-set-operator
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:e420c5331ee0379cfb04b9488b33f4d0c811420c49017c356bc724c0e51e3af4=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-nutanix-machine-controllers
quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:897f93d7062d3adcebaffdb4e11f7873d87fbb3a9ade8cc613e3a3c3926f5ccb=myhost.com:5000/ocp4/release/openshift/release:4.16.5-x86_64-multus-cni-microshift

Private Registry を確認すると、Release image が登録されたことが分かります。

$ curl -s https://myhost.com:5000/v2/_catalog | jq -r .
{
  "repositories": [
    "ocp4/release",
    "ocp4/release/oc-mirror",
    "ocp4/release/openshift/release",
    "ocp4/release/openshift/release-images",
    "ocp4/release/ubi8/ubi"
  ]
}

完了時点の Private Registry ディスク使用量は、以下のようになっています。

$ du -csh /opt/registry/data/
19G     /opt/registry/data/
19G     total

これで、Private Registry への Release image の登録は完了です。この後、以下の要領に従って OCP Cluster に設定を反映して完了です。

2.4.8. oc-mirror が生成したリソースを使用するためのクラスター設定

$ oc apply -f ./oc-mirror-workspace/results-1723098542
$ oc apply -f ./oc-mirror-workspace/results-1723098542/release-signatures/
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?