Proxy Template

With the ProxyTemplate policy you can configure the low-level Envoy resources directly. The policy requires two elements in its configuration:

  • imports: this field lets you import canned ProxyTemplates provided by Kuma.
    • In the current release, the only available canned ProxyTemplate is default-proxy
    • In future releases, more of these will be available and it will also be possible for the user to define them to re-use across their infrastructure
  • resources: the custom resources that will be applied to every Dataplane that matches the selectors.

On Universal:

  1. type: ProxyTemplate
  2. mesh: default
  3. name: template-1
  4. selectors:
  5. - match:
  6. service: backend
  7. conf:
  8. imports:
  9. - default-proxy
  10. resources:
  11. - ..
  12. - ..

On Kubernetes:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: ProxyTemplate
  3. mesh: default
  4. metadata:
  5. namespace: default
  6. name: template-1
  7. spec:
  8. selectors:
  9. - match:
  10. service: backend
  11. conf:
  12. imports:
  13. - default-proxy
  14. resources:
  15. - ..
  16. - ..

Below you can find an example of what a ProxyTemplate configuration could look like:

  1. imports:
  2. - default-proxy
  3. resources:
  4. - name: localhost:9901
  5. version: v1
  6. resource: |
  7. '@type': type.googleapis.com/envoy.api.v2.Cluster
  8. connectTimeout: 5s
  9. name: localhost:9901
  10. loadAssignment:
  11. clusterName: localhost:9901
  12. endpoints:
  13. - lbEndpoints:
  14. - endpoint:
  15. address:
  16. socketAddress:
  17. address: 127.0.0.1
  18. portValue: 9901
  19. type: STATIC
  20. - name: inbound:0.0.0.0:4040
  21. version: v1
  22. resource: |
  23. '@type': type.googleapis.com/envoy.api.v2.Listener
  24. name: inbound:0.0.0.0:4040
  25. address:
  26. socket_address:
  27. address: 0.0.0.0
  28. port_value: 4040
  29. filter_chains:
  30. - filters:
  31. - name: envoy.http_connection_manager
  32. config:
  33. route_config:
  34. virtual_hosts:
  35. - routes:
  36. - match:
  37. prefix: /stats/prometheus
  38. route:
  39. cluster: localhost:9901
  40. domains:
  41. - '*'
  42. name: envoy_admin
  43. codec_type: AUTO
  44. http_filters:
  45. name: envoy.router
  46. stat_prefix: stats