12.2.13. 启用对环境的访问

在部署时,所有 OpenShift Container Platform 机器都是在 Red Hat OpenStack Platform (RHOSP) 租户网络中创建的。因此,大多数 RHOSP 部署中都无法直接访问它们。

您可以在安装过程中使用浮动 IP 地址(FIP)来配置 OpenShift Container Platform API 和应用程序访问。您也可以在没有配置 FIP 的情况下完成安装,但安装程序不会配置一种从外部访问 API 或应用程序的方法。

12.2.13.1. 启用通过浮动 IP 地址进行访问

创建浮动 IP(FIP)地址,用于从外部访问 OpenShift Container Platform API 和集群应用程序。

流程

  1. 使用 Red Hat OpenStack Platform (RHOSP) CLI,创建 API FIP:

    $ openstack floating ip create --description "API <cluster_name>.<base_domain>" <external_network>
  2. 使用 Red Hat OpenStack Platform (RHOSP) CLI,创建应用程序或 Ingress,FIP:

    $ openstack floating ip create --description "Ingress <cluster_name>.<base_domain>" <external_network>
  3. 向用于 API 和 Ingress FIP 的 DNS 服务器添加符合这些模式的记录:

    api.<cluster_name>.<base_domain>.  IN  A  <API_FIP>
    *.apps.<cluster_name>.<base_domain>. IN  A <apps_FIP>
    注意

    如果您不控制 DNS 服务器,您可以通过将集群域名(如以下内容)添加到 /etc/hosts 文件中来访问集群:

    • <api_floating_ip> api.<cluster_name>.<base_domain>
    • <application_floating_ip> grafana-openshift-monitoring.apps.<cluster_name>.<base_domain>
    • <application_floating_ip> prometheus-k8s-openshift-monitoring.apps.<cluster_name>.<base_domain>
    • <application_floating_ip> oauth-openshift.apps.<cluster_name>.<base_domain>
    • <application_floating_ip> console-openshift-console.apps.<cluster_name>.<base_domain>
    • application_floating_ip integrate-oauth-server-openshift-authentication.apps.<cluster_name>.<base_domain>

    /etc/hosts 文件中的集群域名授予对本地集群的 Web 控制台和监控界面的访问权限。您还可以使用 kubectloc。您可以使用指向 <application_floating_ip> 的额外条目来访问用户应用程序。此操作使 API 和应用程序可供您访问,不适合于生产部署,但允许对开发和测试进行安装。

  4. 将 FIP 添加到 install-config.yaml 文件,将其作为以下参数的值:

    • platform.openstack.ingressFloatingIP
    • platform.openstack.apiFloatingIP

如果使用这些值,还必须在 install-config.yaml 文件中输入一个外部网络作为 platform.openstack.externalNetwork 参数的值。

提示

您可以通过分配浮动 IP 地址并更新防火墙配置,使 OpenShift Container Platform 资源在集群之外可用。