6.3.4. 配置对 air-gapped OpenShift 集群中的 Clair 数据库的访问

  • 使用 kubectl 确定 Clair 数据库服务:

    $ kubectl get svc -n quay-enterprise
    
    NAME                                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                             AGE
    example-registry-clair-app            ClusterIP      172.30.224.93    <none>        80/TCP,8089/TCP                     4d21h
    example-registry-clair-postgres       ClusterIP      172.30.246.88    <none>        5432/TCP                            4d21h
    ...
  • 转发 Clair 数据库端口,以便可以从本地机器访问,例如:

    $ kubectl port-forward -n quay-enterprise service/example-registry-clair-postgres 5432:5432
  • 更新 Clair 配置文件,将多个 connstring 字段中 的主机 值替换为 localhost,例如:

    clair-config.yaml

        ...
        connstring: host=localhost port=5432 dbname=postgres user=postgres password=postgres sslmode=disable
        ...

注意

作为使用 kubectl port-forward 的替代选择,您可以使用 kubefwd 替代。使用此方法时,不需要修改 Clair 配置文件中的 connstring 字段来使用 localhost