본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

MeshProxyPatches 정책

원문 보기 위키 갱신

MeshProxyPatches 정책 (MeshProxyPatches Policy)

MeshProxyPatch 정책은 Kong Mesh가 생성하는 Envoy xDS 설정을 직접 수정할 수 있게 해주는 정책이에요. 리스너, 클러스터, 네트워크 필터, HTTP 필터, VirtualHost 같은 리소스를 추가하거나 패치하거나 삭제할 수 있고, JSON Patch 표기법이나 raw Envoy 설정 값으로 수정 내용을 표현해요. Sidecar, Built-in Gateway, Delegated Gateway마다 지원되는 targetRef 종류가 다르고, origin 값을 활용하면 인바운드나 아웃바운드처럼 특정 리소스만 골라 수정할 수도 있어요. 새로운 정책 매칭 알고리즘을 사용하기 때문에 폐기된 Proxy Template 정책과는 함께 사용하지 말아야 한다는 점만 기억해 주세요

출처: 문서

본문

이 정책은 새로운 정책 매칭 알고리즘을 사용해요. 지원이 중단된 Proxy Template 정책과는 함께 사용하지 마세요.

targetRef 지원 매트릭스

사이드카

targetRef.kind

허용되는 kind: Mesh, Dataplane, MeshSubset(deprecated)

빌트인 게이트웨이

targetRef.kind

허용되는 kind: Mesh, MeshGateway

위임 게이트웨이

targetRef.kind

허용되는 kind: Mesh, MeshSubset, MeshService, MeshServiceSubset

설정

수정 사항

MeshProxyPatch를 사용하면 appendModification 블록에서 수정 사항을 지정할 수 있어요. 이를 통해 새 리소스를 추가하거나, 기존 리소스를 패치하거나, 기존 리소스를 제거할 수 있어요.

각 xDS 리소스 수정은 3개의 필드로 구성돼요:

  • operation - 생성된 설정에 적용되는 연산이에요 (예: Add, Remove, Patch).
  • match - 일부 연산은 매칭된 리소스에 적용할 수 있어요 (예: 지정된 이름의 리소스만 제거, 모든 outbound 리소스 패치).

그리고 다음 중 하나:

  • jsonPatches - JSON Patch 표기법으로 작성된 수정 목록.
  • value - raw Envoy xDS 설정이에요. 연산이 patch인 경우 일부만 담을 수 있어요.

Origin

Kong Mesh가 생성하는 모든 리소스에는 origin 값이 표시되어 있어서, 특정 리소스를 매칭할 수 있어요.

예시: 새 필터를 추가하되 inbound 리스너에만 추가하기, outbound 클러스터에 타임아웃 설정하기.

잘 알려진 origin:

  • inbound - 들어오는 트래픽을 위해 생성된 리소스.
  • outbound - 나가는 트래픽을 위해 생성된 리소스.
  • transparent - 투명 프록시(transparent proxy) 기능을 위해 생성된 리소스.
  • prometheus - Mesh에서 메트릭이 활성화됐을 때 Prometheus가 스크랩하기 위해 생성된 리소스.
  • direct-access - Direct Access 기능을 위해 생성된 리소스.
  • gateway - MeshGateway를 위해 생성된 리소스.

정책 플러그인이 새로운 리소스를 도입할 수 있기 때문에, 이 목록이 전부는 아니에요. 예를 들어 MeshTrace 플러그인은 mesh-trace origin을 가진 Cluster를 만들 수 있어요.

Cluster

Clusters 리소스에 적용되는 수정 사항이에요.

사용 가능한 연산:

  • Add - 새 Cluster를 추가하거나, 이름이 같은 경우 기존 Cluster를 대체해요.
  • Remove - Cluster를 제거해요.
  • Patch - Cluster 정의의 일부를 패치해요.

사용 가능한 매처:

  • name - Cluster의 이름.
  • origin - Cluster의 origin.
