-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmirror-operator.sh
56 lines (41 loc) · 1.92 KB
/
mirror-operator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#########################################
#### Purpose : Setup mirroring ######
#### Author : Largou Walid ######
#### Version : 1.0 ######
#########################################
## Variables
redhatpass=xxxxxx
quaypass=xxxxxx
registryuser=myuser
registrypassword=mypassword
registryport=5000
hostname=$HOSTNAME
registryname=${hostname}:${registryport}
REG_CREDS=/run/user/0/containers/auth.json
tempdir=/opt/tools
targetdir=/opt/download
## Tools
mkdir -p $tempdir
cd $tempdir
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest-4.6/opm-linux.tar.gz
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/latest-4.6/openshift-client-linux.tar.gz
wget https://github.com/fullstorydev/grpcurl/releases/download/v1.8.5/grpcurl_1.8.5_linux_x86_64.tar.gz
tar -xvf grpcurl_1.8.5_linux_x86_64.tar.gz
tar -xvf openshift-client-linux.tar.gz
tar -xvf opm-linux.tar.gz
cp opm oc kubectl grpcurl /usr/local/bin/
#### Mirroring
podman login registry.redhat.io -u ${redhatlogin} -p ${redhatpass}
podman login quay.io -u ${quaylogin} -p ${quaypass}
podman run -d -p50051:50051 registry.redhat.io/redhat/redhat-operator-index:v4.8
opm index prune -f registry.redhat.io/redhat/redhat-operator-index:v4.8 -p openshift-gitops-operator,openshift-pipelines-operator-rh,eap -t ${registryname}/openshift4-ohi/redhat-operator-index:v4.8
podman login ${hostname}:${registryport} -u ${registryuser} -p ${registrypassword}
podman push ${registryname}/openshift4-ohi/redhat-operator-index:v4.8
mkdir $targetdir
cd $targetdir
oc adm catalog mirror ${registryname}/openshift4-ohi/redhat-operator-index:v4.8 file:///local/index -a ${REG_CREDS} --insecure --index-filter-by-os=Linux/amd64
tar -cvf offline-images.tar.gz .
sha256sum offline-images.tar.gz > offline-images.tar.gz.sha256
### Test after copy with sha256sum -c offline-images.tar.gz.sha256