Gateway 的基础设施 Labels 和 Annotations
原文:https://gateway-api.sigs.k8s.io/guides/user-guides/infrastructure/
Gateway API 的实现负责为每个 Gateway 创建其运行所需的底层基础设施资源。举例来说:
- 集群内运行的实现,往往会创建 Service 和 Deployment;
- 基于云服务的实现,则可能会去创建云厂商的负载均衡器资源。
在很多场景下,我们希望把自定义的 labels 或 annotations 一并应用到这些由 Gateway 控制器自动创建出来的资源上。
Gateway 上的 infrastructure 字段正是为此而设计的——它允许你为控制器创建的基础设施资源指定 labels 和 annotations。
例如,假设你的 Gateway 基础设施运行在集群内部,那么你可以用下面这份 Gateway 配置同时启用 Linkerd 和 Istio 的 sidecar 注入,从而让所创建的基础设施能自动接入你安装的任意一种服务网格:
yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: meshed-gateway
namespace: incoming
spec:
gatewayClassName: meshed-gateway-class
listeners:
- name: http-listener
protocol: HTTP
port: 80
infrastructure:
labels:
istio-injection: enabled
annotations:
linkerd.io/inject: enabled