How to modify headers

    After installation, you can see that the following two NSs have been added to the cluster, and the Dubbo and Thrift demo applications are installed in these two NSs. You can choose either of them to test.

    Aeraki supports header mutation. For example, we can use the following MetaRouter to modify the request message header.

    1. kubectl apply -f- <<EOF
    2. apiVersion: metaprotocol.aeraki.io/v1alpha1
    3. kind: MetaRouter
    4. metadata:
    5. name: test-metaprotocol-thrift-route
    6. namespace: meta-thrift
    7. spec:
    8. hosts:
    9. - thrift-sample-server.meta-thrift.svc.cluster.local
    10. routes:
    11. - name: header-mutation
    12. route:
    13. - destination:
    14. host: thrift-sample-server.meta-thrift.svc.cluster.local
    15. requestMutation:
    16. value: bar
    17. value: bar1
    18. EOF

    Use the aerakictl command to view the client-side log, you can see the added header:

    In the configuration delivered to the Sidecar Proxy, Aeraki sets the MetaProtocol Proxy in the FilterChain of the Outbound Listener corresponding to the service, and specifies Aeraki as the RDS server in the MetaProtocol Proxy configuration.

    Aeraki will translate the routing rules configured in MetaRouter into the routing rules of MetaProtocol Proxy, and send them to MetaProtocol Proxy through Aeraki’s built-in RDS server.

    1. aerakictl_sidecar_config client meta-thrift |fx

    The MetaProtocol Proxy configuration in the Outbound Listener of the Thrift service is as follows:

    You can also view the RDS routing information that is currently in effect in the Proxy in the exported file, and you can catch sight of that the corresponding header is added to the routing, as shown below:

    1. {
    2. @type": "type.googleapis.com/aeraki.meta_protocol_proxy.admin.v1alpha.RoutesConfigDump",
    3. dynamic_route_configs": [
    4. {
    5. "version_info": "1641896797",
    6. "route_config": {
    7. "@type": "type.googleapis.com/aeraki.meta_protocol_proxy.config.route.v1alpha.RouteConfiguration",
    8. "name": "thrift-sample-server.meta-thrift.svc.cluster.local_9090",
    9. "routes": [
    10. {
    11. "name": "header-mutation",
    12. "route": {
    13. "cluster": "outbound|9090||thrift-sample-server.meta-thrift.svc.cluster.local"
    14. {
    15. "key": "foo",
    16. "value": "bar"
    17. },
    18. {
    19. "key": "foo1",
    20. "value": "bar1"
    21. }
    22. ]
    23. }
    24. ]
    25. },
    26. "last_updated": "2022-03-10T06:26:24.083Z"
    27. }
    28. ]
    29. },
    30. "last_updated": "2022-01-11T10:26:37.357Z"

    Last modified May 9, 2022: Update header-mutation.md (f7eb909)