OpenShift 4.2 etcd operatorhub离线环境部署

本文记录在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

 

posted @ 2019-12-03 15:34  ericnie  阅读(894)  评论(0编辑  收藏  举报