Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions image-sync/configuration/mvp-oc-mirror.yml

This file was deleted.

3 changes: 2 additions & 1 deletion image-sync/deployment/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ deploy-oc-mirror:
--set serviceAccountName=image-sync \
--set azureClientId=$${AZURE_SYNC_MI_CLIENT_ID} \
--set acrRegistryName=${ARO_HCP_IMAGE_ACR} \
--set stableVersions="4.16\,4.17" \
--set azureTenantId=$${TENANT_ID} \
--set ocmirrorImage="arohcpdev.azurecr.io/image-sync/ocmirror" \
--set ocmirrorTag=latest \
--set credsPullSecret=pull-secret \
--set credsKeyVaultName=service-kv-aro-hcp-dev
--set credsKeyVaultName=aro-hcp-dev-svc-kv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a param?


deploy: deploy-shared deploy-component-sync deploy-oc-mirror

Expand Down
11 changes: 4 additions & 7 deletions image-sync/deployment/ocmirrorCronjob/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,21 @@ spec:
containers:
- image: "{{ .Values.ocmirrorImage }}:{{ .Values.ocmirrorTag }}"
name: oc-mirror
command: ["oc-mirror", "--continue-on-error", "--config", "/etc/oc-mirror/imageset-config.yml", "docker://{{ .Values.acrRegistryName }}.azurecr.io"]
workingDir: "/workspace"
env:
- name: XDG_RUNTIME_DIR
value: /etc/
- name: REGISTRY_URL
value: "{{ .Values.acrRegistryName }}.azurecr.io"
- name: STABLE_VERSIONS
value: "{{ .Values.stableVersions }}"
volumeMounts:
- name: oc-mirror-config
mountPath: "/etc/oc-mirror"
readOnly: true
- name: pull-secrets-updated
mountPath: "/etc/containers"
readOnly: true
- name: workspace
mountPath: "/workspace"
volumes:
- name: oc-mirror-config
configMap:
name: oc-mirror-config
- name: workspace
emptyDir: {}
- name: pull-secrets-updated
Expand Down
1 change: 1 addition & 0 deletions image-sync/deployment/ocmirrorCronjob/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
acrRegistryName: ""
stableVersions: ""

azureClientId: ""
azureTenantId: ""
Expand Down
11 changes: 7 additions & 4 deletions image-sync/oc-mirror/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS downloader
FROM --platform=linux/amd64 mcr.microsoft.com/cbl-mariner/base/core:2.0 AS downloader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to specify platform here? Should the container infer it depending on the platform you run on?


RUN set -eux; \
# Upgrade all packages per https://eng.ms/docs/more/containers-secure-supply-chain/updating
tdnf update -y; \
tdnf -y install unzip wget tar ca-certificates; \
tdnf -y install unzip wget tar ca-certificates; \
tdnf clean all

ENV OC_VERSION=4.16.3
Expand All @@ -17,19 +17,22 @@ RUN curl -sfL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OC_VER
tar -zvxf oc-mirror.tar.gz && \
mv oc-mirror /usr/local/bin

FROM mcr.microsoft.com/cbl-mariner/base/core:2.0
FROM --platform=linux/amd64 mcr.microsoft.com/cbl-mariner/base/core:2.0

RUN mkdir --mode=777 /workspace; \
mkdir --mode=777 /config; \
tdnf update -y; \
tdnf -y install ca-certificates; \
tdnf clean all

WORKDIR /workspace

ADD mirror.sh /usr/local/bin/mirror.sh

COPY --chown=0:0 --chmod=755 --from=downloader \
/usr/local/bin/oc-mirror \
/usr/local/bin/oc \
/usr/local/bin/kubectl \
/usr/local/bin/

ENTRYPOINT ["oc-mirror", "--continue-on-error", "--config", "/etc/oc-mirror/imageset-config.yml"]
ENTRYPOINT ["/usr/local/bin/mirror.sh"]
1 change: 0 additions & 1 deletion image-sync/oc-mirror/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ OC_MIRROR_IMAGE_TAGGED ?= $(OC_MIRROR_IMAGE):$(COMMIT)
build-push: image push

