OpenShift 4 的运行环境开始使用CoreOS Linux作为支撑Container运行的操作系统。CoreOS Linux是一个非常轻量级的Linux,Red Hat将它和OpenShift对接的非常紧密,官方不建议管理员直接进入CoreOS进行管理。不过这也是的管理员对OpenShift Image Registry中的Container操作有一定影响。
下面以CodeReady Container为例说明如何对OpenShift Image Registry的Container操作,将busybox容器导入到OpenShift Image Registry中。
- 在第一个Terminal中执行以下命令:
$ oc login -u kubeadmin -p PASSWD
$ oc project openshift-image-registry
$ oc get pod
NAME READY STATUS RESTARTS AGE
cluster-image-registry-operator-56f5f56b8-6n8l4 2/2 Running 0 10d
image-registry-7456cc4bbd-v24jj 1/1 Running 0 10d
node-ca-tlsk8 1/1 Running 0 10d
#将运行image-registry的容器进行端口影射
$ oc port-forward image-registry-7456cc4bbd-v24jj 5000:5000
Forwarding from 127.0.0.1:5000 -> 5000
Forwarding from [::1]:5000 -> 5000
- 在第二个Terminal中执行以下命令,先将docker.io/busybox镜像pull到本地,然后将它push到Image Registry。
$ oc login -u kubeadmin -p PASSWD
$ oc new-project busybox
$ podman login -u kubeadmin -p $(oc whoami -t) localhost:5000 --tls-verify=false
$ podman pull docker.io/busybox
Trying to pull docker.io/busybox...Getting image source signatures
Copying blob 0f8c40e1270f done
Copying config 020584afcc done
Writing manifest to image destination
Storing signatures
020584afccce44678ec82676db80f68d50ea5c766b6e9d9601f7b5fc86dfb96d
$ podman tag docker.io/busybox localhost:5000/busybox/busybox
$ podman push localhost:5000/busybox/busybox --tls-verify=false
Getting image source signatures
Copying blob 1da8e4c8d307 done
Copying config 020584afcc done
Writing manifest to image destination
Storing signatures
#确认已经有imagestream,而且指向的OpenShift内部的Image Registry
$ oc get is -n busybox
NAME IMAGE REPOSITORY TAGS UPDATED
busybox default-route-openshift-image-registry.apps-crc.testing/busybox/busybox latest 7 minutes ago