$ oc edit apiserver.config.openshift.io cluster
默认的OpenShift Container Platform配置仅允许Web控制台向API服务器发送请求。
如果您需要从使用不同主机名的JavaScript应用程序访问API服务器或OAuth服务器,您可以配置其他主机名以允许访问。
以具有cluster-admin
角色的用户身份访问集群。
编辑APIServer
资源
$ oc edit apiserver.config.openshift.io cluster
在spec
部分下添加additionalCORSAllowedOrigins
字段,并指定一个或多个其他主机名
apiVersion: config.openshift.io/v1
kind: APIServer
metadata:
annotations:
release.openshift.io/create-only: "true"
creationTimestamp: "2019-07-11T17:35:37Z"
generation: 1
name: cluster
resourceVersion: "907"
selfLink: /apis/config.openshift.io/v1/apiservers/cluster
uid: 4b45a8dd-a402-11e9-91ec-0219944e0696
spec:
additionalCORSAllowedOrigins:
- (?i)//my\.subdomain\.domain\.com(:|\z) (1)
1 | 主机名被指定为Golang正则表达式,它与针对API服务器和OAuth服务器的HTTP请求的CORS标头匹配。 |
此示例使用以下语法
|
保存文件以应用更改。