image:
cp ../configuration/mvp-oc-mirror.yml config.yml
docker build --platform="linux/amd64" -f "./Dockerfile" -t ${OC_MIRROR_IMAGE_TAGGED} .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs say "podman" can we update docker -> podman or vice versa? Or do we have a preference?


push: image
Expand Down
49 changes: 22 additions & 27 deletions image-sync/oc-mirror/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,34 @@ This container contains oc-mirror end required dependencies.

## Example usage for devarohcp

* Build the container image `podman build -t oc-mirror .`
* Alternatively, use `make image`
* Get credentials for Openshift registries https://console.redhat.com/openshift/install/pull-secret
* Get Azure registry credentials `az acr login -n devarohcp`
* Run the sync using the built container
- Build the container image `podman build -t oc-mirror .`
- Alternatively, use `make image`
- Get credentials for Openshift registries https://console.redhat.com/openshift/install/pull-secret
- Get Azure registry credentials `DOCKER_COMMAND=podman az acr login --name arohcpdev`
- Run the sync using the built container

On Linux

```BASH
podman run -it --rm --tmpfs /oc-mirror-workspace \
-e XDG_RUNTIME_DIR=/ \
-v $PWD/imageset-config.yml:/imageset-config.yml:Z \
-e STABLE_VERSIONS=4.16,4.17 \
-e REGISTRY_URL=arohcpdev.azurecr.io \
-v $HOME/.docker/config.json:/containers/auth.json:Z \
oc-mirror \
oc mirror --config=/imageset-config.yml docker://devarohcp.azurecr.io --dry-run
--dry-run
```

Note, the above command will run the sync in dry-run mode. To run the sync, remove the `--dry-run` flag.
On OSX

## Example configuration

The following is an example of the configuration file `imageset-config.yml`.

This exact configuration was used in the initial testing of the `oc-mirror` tool.

```YAML
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
registry:
imageURL: devarohcp.azurecr.io/mirror/oc-mirror-metadata
skipTLS: false
mirror:
platform:
channels:
- name: stable-4.16
type: ocp
graph: true
```BASH
podman run -it --rm --tmpfs /oc-mirror-workspace \
-e XDG_RUNTIME_DIR=/ \
-e STABLE_VERSIONS=4.16,4.17 \
-e REGISTRY_URL=arohcpdev.azurecr.io \
-v $HOME/.config/containers/auth.json:/containers/auth.json:Z \
oc-mirror \
--dry-run
```

Note, the above command will run the sync in dry-run mode. To run the sync, remove the `--dry-run` flag.
30 changes: 0 additions & 30 deletions image-sync/oc-mirror/config.yml

This file was deleted.

16 changes: 0 additions & 16 deletions image-sync/oc-mirror/imageset-config.yml

This file was deleted.

25 changes: 25 additions & 0 deletions image-sync/oc-mirror/imageset-config.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
kind: ImageSetConfiguration
apiVersion: mirror.openshift.io/v1alpha2
storageConfig:
registry:
imageURL: {{ .RegistryUrl }}/mirror/oc-mirror-metadata
skipTLS: false
mirror:
platform:
architectures:
- multi
- amd64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need amd64 images still, or can we switch everything to multi yet?

channels:
{{- range .StableVersions }}
- name: stable-{{ . }}
type: ocp
full: true
{{- end }}
graph: true
additionalImages:
{{- range .StableVersions }}
- name: registry.redhat.io/redhat/redhat-operator-index:v{{ . }}
- name: registry.redhat.io/redhat/certified-operator-index:v{{ . }}
- name: registry.redhat.io/redhat/community-operator-index:v{{ . }}
- name: registry.redhat.io/redhat/redhat-marketplace-index:v{{ . }}
{{- end }}
4 changes: 4 additions & 0 deletions image-sync/oc-mirror/mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo ${IMAGE_SET_CONFIG} | base64 -d /config/imageset-config.yml
/usr/local/bin/oc-mirror --continue-on-error --config /config/imageset-config.yml docker://${REGISTRY_URL} @$