NgrokTrafficPolicy Custom Resource
apiVersion: ngrok.k8s.ngrok.com/v1alpha1
kind: NgrokTrafficPolicy
The NgrokTrafficPolicy resource allows you to define your traffic policy configuration in a resource that can by used by reference on other resources such as
Ingress, Gateway, CloudEndpoint, and AgentEndpoint. Ingress and Gateway have no direct method for configuring an ngrok traffic policy, so to use a traffic policy with those
resources, you would create an NgrokTrafficPolicy resource and add the k8s.ngrok.com/traffic-policy annotation on your Ingress/Gateway to add the traffic policy configuration to it.
CloudEndpoint and AgentEndpoint both give you the option to either define the traffic policy configuration inline, or as a reference to an NgrokTrafficPolicy resource, enabling the efficient
reuse of common traffic policies such as enforcing ratelimiting/authentication across all of your endpoints without needing to redefine the traffic policy on each individual resource that needs to use it.
For more information about writing ngrok traffic policies, refer to the traffic policy section
NgrokTrafficPolicy Structure and Types
The following outlines the high level structure and typings of aNgrokTrafficPolicy
NgrokTrafficPolicy Fields
The following sections outline each field of theNgrokTrafficPolicy custom resource, whether they are required, what their default values are (if applicable), and a description of their purpose/constraints.
spec
spec defines the desired state of the NgrokTrafficPolicy
Type: Object
Required: yes
Default: none
Fields:
| Field Name | Type | Required | Default | Description |
|---|---|---|---|---|
spec.policy | json.RawMessage | yes | none | Configuration for the traffic policy rules and actions |
spec.policy
Defines the phases, rules, actions, and expressions of the traffic policy configuration.
Type: json.RawMessage
Required: yes
Default: none
Example NgrokTrafficPolicy
The followingNgrokTrafficPolicy will return a static response when the request query parameter ?debug=true is present.
On its own, this NgrokTrafficPolicy will not do anything, and must be attached to an Ingress/Gateway/CloudEndpoint/AgentEndpoint