Kubernetes
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
  name: custom-template-1
  namespace: kong-mesh-system
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - cluster:
          operation: Add
          value: |
            name: test-cluster
            connectTimeout: 5s
            type: STATIC
      - cluster:
          operation: Patch
          match: # optional: if absent, all clusters will be patched
            name: test-cluster # optional: if absent, all clusters regardless of name will be patched
            origin: inbound # optional: if absent, all clusters regardless of its origin will be patched
          value: | # you can specify only part of cluster definition that will be merged into existing cluster
            connectTimeout: 5s
      - cluster:
          operation: Patch
          match: # optional: if absent, all clusters will be patched
            name: test-cluster # optional: if absent, all clusters regardless of name will be patched
            origin: inbound # optional: if absent, all clusters regardless of its origin will be patched
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: add
              path: /transportSocket/typedConfig/commonTlsContext/tlsParams # remember to always use camelCase
              value:
                tlsMinimumProtocolVersion: TLSv1_2
            - op: add
              path: /transportSocket/typedConfig/commonTlsContext/tlsParams/tlsMaximumProtocolVersion
              value: TLSv1_2
            - op: replace
              path: /connectTimeout
              value: 77s
      - cluster:
          operation: Remove
          match: # optional: if absent, all clusters will be removed
            name: test-cluster # optional: if absent, all clusters regardless of name will be removed
            origin: inbound # optional: if absent, all clusters regardless of its origin will be removed
Universal
type: MeshProxyPatch
mesh: default
name: custom-template-1
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - cluster:
          operation: Add
          value: |
            name: test-cluster
            connectTimeout: 5s
            type: STATIC
      - cluster:
          operation: Patch
          match: # optional: if absent, all clusters will be patched
            name: test-cluster # optional: if absent, all clusters regardless of name will be patched
            origin: inbound # optional: if absent, all clusters regardless of its origin will be patched
          value: | # you can specify only part of cluster definition that will be merged into existing cluster
            connectTimeout: 5s
      - cluster:
          operation: Patch
          match: # optional: if absent, all clusters will be patched
            name: test-cluster # optional: if absent, all clusters regardless of name will be patched
            origin: inbound # optional: if absent, all clusters regardless of its origin will be patched
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: add
              path: /transportSocket/typedConfig/commonTlsContext/tlsParams
              value:
                tlsMinimumProtocolVersion: TLSv1_2
            - op: add
              path: /transportSocket/typedConfig/commonTlsContext/tlsParams/tlsMaximumProtocolVersion
              value: TLSv1_2
            - op: replace
              path: /connectTimeout
              value: 77s
      - cluster:
          operation: Remove
          match: # optional: if absent, all clusters will be removed
            name: test-cluster # optional: if absent, all clusters regardless of name will be removed
            origin: inbound # optional: if absent, all clusters regardless of its origin will be removed

Listener

Listeners 리소스에 적용되는 수정 사항이에요.

사용 가능한 연산:

  • Add - 새 Listener를 추가하거나, 이름이 같은 경우 기존 Listener를 대체해요.
  • Remove - Listener를 제거해요.
  • Patch - Listener 정의의 일부를 패치해요.

사용 가능한 매처:

  • name - Listener의 이름.
  • origin - Listener의 origin.
  • tags - inbound 또는 outbound Listener의 태그예요. XDS 설정에서 Listener.metadata.filterMetadata[io.kuma.tags]와 매칭돼요.
Kubernetes
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
  name: custom-template-1
  namespace: kong-mesh-system
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - listener:
          operation: Add
          value: |
            name: test-listener
            address:
              socketAddress:
                address: 192.168.0.1
                portValue: 8080
      - listener:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: test-listener # optional: if absent, all listeners regardless of name will be patched
            origin: inbound # optional: if absent, all listeners regardless of its origin will be patched
            tags: # optional: if absent, all listeners are matched
              kuma.io/service: backend
          value: | # you can specify only part of listener definition that will be merged into existing listener
            continueOnListenerFiltersTimeout: true
      - listener:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: test-listener # optional: if absent, all listeners regardless of name will be patched
            origin: inbound # optional: if absent, all listeners regardless of its origin will be patched
            tags: # optional: if absent, all listeners are matched
              kuma.io/service: backend
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: add
              path: /continueOnListenerFiltersTimeout
              value: true
      - listener:
          operation: Remove
          match: # optional: if absent, all listeners will be removed
            name: test-listener # optional: if absent, all listeners regardless of name will be removed
            origin: inbound # optional: if absent, all listeners regardless of its origin will be removed
