Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

3.3.3.4. 注解

每个路由都可以附加注解。每个注释仅是一个名称和一个值。

apiVersion: v1
kind: Route
metadata:
  annotations:
    haproxy.router.openshift.io/timeout: 5500ms
[...]

名称可以是与现有 Annotations 没有冲突的任何内容。值是任意字符串。字符串可以具有多个令牌,用空格分开。例如,aa bb cc.该模板使用 {{index}} 来提取注释的值。例如:

{{$balanceAlgo := index $cfg.Annotations "haproxy.router.openshift.io/balance"}}

这是如何将其用于相互客户端授权的示例。

{{ with $cnList := index $cfg.Annotations "whiteListCertCommonName" }}
  {{   if ne $cnList "" }}
    acl test ssl_c_s_dn(CN) -m str {{ $cnList }}
    http-request deny if !test
  {{   end }}
{{ end }}

然后,您可以使用此命令处理列入白名单的 CN。

$ oc annotate route <route-name> --overwrite whiteListCertCommonName="CN1 CN2 CN3"

如需更多信息,请参阅特定于路由的注解