此内容没有您所选择的语言版本。
Chapter 2. Creating container images in a network restricted environment
As an application developer, configure OpenShift Container Platform with an HTTP or HTTPS proxy to enforce security and prevent direct internet access for your build processes. This setup enforces security by routing build pulls of dependencies, images, and code through a monitored outgoing proxy gateway.
Create a buildah build in a network-restricted environment by mirroring the images that buildah build strategy requires. Mirroring the images eliminates the need for public registry access. This ensures clusters use only images that comply with external content controls.
Prerequisites
-
You have installed the
ocCLI. - Your cluster can connect and interact with the Git source that you can use to create the buildah build.
-
You have the builder-image required to create the
buildahbuild in your local registry. If the builder-image is not present in the local registry, mirror the source image.
Procedure
Run the following command to mirror the images that
buildahbuild strategy requires:oc image mirror --insecure -a <registry_authentication> registry.redhat.io/ubi8/buildah@sha256:1c89cc3cab0ac0fc7387c1fe5e63443468219aab6fd531c8dad6d22fd999819e <mirror_registry>/<repo>/ubi8_buildah
$ oc image mirror --insecure -a <registry_authentication> registry.redhat.io/ubi8/buildah@sha256:1c89cc3cab0ac0fc7387c1fe5e63443468219aab6fd531c8dad6d22fd999819e <mirror_registry>/<repo>/ubi8_buildahCopy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<registry_authentication>- Specifies the authentication credentials used to access a container registry. This is required when pushing to or pulling from a private registry.
<mirror_registry>- Specifies the registry where the image you want to mirror is stored.
<image_name>- Specifies the name of the image.
<tag>- Specifies the tag of the image.
- Perform the steps mentioned in the "Creating a buildah build" section.
Create a source-to-image build in a network-restricted environment by mirroring the images that source-to-image build strategy requires. Mirroring the images eliminates the need for public registry access. This ensures clusters use only images that comply with external content controls.
Prerequisites
-
You have installed the
ocCLI. -
Your cluster can connect and interact with the Git source used to create the
source-to-imagebuild. -
You have the builder-image required to create the
source-to-imagebuild in your local registry. If the builder-image is not present in the local registry, mirror the source image.
Procedure
Run the following command to mirror the images that
source-to-imagebuild strategy requires:oc image mirror --insecure -a <registry_authentication> registry.redhat.io/source-to-image/source-to-image-rhel8@sha256:d041c1bbe503d152d0759598f79802e257816d674b342670ef61c6f9e6d401c5 <mirror_registry>/<repo>/source-to-image-source-to-image-rhel8
$ oc image mirror --insecure -a <registry_authentication> registry.redhat.io/source-to-image/source-to-image-rhel8@sha256:d041c1bbe503d152d0759598f79802e257816d674b342670ef61c6f9e6d401c5 <mirror_registry>/<repo>/source-to-image-source-to-image-rhel8Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
<registry_authentication>- Specifies the authentication credentials used to access a container registry. This is required when pushing to or pulling from a private registry.
<mirror_registry>- Specifies the registry where the image you want to mirror is stored.
<image_name>- Specifies the name of the mirror image.
<tag>- Specifies the tag of the image.
- Perform the steps mentioned in the "Creating a source-to-image build" section.
2.3. Verifying proxy details 复制链接链接已复制到粘贴板!
If you run a cluster behind a proxy, ensure that cluster-wide proxy settings and environment variables are correctly configured in the OpenShift Container Platform cluster. This ensures all Builds traffic is routed through the monitored outbound proxy gateway.
Prerequisites
-
You have installed the
ocCLI.
Procedure
To verify the cluster-wide proxy settings, run the following command:
oc describe proxy/cluster
$ oc describe proxy/clusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To verify the environment variables, run the following command:
oc set env deployment/openshift-builds-operator --list -n openshift-builds | grep PROXY
$ oc set env deployment/openshift-builds-operator --list -n openshift-builds | grep PROXYCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output:
HTTP_PROXY=http://192.168.130.1:3128 HTTPS_PROXY=https://192.168.130.1:3129 NO_PROXY=.cluster.local,.svc,.testing,10.217.0.0/22,10.217.4.0/23,127.0.0.1,192.168.126.0/24,192.168.1 30.11,api-int.crc.testing,localhost
HTTP_PROXY=http://192.168.130.1:3128 HTTPS_PROXY=https://192.168.130.1:3129 NO_PROXY=.cluster.local,.svc,.testing,10.217.0.0/22,10.217.4.0/23,127.0.0.1,192.168.126.0/24,192.168.1 30.11,api-int.crc.testing,localhostCopy to Clipboard Copied! Toggle word wrap Toggle overflow