【问题标题】:How to point a CNAME to an OpenShift route如何将 CNAME 指向 OpenShift 路由
【发布时间】:2021-09-17 00:56:49
【问题描述】:

我在 OpenShift 上托管的应用程序有一个带有如下 URL 的路由:

https://books-student-book-reservation-backend-project.apps.amarige.hostname.us

我想为最终用户提供一个如下所示的 URL:https://breeze.us。首先它隐藏了 OpenShift URL 结构,其次它更容易记住。归根结底,它对用户更友好。

挑战在于,当我将微风.us 重定向到 OpenShift 路由时,我从 OpenShift 收到“应用程序不可用”错误。

关于如何解决这个问题的任何建议?

【问题讨论】:

    标签: kubernetes openshift


    【解决方案1】:

    https://docs.openshift.com/online/pro/dev_guide/routes.html#custom-route-and-hosts-and-certificates-restrictions

    如果您使用的是 OpenShift Online

    在 OpenShift Online Starter 中,不允许自定义主机名。您可以购买 OpenShift Online Pro(允许设置自定义主机名),或使用反向代理将您的流量(从具有自定义主机名的另一台服务器)重定向到 OpenShift。

    如果您使用的是自行部署的 OKD

    您可以像这样为您的路由设置自定义主机名:

    # A example unsecured route with custom hostname
    apiVersion: v1
    kind: Route
    metadata:
      name: route-unsecured
    spec:
      host: www.your-custom-hostname.com  # here
      to:
        kind: Service
        name: service-name
    

    如果您需要在同一个主机名下服务多个路由,您还可以使用自定义主机名进行基于路径的路由:

    # A example unsecured path-based route with custom hostname
    apiVersion: v1
    kind: Route
    metadata:
      name: route-unsecured
    spec:
      host: www.your-custom-hostname.com
      path: "/test"      # here
      to:
        kind: Service
        name: service-name
    

    这样您就可以使用www.your-custom-hostname.com/test 访问您的路线。

    【讨论】:

    • 我实际上有自己的 OKD 4.8 部署。我没有使用 OpenShift Online。
    • @BillyBilly 这是很重要的信息。我已经更新了我的答案。
    • 太棒了。这样就完成了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-05
    • 2021-05-21
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2017-09-04
    相关资源
    最近更新 更多