Universal
type: MeshProxyPatch
mesh: default
name: custom-template-1
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - listener:
          operation: Add
          value: |
            name: test-listener
            address:
              socketAddress:
                address: 192.168.0.1
                portValue: 8080
      - listener:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: test-listener # optional: if absent, all listeners regardless of name will be patched
            origin: inbound # optional: if absent, all listeners regardless of its origin will be patched
            tags: # optional: if absent, all listeners are matched
              kuma.io/service: backend
          value: | # you can specify only part of listener definition that will be merged into existing listener
            continueOnListenerFiltersTimeout: true
      - listener:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: test-listener # optional: if absent, all listeners regardless of name will be patched
            origin: inbound # optional: if absent, all listeners regardless of its origin will be patched
            tags: # optional: if absent, all listeners are matched
              kuma.io/service: backend
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: add
              path: /continueOnListenerFiltersTimeout
              value: true
      - listener:
          operation: Remove
          match: # optional: if absent, all listeners will be removed
            name: test-listener # optional: if absent, all listeners regardless of name will be removed
            origin: inbound # optional: if absent, all listeners regardless of its origin will be removed

Network Filter

Listeners 리소스의 일부인 Network Filters에 적용되는 수정 사항이에요. 수정 사항은 Listener 내의 모든 Filter Chains에 적용돼요.

사용 가능한 연산:

  • AddFirst - Filter Chain의 첫 번째 필터로 새 필터를 추가해요.
  • AddLast - Filter Chain의 마지막 필터로 새 필터를 추가해요.
  • AddAfter - match 섹션으로 매칭되는 Filter Chain 내의 다른 필터 뒤에 새 필터를 추가해요.
  • AddBefore - match 섹션으로 매칭되는 Filter Chain 내의 다른 필터 앞에 새 필터를 추가해요.
  • Patch - Filter Chain에서 매칭된 필터를 패치해요.
  • Remove - Filter Chain에서 필터를 제거해요.

사용 가능한 매처:

  • name - Network Filter의 이름.
  • listenerName - Listener의 이름.
  • listenerTags - inbound 또는 outbound Listener의 태그예요. XDS 설정에서 Listener.metadata.filterMetadata[io.kuma.tags]와 매칭돼요.
  • origin - Listener의 origin.
Kubernetes
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
  name: custom-template-1
  namespace: kong-mesh-system
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - networkFilter:
          operation: AddFirst
          match: # optional: if absent, filter will be added to all listeners
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: AddLast
          match: # optional: if absent, filter will be added to all listeners
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: AddBefore
          match:
            name: envoy.filters.network.tcp_proxy # a new filter (Local RateLimit) will be added before existing (TcpProxy). If there is no TcpProxy filter, Local RateLimit won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: AddAfter
          match:
            name: envoy.filters.network.tcp_proxy # a new filter (Local RateLimit) will be added after existing (TcpProxy). If there is no TcpProxy filter, Local RateLimit won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: Patch
          match:
            name: envoy.filters.network.tcp_proxy 
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          value: | # you can specify only part of filter definition that will be merged into existing filter
            name: envoy.filters.network.tcp_proxy
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
              idleTimeout: 10s
      - networkFilter:
          operation: Patch
          match:
            name: envoy.filters.network.tcp_proxy 
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: replace
              path: /idleTimeout
              value: 10s
      - networkFilter:
          operation: Remove
          match: # optional: if absent, all filters from all listeners will be removed
            name: envoy.filters.network.tcp_proxy # optional: if absent, all filters regardless of name will be removed
            listenerName: inbound:127.0.0.0:80 # optional: if absent, all filters regardless of the listener name will be removed
            listenerTags: # optional: if absent, all filters regardless of the listener tags will be removed
              kuma.io/service: backend
            origin: inbound # optional: if absent, all filters regardless of its origin will be removed
