本文記錄在OperatorHub中存在界面但缺少鏡像的環境下如何安裝部署。感謝王征提供的大力支持和指導。

現在一個在線環境找到etcd所需要的鏡像
quay.io/coreos/etcd-operator@sha256:66a37fd61a06a43969854ee6d3e21087a98b93838e284a6086b13917f96b0d9b quay.io/coreos/etcd:v3.2.13 docker.io/library/busybox:1.28.0-glibc
找一個能上網的機器,建立registry.redhat.ren的docker-distribution,通過oc image mirror命令把鏡像的相關信息復制到本地
oc image mirror quay.io/coreos/etcd-operator@sha256:66a37fd61a06a43969854ee6d3e21087a98b93838e284a6086b13917f96b0d9b registry.redhat.ren/quay.io/coreos/etcd-operator
將本地的registry打包成tgz文件,
tar zcvf registry-etcd.tgz registry
然后上傳到自己離線的registry,然后解壓。
修改helper機器上的image.registries.conf,添加如下記錄
[[registry]] location = "quay.io/coreos/etcd-operator" insecure = false blocked = false mirror-by-digest-only = false prefix = "" [[registry.mirror]] location = "registry.redhat.ren/quay.io/coreos/etcd-operator" insecure = true [[registry]] location = "docker.io/library/busybox" insecure = false blocked = false mirror-by-digest-only = false prefix = "" [[registry.mirror]] location = "registry.redhat.ren/docker.io/library/busybox" insecure = true [[registry]] location = "quay.io/coreos/etcd" insecure = false blocked = false mirror-by-digest-only = false prefix = "" [[registry.mirror]] location = "registry.redhat.ren/quay.io/coreos/etcd" insecure = true
然后運行
config_source=$(cat ./image.registries.conf | python3 -c "import sys, urllib.parse; print(urllib.parse.quote(''.join(sys.stdin.readlines())))" ) 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: 2.2.0 storage: files: - contents: source: data:text/plain,${config_source} verification: {} filesystem: root mode: 420 path: /etc/containers/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: 2.2.0 storage: files: - contents: source: data:text/plain,${config_source} verification: {} filesystem: root mode: 420 path: /etc/containers/registries.conf EOF
oc apply -f ./99-worker-container-registries.yaml -n openshift-config oc apply -f ./99-master-container-registries.yaml -n openshift-config
通過podman push把另外兩個鏡像推入到正確的位置,然后安裝etcd Operator, 再建立etcd cluster.

[root@helper ocp4]# oc get pods NAME READY STATUS RESTARTS AGE etcd-operator-7f95f8497c-cczf9 3/3 Running 0 3h46m example-f6jg6px9q4 1/1 Running 0 3h44m example-mvlbn7v2tl 1/1 Running 0 3h43m example-wkgcgjgpw4 1/1 Running 0 3h43m
