2017年1月20日星期五

OpenShift_027:离线安装 OCP 3.4 之 环境准备 之 本地 Docker Registry 配置

1.  安装并配置 Docker Registry (在 Registry 机器上操作)
yum -y install docker-registry;
systemctl enable docker-registry;
systemctl start docker-registry;

mkdir /opt/ose/images

2. 拷贝之前下载的镜像到 Registry(在 MAC 上操作)
scp ose-images-core-v3.4.0.39.tar.gz root@192.168.56.112:/opt/ose/images/
scp ose-images-logging_metric-v3.4.0.tar.gz root@192.168.56.112:/opt/ose/images/
scp ose-images-apps-latest_20170119.tar.gz root@192.168.56.112:/opt/ose/images/

3. 加载所有镜像(在 Registry 机器上操作
cd /opt/ose/images/
for i in `ls *.tar.gz` ; do docker load -i $i; done;

docker images;

输出如下:
REPOSITORY                                                                   TAG                 IMAGE ID            CREATED             SIZE
registry.access.redhat.com/openshift3/logging-elasticsearch                  v3.4                3faf59ca2a97        6 days ago          399 MB
registry.access.redhat.com/openshift3/logging-deployer                       v3.4                910537ac6658        6 days ago          763 MB
registry.access.redhat.com/openshift3/metrics-deployer                       v3.4                2f1483e3e389        6 days ago          769.7 MB
registry.access.redhat.com/openshift3/ose-sti-builder                        v3.4.0.39           904666216ea7        6 days ago          604.5 MB
registry.access.redhat.com/openshift3/ose-haproxy-router                     v3.4.0.39           d6c17004c16c        6 days ago          621.3 MB
registry.access.redhat.com/openshift3/ose-docker-builder                     v3.4.0.39           161c05f56506        6 days ago          604.5 MB
registry.access.redhat.com/openshift3/ose-deployer                           v3.4.0.39           16b04bd97cf7        6 days ago          604.5 MB
registry.access.redhat.com/openshift3/logging-curator                        v3.4                e8e3b80ea540        6 days ago          244.3 MB
registry.access.redhat.com/openshift3/logging-auth-proxy                     v3.4                d22da7f89efe        6 days ago          219.8 MB
registry.access.redhat.com/openshift3/ose-keepalived-ipfailover              v3.4.0.39           695877475b1a        6 days ago          288.7 MB
registry.access.redhat.com/openshift3/ose-docker-registry                    v3.4.0.39           ad19b4c7468a        6 days ago          684.3 MB
registry.access.redhat.com/openshift3/nodejs-010-rhel7                       latest              226d0b1b7987        6 days ago          430.2 MB
registry.access.redhat.com/openshift3/ose-pod                                v3.4.0.39           d3056432d706        6 days ago          205 MB
registry.access.redhat.com/openshift3/logging-kibana                         v3.4                fa619423c707        6 days ago          338.6 MB
registry.access.redhat.com/openshift3/metrics-heapster                       v3.4                04c115b270b4        6 days ago          317.8 MB
registry.access.redhat.com/openshift3/logging-fluentd                        v3.4                ceadd7faf90e        6 days ago          232.5 MB
registry.access.redhat.com/openshift3/jenkins-2-rhel7                        latest              6051679e8e5c        6 days ago          678.2 MB
registry.access.redhat.com/openshift3/jenkins-1-rhel7                        latest              ab93effc37cc        6 days ago          673.1 MB
registry.access.redhat.com/openshift3/metrics-cassandra                      v3.4                b5d700281ef7        4 weeks ago         649.2 MB
registry.access.redhat.com/openshift3/metrics-hawkular-metrics               v3.4                ef113cd9dc4a        4 weeks ago         1.508 GB
registry.access.redhat.com/jboss-amq-6/amq62-openshift                       latest              c4cf8db67ec3        5 weeks ago         594.2 MB
registry.access.redhat.com/jboss-eap-7/eap70-openshift                       latest              92138ab3d385        5 weeks ago         1.207 GB
registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift   latest              d8f7cc1e44b4        5 weeks ago         686.9 MB
registry.access.redhat.com/rhscl/ruby-23-rhel7                               latest              649708ab3fa4        7 weeks ago         458.4 MB
registry.access.redhat.com/rhscl/python-35-rhel7                             latest              3e722751e168        7 weeks ago         513.4 MB
registry.access.redhat.com/rhscl/php-56-rhel7                                latest              8dfb47719cd5        7 weeks ago         484.5 MB
registry.access.redhat.com/rhscl/mongodb-32-rhel7                            latest              23681eff7577        7 weeks ago         563.1 MB
registry.access.redhat.com/rhscl/mysql-56-rhel7                              latest              a2d6674acb24        7 weeks ago         366.3 MB
registry.access.redhat.com/rhscl/redis-32-rhel7                              latest              2679220a6fa4        7 weeks ago         218.6 MB

确认推送成功后,可以删除 .tar.gz 文件
rm *.tar.gz

4. 推送镜像到本地 Docker Registry在 Registry 机器上操作
cp /etc/sysconfig/docker /etc/sysconfig/docker.bak.$(date "+%Y%m%d%H%M%S");
sed  -i s/".*OPTIONS=.*"/"OPTIONS='--selinux-enabled --insecure-registry 172.30.0.0\/16 --insecure-registry registry.example.com:5000'"/g /etc/sysconfig/docker;
sed -i 's/registry.access.redhat.com/registry.example.com:5000/g' /etc/sysconfig/docker;
systemctl restart docker

REDHAT_REG="registry.access.redhat.com";
PRIVATE_REG="registry.example.com:5000";
for i in $(docker images|grep $REDHAT_REG|awk '{print $1":"$2}') ; do docker tag  $i "$PRIVATE_REG$(echo $i|awk -F 'com' {'print $2'})" ; done;
for i in `docker images|grep $PRIVATE_REG|awk '{print $1":"$2}'` ; do  docker push $i; done;

docker images
输出如下:
REPOSITORY                                                                   TAG                 IMAGE ID            CREATED             SIZE
registry.example.com:5000/openshift3/logging-elasticsearch                   v3.4                3faf59ca2a97        6 days ago          399 MB
registry.access.redhat.com/openshift3/logging-elasticsearch                  v3.4                3faf59ca2a97        6 days ago          399 MB
registry.access.redhat.com/openshift3/logging-deployer                       v3.4                910537ac6658        6 days ago          763 MB
registry.example.com:5000/openshift3/logging-deployer                        v3.4                910537ac6658        6 days ago          763 MB
registry.access.redhat.com/openshift3/metrics-deployer                       v3.4                2f1483e3e389        6 days ago          769.7 MB
registry.example.com:5000/openshift3/metrics-deployer                        v3.4                2f1483e3e389        6 days ago          769.7 MB
registry.access.redhat.com/openshift3/ose-sti-builder                        v3.4.0.39           904666216ea7        6 days ago          604.5 MB
registry.example.com:5000/openshift3/ose-sti-builder                         v3.4.0.39           904666216ea7        6 days ago          604.5 MB
registry.access.redhat.com/openshift3/ose-haproxy-router                     v3.4.0.39           d6c17004c16c        6 days ago          621.3 MB
registry.example.com:5000/openshift3/ose-haproxy-router                      v3.4.0.39           d6c17004c16c        6 days ago          621.3 MB
registry.access.redhat.com/openshift3/ose-docker-builder                     v3.4.0.39           161c05f56506        6 days ago          604.5 MB
registry.example.com:5000/openshift3/ose-docker-builder                      v3.4.0.39           161c05f56506        6 days ago          604.5 MB
registry.access.redhat.com/openshift3/ose-deployer                           v3.4.0.39           16b04bd97cf7        6 days ago          604.5 MB
registry.example.com:5000/openshift3/ose-deployer                            v3.4.0.39           16b04bd97cf7        6 days ago          604.5 MB
registry.example.com:5000/openshift3/logging-curator                         v3.4                e8e3b80ea540        6 days ago          244.3 MB
registry.access.redhat.com/openshift3/logging-curator                        v3.4                e8e3b80ea540        6 days ago          244.3 MB
registry.access.redhat.com/openshift3/logging-auth-proxy                     v3.4                d22da7f89efe        6 days ago          219.8 MB
registry.example.com:5000/openshift3/logging-auth-proxy                      v3.4                d22da7f89efe        6 days ago          219.8 MB
registry.access.redhat.com/openshift3/ose-keepalived-ipfailover              v3.4.0.39           695877475b1a        6 days ago          288.7 MB
registry.example.com:5000/openshift3/ose-keepalived-ipfailover               v3.4.0.39           695877475b1a        6 days ago          288.7 MB
registry.access.redhat.com/openshift3/ose-docker-registry                    v3.4.0.39           ad19b4c7468a        6 days ago          684.3 MB
registry.example.com:5000/openshift3/ose-docker-registry                     v3.4.0.39           ad19b4c7468a        6 days ago          684.3 MB
registry.access.redhat.com/openshift3/nodejs-010-rhel7                       latest              226d0b1b7987        6 days ago          430.2 MB
registry.example.com:5000/openshift3/nodejs-010-rhel7                        latest              226d0b1b7987        6 days ago          430.2 MB
registry.access.redhat.com/openshift3/ose-pod                                v3.4.0.39           d3056432d706        6 days ago          205 MB
registry.example.com:5000/openshift3/ose-pod                                 v3.4.0.39           d3056432d706        6 days ago          205 MB
registry.example.com:5000/openshift3/logging-kibana                          v3.4                fa619423c707        6 days ago          338.6 MB
registry.access.redhat.com/openshift3/logging-kibana                         v3.4                fa619423c707        6 days ago          338.6 MB
registry.access.redhat.com/openshift3/metrics-heapster                       v3.4                04c115b270b4        6 days ago          317.8 MB
registry.example.com:5000/openshift3/metrics-heapster                        v3.4                04c115b270b4        6 days ago          317.8 MB
registry.access.redhat.com/openshift3/logging-fluentd                        v3.4                ceadd7faf90e        6 days ago          232.5 MB
registry.example.com:5000/openshift3/logging-fluentd                         v3.4                ceadd7faf90e        6 days ago          232.5 MB
registry.access.redhat.com/openshift3/jenkins-2-rhel7                        latest              6051679e8e5c        6 days ago          678.2 MB
registry.example.com:5000/openshift3/jenkins-2-rhel7                         latest              6051679e8e5c        6 days ago          678.2 MB
registry.access.redhat.com/openshift3/jenkins-1-rhel7                        latest              ab93effc37cc        6 days ago          673.1 MB
registry.example.com:5000/openshift3/jenkins-1-rhel7                         latest              ab93effc37cc        6 days ago          673.1 MB
registry.access.redhat.com/openshift3/metrics-cassandra                      v3.4                b5d700281ef7        4 weeks ago         649.2 MB
registry.example.com:5000/openshift3/metrics-cassandra                       v3.4                b5d700281ef7        4 weeks ago         649.2 MB
registry.access.redhat.com/openshift3/metrics-hawkular-metrics               v3.4                ef113cd9dc4a        4 weeks ago         1.508 GB
registry.example.com:5000/openshift3/metrics-hawkular-metrics                v3.4                ef113cd9dc4a        4 weeks ago         1.508 GB
registry.access.redhat.com/jboss-amq-6/amq62-openshift                       latest              c4cf8db67ec3        5 weeks ago         594.2 MB
registry.example.com:5000/jboss-amq-6/amq62-openshift                        latest              c4cf8db67ec3        5 weeks ago         594.2 MB
registry.access.redhat.com/jboss-eap-7/eap70-openshift                       latest              92138ab3d385        5 weeks ago         1.207 GB
registry.example.com:5000/jboss-eap-7/eap70-openshift                        latest              92138ab3d385        5 weeks ago         1.207 GB
registry.access.redhat.com/jboss-webserver-3/webserver30-tomcat8-openshift   latest              d8f7cc1e44b4        5 weeks ago         686.9 MB
registry.example.com:5000/jboss-webserver-3/webserver30-tomcat8-openshift    latest              d8f7cc1e44b4        5 weeks ago         686.9 MB
registry.example.com:5000/rhscl/ruby-23-rhel7                                latest              649708ab3fa4        7 weeks ago         458.4 MB
registry.access.redhat.com/rhscl/ruby-23-rhel7                               latest              649708ab3fa4        7 weeks ago         458.4 MB
registry.access.redhat.com/rhscl/python-35-rhel7                             latest              3e722751e168        7 weeks ago         513.4 MB
registry.example.com:5000/rhscl/python-35-rhel7                              latest              3e722751e168        7 weeks ago         513.4 MB
registry.access.redhat.com/rhscl/php-56-rhel7                                latest              8dfb47719cd5        7 weeks ago         484.5 MB
registry.example.com:5000/rhscl/php-56-rhel7                                 latest              8dfb47719cd5        7 weeks ago         484.5 MB
registry.access.redhat.com/rhscl/mongodb-32-rhel7                            latest              23681eff7577        7 weeks ago         563.1 MB
registry.example.com:5000/rhscl/mongodb-32-rhel7                             latest              23681eff7577        7 weeks ago         563.1 MB
registry.access.redhat.com/rhscl/mysql-56-rhel7                              latest              a2d6674acb24        7 weeks ago         366.3 MB
registry.example.com:5000/rhscl/mysql-56-rhel7                               latest              a2d6674acb24        7 weeks ago         366.3 MB
registry.access.redhat.com/rhscl/redis-32-rhel7                              latest              2679220a6fa4        7 weeks ago         218.6 MB
registry.example.com:5000/rhscl/redis-32-rhel7                               latest              2679220a6fa4        7 weeks ago         218.6 MB

5. 验证能否成功下载镜像 (在所有机器上操作)
docker pull registry.example.com:5000/rhscl/php-56-rhel7

没有评论: