Running built-in gateway pods on Kubernetes

MeshGatewayInstance is a Kubernetes-only resource for deploying Kuma’s builtin gateway.

MeshGateway and MeshHTTPRoute/MeshTCPRoute allow specifying builtin gateway listener and route configuration but don’t handle deploying kuma-dp instances that listen and serve traffic.

Kuma offers MeshGatewayInstance to manage a Kubernetes Deployment and Service that together provide service capacity for the MeshGateway.

Heads up! In previous versions of Kuma, setting the kuma.io/service tag directly within a MeshGatewayInstance resource was used to identify the service. However, this practice is deprecated and no longer recommended for security reasons since Kuma version 2.7.0.

We’ve automatically switched to generating the service name for you based on your MeshGatewayInstance resource name and namespace (format: {name}_{namespace}_svc).

If you’re not using the default Mesh, you’ll need to label the MeshGatewayInstance using kuma.io/mesh.

Consider the following example:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshGatewayInstance
  3. metadata:
  4. name: edge-gateway
  5. namespace: default
  6. labels:
  7. kuma.io/mesh: default # only necessary if not using default Mesh
  8. spec:
  9. replicas: 2
  10. serviceType: LoadBalancer

Once a MeshGateway exists with kuma.io/service: edge-gateway_default_svc, the control plane creates a new Deployment in the default namespace. This Deployment deploys 2 replicas of kuma-dp and corresponding builtin gateway Dataplane running with kuma.io/service: edge-gateway_default_svc.

The control plane also creates a new Service to send network traffic to the builtin Dataplane pods. The Service is of type LoadBalancer, and its ports are automatically adjusted to match the listeners on the corresponding MeshGateway.

Customization

Additional customization of the generated Service or Pods is possible via spec.serviceTemplate and spec.podTemplate.

For example, you can add annotations and/or labels to the generated objects:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshGatewayInstance
  3. metadata:
  4. name: edge-gateway
  5. namespace: default
  6. spec:
  7. replicas: 1
  8. serviceType: LoadBalancer
  9. serviceTemplate:
  10. metadata:
  11. annotations:
  12. service.beta.kubernetes.io/aws-load-balancer-internal: "true"
  13. podTemplate:
  14. metadata:
  15. labels:
  16. app-name: my-app

You can also modify several resource limits or security-related parameters for the generated Pods or specify a loadBalancerIP for the Service:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshGatewayInstance
  3. metadata:
  4. name: edge-gateway
  5. namespace: default
  6. spec:
  7. replicas: 1
  8. serviceType: LoadBalancer
  9. resources:
  10. requests:
  11. memory: 64Mi
  12. cpu: 250m
  13. limits:
  14. memory: 128Mi
  15. cpu: 500m
  16. serviceTemplate:
  17. metadata:
  18. labels:
  19. svc-id: "19-001"
  20. spec:
  21. loadBalancerIP: 172.17.0.1
  22. podTemplate:
  23. metadata:
  24. annotations:
  25. app-monitor: "false"
  26. spec:
  27. serviceAccountName: my-sa
  28. securityContext:
  29. fsGroup: 2000
  30. container:
  31. securityContext:
  32. readOnlyRootFilesystem: true

Schema