Universal
type: MeshProxyPatch
mesh: default
name: custom-template-1
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - networkFilter:
          operation: AddFirst
          match: # optional: if absent, filter will be added to all listeners
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: AddLast
          match: # optional: if absent, filter will be added to all listeners
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: AddBefore
          match:
            name: envoy.filters.network.tcp_proxy # a new filter (Local RateLimit) will be added before existing (TcpProxy). If there is no TcpProxy filter, Local RateLimit won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: AddAfter
          match:
            name: envoy.filters.network.tcp_proxy # a new filter (Local RateLimit) will be added after existing (TcpProxy). If there is no TcpProxy filter, Local RateLimit won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.network.local_ratelimit
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
              statPrefix: rateLimit
              tokenBucket:
                fillInterval: 1s
      - networkFilter:
          operation: Patch
          match:
            name: envoy.filters.network.tcp_proxy
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          value: | # you can specify only part of filter definition that will be merged into existing filter
            name: envoy.filters.network.tcp_proxy
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy
              idleTimeout: 10s
      - networkFilter:
          operation: Patch
          match:
            name: envoy.filters.network.tcp_proxy
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: replace
              path: /idleTimeout
              value: 10s
      - networkFilter:
          operation: Remove
          match: # optional: if absent, all filters from all listeners will be removed
            name: envoy.filters.network.tcp_proxy # optional: if absent, all filters regardless of name will be removed
            listenerName: inbound:127.0.0.0:80 # optional: if absent, all filters regardless of the listener name will be removed
            listenerTags: # optional: if absent, all filters regardless of the listener tags will be removed
              kuma.io/service: backend
            origin: inbound # optional: if absent, all filters regardless of its origin will be removed

HTTP Filter

Listeners 리소스의 일부인 HTTP Filters에 적용되는 수정 사항이에요. Kong Mesh가 Listener 내의 모든 HTTP Connection Managers에 적용하는 수정 사항이에요.

HTTP Filter 수정 사항은 HTTP로 구성된 서비스에만 적용할 수 있어요.

사용 가능한 작업:

  • AddFirst - HTTP Connection Manager에서 첫 번째 필터로 새 필터를 추가해요.
  • AddLast - HTTP Connection Manager에서 마지막 필터로 새 필터를 추가해요.
  • AddAfter - match 섹션으로 매칭되는 HTTP Connection Manager의 다른 필터 뒤에 새 필터를 추가해요.
  • AddBefore - match 섹션으로 매칭되는 HTTP Connection Manager의 다른 필터 앞에 새 필터를 추가해요.
  • Patch - HTTP Connection Manager에서 매칭된 필터를 패치해요.
  • Remove - HTTP Connection Manager에서 필터를 제거해요.

사용 가능한 매처:

  • name - HTTP Filter의 이름이에요.
  • listenerName - Listener의 이름이에요.
  • listenerTags - 인바운드 또는 아웃바운드 Listener의 태그예요. XDS 구성에서 Listener.metadata.filterMetadata[io.kuma.tags]와 매칭돼요.
  • origin - Listener의 origin이에요.
