Cloud Native 6 min read

Inject Custom Headers into Aeraki Mesh Using MetaRouter CRD

This tutorial walks through installing Aeraki Mesh and sample Dubbo/Thrift services, creating a MetaRouter resource to add custom request headers, verifying the changes via sidecar logs, and explains how Aeraki translates MetaRouter rules into MetaProtocol Proxy configurations delivered through its internal RDS server.

Cloud Native Technology Community
Cloud Native Technology Community
Cloud Native Technology Community
Inject Custom Headers into Aeraki Mesh Using MetaRouter CRD

Installation of Example Programs

Install Aeraki, Istio, and the sample applications. After installation two namespaces, meta-dubbo and meta-thrift, appear, each containing a sample service for Dubbo or Thrift.

kubectl get ns | grep meta
meta-dubbo        Active   16m
meta-thrift       Active   16m

Modifying Request Message Header

Aeraki supports header mutation via a MetaRouter custom resource. The following manifest adds two headers ( foo: bar and foo1: bar1) to outgoing Thrift requests.

apiVersion: metaprotocol.aeraki.io/v1alpha1
kind: MetaRouter
metadata:
  name: test-metaprotocol-thrift-route
  namespace: meta-thrift
spec:
  hosts:
    - thrift-sample-server.meta-thrift.svc.cluster.local
  routes:
    - name: header-mutation
      route:
        - destination:
            host: thrift-sample-server.meta-thrift.svc.cluster.local
      requestMutation:
        - key: foo
          value: bar
        - key: foo1
          value: bar1

Apply the manifest: kubectl apply -f - Sidecar logs show the injected headers:

2022-03-10T06:42:25.605305Z	info	envoy filter	thrift: codec mutation foo : bar
2022-03-10T06:42:25.605316Z	info	envoy filter	thrift: codec mutation foo1 : bar1

Underlying Mechanism

Aeraki configures an outbound listener for the Thrift service and inserts the envoy.filters.network.meta_protocol_proxy filter. The filter points to Aeraki’s internal RDS server, which receives the translated routing rules from the MetaRouter resource.

Outbound listener configuration (JSON):

{
  "name": "envoy.filters.network.meta_protocol_proxy",
  "typed_config": {
    "@type": "type.googleapis.com/udpa.type.v1.TypedStruct",
    "type_url": "type.googleapis.com/aeraki.meta_protocol_proxy.v1alpha.MetaProtocolProxy",
    "value": {
      "stat_prefix": "outbound|9090||thrift-sample-server.meta-thrift.svc.cluster.local",
      "application_protocol": "thrift",
      "rds": {
        "config_source": {
          "api_config_source": {
            "api_type": "GRPC",
            "grpc_services": [
              {
                "envoy_grpc": {
                  "cluster_name": "aeraki-xds"
                }
              }
            ],
            "transport_api_version": "V3"
          },
          "resource_api_version": "V3"
        },
        "route_config_name": "thrift-sample-server.meta-thrift.svc.cluster.local_9090"
      },
      "codec": {
        "name": "aeraki.meta_protocol.codec.thrift"
      },
      "meta_protocol_filters": [
        {
          "name": "aeraki.meta_protocol.filters.router"
        }
      ]
    }
  }
}

The RDS dump confirms that the route named “header‑mutation” contains the request_mutation entries for the two headers:

{
  "@type": "type.googleapis.com/aeraki.meta_protocol_proxy.admin.v1alpha.RoutesConfigDump",
  "dynamic_route_configs": [
    {
      "version_info": "1641896797",
      "route_config": {
        "@type": "type.googleapis.com/aeraki.meta_protocol_proxy.config.route.v1alpha.RouteConfiguration",
        "name": "thrift-sample-server.meta-thrift.svc.cluster.local_9090",
        "routes": [
          {
            "name": "header-mutation",
            "route": {
              "cluster": "outbound|9090||thrift-sample-server.meta-thrift.svc.cluster.local"
            },
            "request_mutation": [
              { "key": "foo", "value": "bar" },
              { "key": "foo1", "value": "bar1" }
            ]
          }
        ]
      },
      "last_updated": "2022-03-10T06:26:24.083Z"
    }
  ],
  "last_updated": "2022-01-11T10:26:37.357Z"
}

To view the sidecar proxy configuration, run:

aerakictl_sidecar_config client meta-thrift | fx
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

KubernetesIstioService MeshAerakiMetaRouterHeader Mutation
Cloud Native Technology Community
Written by

Cloud Native Technology Community

The Cloud Native Technology Community, part of the CNBPA Cloud Native Technology Practice Alliance, focuses on evangelizing cutting‑edge cloud‑native technologies and practical implementations. It shares in‑depth content, case studies, and event/meetup information on containers, Kubernetes, DevOps, Service Mesh, and other cloud‑native tech, along with updates from the CNBPA alliance.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.