-
Notifications
You must be signed in to change notification settings - Fork 2
/
image.registries.conf.sh
128 lines (100 loc) · 3.23 KB
/
image.registries.conf.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env bash
set -e
set -x
parm_local_reg=$1
parm_file=$2
#export LOCAL_REG='registry.redhat.ren:5443'
# export MID_REG="registry.redhat.ren"
# export OCP_RELEASE=${BUILDNUMBER}
# export LOCAL_REG='registry.redhat.ren'
# export LOCAL_REPO='ocp4/openshift4'
# export UPSTREAM_REPO='openshift-release-dev'
# export LOCAL_SECRET_JSON="pull-secret.json"
# export OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE=${LOCAL_REG}/${LOCAL_REPO}:${OCP_RELEASE}
# export RELEASE_NAME="ocp-release"
# /bin/rm -rf ./operator/yaml/
# mkdir -p ./operator/yaml/
cat pull.image.ok.list ${parm_file} mapping-*.txt | sed 's/\/.*$//g' | egrep "^.*\.(io|com|org|net)$" | sort | uniq > mirror.domain.list
# cat pull.image.ok.list ${parm_file} mapping-*.txt | sed 's/\/.*$//g' | sort | uniq > mirror.domain.list
cat << EOF > ./image.registries.conf
EOF
yaml_docker_image(){
docker_image=$1
# local_image=$(echo $2 | sed "s/${MID_REG}/${LOCAL_REG}/")
num=$2
# echo $docker_image
cat << EOF >> ./image.registries.conf
[[registry]]
location = "${docker_image}"
insecure = false
blocked = false
mirror-by-digest-only = false
prefix = "${docker_image}"
[[registry.mirror]]
location = "${parm_local_reg}"
insecure = true
EOF
}
declare -i num=1
while read -r line; do
# docker_image=$(echo $line | awk '{split($0,a,"\t"); print a[1]}')
# local_image=$(echo $line | awk '{split($0,a,"\t"); print a[2]}')
docker_image=$line
echo $docker_image
# echo $local_image
# yaml_docker_image $docker_image $local_image $num
yaml_docker_image $docker_image $num
num=${num}+1;
done < mirror.domain.list
cat << EOF >> ./image.registries.conf
[[registry]]
location = "${parm_local_reg}"
insecure = true
blocked = false
mirror-by-digest-only = false
prefix = ""
EOF
# config_source=$(cat ./image.registries.conf | python3 -c "import sys, urllib.parse; print(urllib.parse.quote(''.join(sys.stdin.readlines())))" )
config_source=$( cat ./image.registries.conf | python3 -c "import sys, base64; sys.stdout.buffer.write(base64.urlsafe_b64encode(bytes(''.join(sys.stdin.readlines()), 'utf-8') ) ) " )
cat <<EOF > 99-worker-container-registries.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 99-worker-container-registries
spec:
config:
ignition:
version: 3.1.0
storage:
files:
- contents:
# source: data:text/plain,
source: data:text/plain;charset=utf-8;base64,${config_source}
verification: {}
filesystem: root
mode: 420
path: /etc/containers/registries.conf.d/custom-registries.conf
EOF
cat <<EOF > 99-master-container-registries.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: master
name: 99-master-container-registries
spec:
config:
ignition:
version: 3.1.0
storage:
files:
- contents:
# source: data:text/plain,
source: data:text/plain;charset=utf-8;base64,${config_source}
verification: {}
filesystem: root
mode: 420
path: /etc/containers/registries.conf.d/custom-registries.conf
EOF