Kubernetes
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
  name: custom-template-1
  namespace: kong-mesh-system
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - httpFilter:
          operation: AddFirst
          match: # optional: if absent, filter will be added to all HTTP Connection Managers
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: AddLast
          match: # optional: if absent, filter will be added to all HTTP Connection Managers
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: AddBefore
          match:
            name: envoy.filters.http.router # a new filter (Gzip) will be added before existing (Router). If there is no Router filter, Gzip won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: AddAfter
          match:
            name: envoy.filters.http.router # a new filter (Gzip) will be added after existing (Router). If there is no Router filter, Gzip won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: Patch
          match:
            name: envoy.filters.http.router 
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          value: | # you can specify only part of filter definition that will be merged into existing filter
            name: envoy.filters.http.router 
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
              dynamicStats: false
      - httpFilter:
          operation: Patch
          match:
            name: envoy.filters.http.router 
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: replace
              path: /dynamicStats
              value: false
      - httpFilter:
          operation: Remove
          match: # optional: if absent, all filters from all listeners will be removed
            name: envoy.filters.http.gzip # optional: if absent, all filters regardless of name will be removed
            listenerName: inbound:127.0.0.0:80 # optional: if absent, all filters regardless of the listener name will be removed
            listenerTags: # optional: if absent, all filters regardless of the listener tags will be removed
              kuma.io/service: backend
            origin: inbound # optional: if absent, all filters regardless of its origin will be removed
Universal
type: MeshProxyPatch
mesh: default
name: custom-template-1
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - httpFilter:
          operation: AddFirst
          match: # optional: if absent, filter will be added to all HTTP Connection Managers
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: AddLast
          match: # optional: if absent, filter will be added to all HTTP Connection Managers
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: AddBefore
          match:
            name: envoy.filters.http.router # a new filter (Gzip) will be added before existing (Router). If there is no Router filter, Gzip won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: AddAfter
          match:
            name: envoy.filters.http.router # a new filter (Gzip) will be added after existing (Router). If there is no Router filter, Gzip won't be added.
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be added to all listeners regardless of name
            listenerTags: # optional: if absent, filter will be added to all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be added to all listeners regardless of its origin
          value: |
            name: envoy.filters.http.gzip
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.gzip.v3.Gzip
              memoryLevel: 9
      - httpFilter:
          operation: Patch
          match:
            name: envoy.filters.http.router
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          value: | # you can specify only part of filter definition that will be merged into existing filter
            name: envoy.filters.http.router 
            typedConfig:
              '@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
              dynamicStats: false
      - httpFilter:
          operation: Patch
          match:
            name: envoy.filters.http.router
            listenerName: inbound:127.0.0.0:80 # optional: if absent, filter will be patched within all listeners regardless of name
            listenerTags: # optional: if absent, filter will be patched within all listeners regardless of listener tags
              kuma.io/service: backend
            origin: inbound # optional: if absent, filter will be patched within all listeners regardless of its origin
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: replace
              path: /dynamicStats
              value: false
      - httpFilter:
          operation: Remove
          match: # optional: if absent, all filters from all listeners will be removed
            name: envoy.filters.http.gzip # optional: if absent, all filters regardless of name will be removed
            listenerName: inbound:127.0.0.0:80 # optional: if absent, all filters regardless of the listener name will be removed
            listenerTags: # optional: if absent, all filters regardless of the listener tags will be removed
              kuma.io/service: backend
            origin: inbound # optional: if absent, all filters regardless of its origin will be removed

VirtualHost

VirtualHost 리소스에 적용되는 수정 사항이에요.

VirtualHost 수정 사항은 HTTP로 구성된 서비스에만 적용할 수 있어요.

사용 가능한 연산:

  • Add - 새로운 VirtualHost를 추가해요.
  • Remove - VirtualHost를 제거해요.
  • Patch - VirtualHost 정의의 일부를 패치해요.

사용 가능한 매처:

  • name - VirtualHost의 이름이에요.
  • origin - VirtualHost의 origin이에요.
  • routeConfigurationName - RouteConfiguration의 이름이에요.
