2.3. 查找当前路由
验证您是否可以访问其默认主机名上的组件路由。
您可以通过查询
openshift-console
和openshift-authentication
项目中的路由列表来查找主机名。oc get routes -n openshift-console oc get routes -n openshift-authentication
$ oc get routes -n openshift-console $ oc get routes -n openshift-authentication
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD console console-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more console https reencrypt/Redirect None downloads downloads-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more downloads http edge/Redirect None NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD oauth-openshift oauth-openshift.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more oauth-openshift 6443 passthrough/Redirect None
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD console console-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more console https reencrypt/Redirect None downloads downloads-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more downloads http edge/Redirect None NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD oauth-openshift oauth-openshift.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com ... 1 more oauth-openshift 6443 passthrough/Redirect None
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在这个输出中,您可以看到我们的基本主机名为
z9a9.p2.openshiftapps.com
。运行以下命令,获取默认入口的 ID:
export INGRESS_ID=$(ocm list ingress -c ${CLUSTER_NAME} -o json | jq -r '.[] | select(.default == true) | .id')
$ export INGRESS_ID=$(ocm list ingress -c ${CLUSTER_NAME} -o json | jq -r '.[] | select(.default == true) | .id')
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在移至下一部分前,确保所有字段都正确输出:
echo "Ingress ID: ${INGRESS_ID}"
$ echo "Ingress ID: ${INGRESS_ID}"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
Ingress ID: r3l6
Ingress ID: r3l6
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 通过运行这些命令,您可以看到集群的默认组件路由是:
-
console-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com
for Console -
downloads-openshift-console.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com
for Downloads -
oauth-openshift.apps.my-example-cluster-gcp.z9a9.p2.openshiftapps.com
for OAuth
-
我们可以使用 ocm edit ingress
命令更改每个服务的主机名,并为我们的所有组件路由添加一个 TLS 证书。ocm edit ingress
命令的命令行帮助摘录中显示了相关的参数:
ocm edit ingress -h
$ ocm edit ingress -h
Edit a cluster ingress for a cluster. Usage:
ocm edit ingress ID [flags]
[...]
--component-routes string Component routes settings. Available keys [oauth, console, downloads]. For each key a pair of hostname and tlsSecretRef is expected to be supplied. Format should be a comma separate list 'oauth: hostname=example-hostname;tlsSecretRef=example-secret-ref,downloads:...'
在本例中,我们将使用以下自定义组件路由:
-
Console 的
console.my-new-domain.dev
-
download.my-new-domain.dev
for Downloads -
oauth.my-new-domain.dev
for OAuth