5.4. 在远程服务器上设置 Red Hat OpenShift Local

配置远程服务器以运行由 Red Hat OpenShift Local 提供的 OpenShift Container Platform 集群。

这个过程假设使用 Red Hat Enterprise Linux、Fedora 或 CentOS 服务器。在远程服务器中运行此流程中的每个命令。

警告

仅在本地网络中执行此步骤。在互联网上公开不安全的服务器存在许多安全隐患。

先决条件

流程

  1. 启动集群:

    $ crc start

    确保集群在此过程中保持运行。

  2. 安装 haproxy 软件包和其他工具:

    $ sudo dnf install haproxy /usr/sbin/semanage
  3. 修改防火墙以允许与集群通信:

    $ sudo systemctl enable --now firewalld
    $ sudo firewall-cmd --add-service=http --permanent
    $ sudo firewall-cmd --add-service=https --permanent
    $ sudo firewall-cmd --add-service=kube-apiserver --permanent
    $ sudo firewall-cmd --reload
  4. 对于 SELinux,允许 HAProxy 侦听 TCP 端口 6443 为这个端口上提供 kube-apiserver

    $ sudo semanage port -a -t http_port_t -p tcp 6443
  5. 创建默认 haproxy 配置的备份:

    $ sudo cp /etc/haproxy/haproxy.cfg{,.bak}
  6. 配置 haproxy 以与集群搭配使用:

    $ export CRC_IP=$(crc ip)
    $ sudo tee /etc/haproxy/haproxy.cfg &>/dev/null <<EOF
    global
        log /dev/log local0
    
    defaults
        balance roundrobin
        log global
        maxconn 100
        mode tcp
        timeout connect 5s
        timeout client 500s
        timeout server 500s
    
    listen apps
        bind 0.0.0.0:80
        server crcvm $CRC_IP:80 check
    
    listen apps_ssl
        bind 0.0.0.0:443
        server crcvm $CRC_IP:443 check
    
    listen api
        bind 0.0.0.0:6443
        server crcvm $CRC_IP:6443 check
    EOF
  7. 启动 haproxy 服务:

    $ sudo systemctl start haproxy