Kubernetes
apiVersion: kuma.io/v1alpha1
kind: MeshProxyPatch
metadata:
  name: custom-template-1
  namespace: kong-mesh-system
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - virtualHost:
          operation: Add
          value: |
            name: backend
            domains:
            - "*"
            routes:
            - match:
                prefix: /
              route:
                cluster: backend
      - virtualHost:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: backend # optional: if absent, all virtual hosts regardless of name will be patched
            origin: inbound # optional: if absent, all virtual hosts regardless of its origin will be patched
            routeConfigurationName: outbound:backend # optional: if absent, all virtual hosts in all route configurations will be patched
          value: | # you can specify only part of virtual host definition that will be merged into existing virtual host
            retryPolicy:
              retryOn: 5xx
              numRetries: 3
      - virtualHost:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: backend # optional: if absent, all virtual hosts regardless of name will be patched
            origin: inbound # optional: if absent, all virtual hosts regardless of its origin will be patched
            routeConfigurationName: outbound:backend # optional: if absent, all virtual hosts in all route configurations will be patched
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: add
              path: /retryPolicy
              value:
                retryOn: 5xx
                numRetries: 3
      - virtualHost:
          operation: Remove
          match: # optional: if absent, all virtual hosts will be removed
            name: test-listener # optional: if absent, all virtual hsots regardless of name will be removed
            origin: inbound # optional: if absent, all virtual hosts regardless of its origin will be removed
Universal
type: MeshProxyPatch
mesh: default
name: custom-template-1
spec:
  targetRef:
    kind: MeshSubset
    tags:
      app: backend
  default:
    appendModifications:
      - virtualHost:
          operation: Add
          value: |
            name: backend
            domains:
            - "*"
            routes:
            - match:
                prefix: /
              route:
                cluster: backend
      - virtualHost:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: backend # optional: if absent, all virtual hosts regardless of name will be patched
            origin: inbound # optional: if absent, all virtual hosts regardless of its origin will be patched
            routeConfigurationName: outbound:backend # optional: if absent, all virtual hosts in all route configurations will be patched
          value: | # you can specify only part of virtual host definition that will be merged into existing virtual host
            retryPolicy:
              retryOn: 5xx
              numRetries: 3
      - virtualHost:
          operation: Patch
          match: # optional: if absent, all listeners will be patched
            name: backend # optional: if absent, all virtual hosts regardless of name will be patched
            origin: inbound # optional: if absent, all virtual hosts regardless of its origin will be patched
            routeConfigurationName: outbound:backend # optional: if absent, all virtual hosts in all route configurations will be patched
          jsonPatches: # optional and mutually exclusive with "value": list of modifications in JSON Patch notation
            - op: add
              path: /retryPolicy
              value:
                retryOn: 5xx
                numRetries: 3
      - virtualHost:
          operation: Remove
          match: # optional: if absent, all virtual hosts will be removed
            name: test-listener # optional: if absent, all virtual hsots regardless of name will be removed
            origin: inbound # optional: if absent, all virtual hosts regardless of its origin will be removed

병합

appendModification 목록의 모든 수정 사항은 항상 병합돼요. 예를 들어, targetRef.kind: Mesh를 가진 정책과 데이터 플레인 프록시에 매칭되는 targetRef.kind: MeshService를 가진 두 번째 정책이 있다면, 두 정책의 모든 수정 사항이 적용돼요.

JSON Patch

JSON Patch를 사용할 때는 Envoy Config Dump에서 _snake_case_로 보이더라도 path 파라미터에는 항상 snake_case 대신 camelCase를 사용해야 한다는 점을 기억하세요.

더 알아보기 (Learn more)

  • 수정 대상이 되는 Envoy 리스너 설정 구조를 확인할 수 있는 API 문서예요 — Listeners
  • 타임아웃 설정처럼 클러스터 리소스를 패치할 때 참고할 수 있는 Envoy 클러스터 API 문서예요 — Clusters
  • 인바운드 리스너에 새 필터를 추가하는 수정 작업에서 참고할 수 있는 Envoy HTTP 필터 문서예요 — HTTP Filters
  • 라우팅 관점에서 VirtualHost 리소스를 패치할 때 참고할 수 있는 Envoy 문서예요 — VirtualHost
  • jsonPatches 필드에서 수정 내용을 표현할 때 사용하는 JSON Patch 표기법 안내예요 — JSON Patch notation