# envoy-gateway

A Gateway served by Envoy Gateway, with its own Envoy proxies and Service

This page is generated from [`kix/packages/experimental/envoy-gateway`](https://github.com/kix-run/kix/tree/main/kix/packages/experimental/envoy-gateway).

| | |
| --- | --- |
| Stability | Experimental |
| `package` value | `packages.experimental.envoy-gateway` |
| Default aliases | `gateway` |

## How-to guides

- [Install Envoy Gateway](/docs/how-to/package-task-guides/install-envoy-gateway/)

## Dependencies

Kix matches each dependency below to another package instance by instance name, alias, or role. To bind a specific instance, set [`deps.<name>`](/docs/reference/instances-and-composition/#deps) in your cluster definition. See [Declaring dependencies](/docs/reference/package-anatomy/#declaring-dependencies) for how required and optional dependencies work.

| Dependency | Requirement |
| --- | --- |
| `clusterIssuer` | Optional |
| `envoyGateway` | Optional |
| `gatewayApi` | Optional |
| `prometheus` | Optional |

## Options

### `addresses`

Addresses to request on the Gateway (`spec.addresses`), such as a static IP for the proxy `LoadBalancer` Service.

- **Type:** `list of (submodule)`
- **Default:** `[ ]`
- **Example:**

  ```nix
  [
    {
      type = "IPAddress";
      value = "192.0.2.10";
    }
  ]
  ```

### `addresses.*.type`

`IPAddress` (the Gateway API default), `Hostname`, or an implementation-specific type.

- **Type:** `null or string`
- **Default:** `null`

### `addresses.*.value`

Address value, such as an IP address for `IPAddress` or a DNS name for `Hostname`.

- **Type:** `string`

### `clientSources`

Traffic sources that the network policy allows to reach the proxies'
listener ports: `"world"` allows external IP addresses outside the
cluster, and `"all-pods"` allows all pods and cluster nodes. Omit
`"world"` (for example, `[ "all-pods" ]`) on an internal Gateway. Any
`securityPolicy` IP allowlist runs after the network policy.

Clients need `"world"` when they reach the Gateway through a router
that rewrites their source to an address other than a pod or node
IP, as some VPN subnet routers do.

- **Type:** `list of (one of "world", "all-pods")`
- **Default:**

  ```nix
  [
    "world"
    "all-pods"
  ]
  ```
- **Example:**

  ```nix
  [
    "all-pods"
  ]
  ```

### `clientTrafficPolicy`

Envoy Gateway `ClientTrafficPolicy` `spec` fields
(`gateway.envoyproxy.io/v1alpha1`) configuring how the proxies handle
client connections across all listeners. When non-empty, the package
creates a `ClientTrafficPolicy` attached to this `Gateway`. Kix rejects
`targetRef`, `targetRefs`, and `targetSelectors`.

Common settings: `clientIPDetection.xForwardedFor.trustedCIDRs` lists
upstream proxy or CDN IP ranges whose `X-Forwarded-For` header the
Gateway trusts; `tls.minVersion` sets the minimum TLS version (defaults
to `"1.2"`); `tls.alpnProtocols = [ "http/1.1" ]` disables HTTP/2; and
`headers.lateResponseHeaders` adds response headers across all routes on
the Gateway.

- **Type:** `attribute set of anything`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    clientIPDetection.xForwardedFor.trustedCIDRs = [ "192.0.2.0/24" ];
    tls.minVersion = "1.3";
    headers.lateResponseHeaders.set = [
      {
        name = "Strict-Transport-Security";
        value = "max-age=31536000; includeSubDomains";
      }
    ];
  }
  ```

### `httpsRedirect`

Redirect all requests on the Gateway's HTTP listeners to HTTPS with a
301 status code. The package attaches a redirect `HTTPRoute` to each
HTTP listener and sets `allowedRoutes.namespaces.from = "Same"` on
HTTP listeners so routes from other namespaces attach only to HTTPS
listeners. Requires at least one HTTP listener and one active HTTPS
listener.

- **Type:** `boolean`
- **Default:** `false`

### `listenerIssuers`

Map of HTTPS listener name to `ClusterIssuer` name for automatic TLS
certificates. Each value must match a `cluster-issuer` instance wired
to `clusterIssuer`. When only one issuer is wired, HTTPS listeners
omitted here use it automatically.

When a `clusterIssuer` dependency is present, the package creates a
cert-manager `Certificate` for each HTTPS listener without
`tls.certificateRefs` (using the listener's `hostname`) and attaches
the generated `Secret` to the listener.

- **Type:** `attribute set of string`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    example-com = "letsencrypt-example-com";
  }
  ```

### `listeners`

Gateway API v1 `Listener` entries for the Gateway's `spec.listeners`,
with the upstream field names. An HTTPS listener with no
`tls.certificateRefs` is a placeholder and is not rendered.

For listener ports below 1024, Envoy binds to container port
`port + 10000` (for example, port 80 maps to 10080) unless
`proxySpec.provider.kubernetes.useListenerPortAsContainerPort` is
`true`. When network policy is enabled, the package allows incoming
client traffic to those container ports.
kix.expose reads the rendered listeners: `protocol`, `hostname`,
`port`, and `allowedRoutes.namespaces.from` decide whether an
HTTPRoute can attach and which URL scheme and port it gets.

- **Type:** `list of (submodule)`
- **Default:**

  ```nix
  [
    {
      allowedRoutes = {
        namespaces = {
          from = "All";
        };
      };
      name = "http";
      port = 80;
      protocol = "HTTP";
    }
    {
      allowedRoutes = {
        namespaces = {
          from = "All";
        };
      };
      name = "https";
      port = 443;
      protocol = "HTTPS";
      tls = {
        certificateRefs = [ ];
        mode = "Terminate";
      };
    }
  ]
  ```

### `listeners.*.allowedRoutes`

- **Type:** `null or (submodule)`
- **Default:** `null`

### `listeners.*.allowedRoutes.kinds`

- **Type:** `null or (list of attribute set of anything)`
- **Default:** `null`

### `listeners.*.allowedRoutes.namespaces`

- **Type:** `null or (submodule)`
- **Default:** `null`

### `listeners.*.allowedRoutes.namespaces.from`

- **Type:** `null or one of "All", "Same", "Selector"`
- **Default:** `null`

### `listeners.*.allowedRoutes.namespaces.selector`

- **Type:** `null or (attribute set of anything)`
- **Default:** `null`

### `listeners.*.hostname`

- **Type:** `null or string`
- **Default:** `null`

### `listeners.*.name`

- **Type:** `string`

### `listeners.*.port`

- **Type:** `16 bit unsigned integer; between 0 and 65535 (both inclusive)`

### `listeners.*.protocol`

- **Type:** `one of "HTTP", "HTTPS", "TLS", "TCP", "UDP"`

### `listeners.*.tls`

- **Type:** `null or (submodule)`
- **Default:** `null`

### `listeners.*.tls.certificateRefs`

- **Type:** `null or (list of attribute set of anything)`
- **Default:** `null`

### `listeners.*.tls.frontendValidation`

- **Type:** `null or (attribute set of anything)`
- **Default:** `null`

### `listeners.*.tls.mode`

- **Type:** `null or one of "Terminate", "Passthrough"`
- **Default:** `null`

### `listeners.*.tls.options`

- **Type:** `null or (attribute set of string)`
- **Default:** `null`

### `metrics.enabled`

Enable metrics endpoint and monitoring resources (ServiceMonitor, PrometheusRules) when prometheus is available.

- **Type:** `boolean`
- **Default:** `true`

### `metrics.interval`

Scrape interval (e.g. "30s"). Null = use Prometheus default.

- **Type:** `null or string`
- **Default:** `null`

### `proxySpec`

EnvoyProxy `spec` fields (`gateway.envoyproxy.io/v1alpha1`) merged
into this Gateway's `EnvoyProxy` resource.

By default, the package sets `provider.type = "Kubernetes"`, the
Envoy image from `envoy-gateway-controller` (`operandImages.envoy`), the
replica count from the cluster's availability level
(`provider.kubernetes.envoyDeployment.replicas`), pod topology spread
constraints and a `PodDisruptionBudget` when running multiple
replicas, and the proxy Service type (`NodePort` when
`cluster.roles.loadBalancer.binding = "absent"`, or `LoadBalancer`
otherwise).

You can override the replica count, Service type, and other
`EnvoyProxy` fields here. Kix rejects overrides to `provider.type`
(must be `"Kubernetes"`),
`provider.kubernetes.envoyDeployment.container.image` (set
`operandImages.envoy` on `envoy-gateway-controller` instead),
`provider.kubernetes.envoyDeployment.pod.topologySpreadConstraints`,
and `mergeGateways`.

- **Type:** `attribute set of anything`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    provider.kubernetes.envoyService.annotations."service.beta.kubernetes.io/aws-load-balancer-type" = "nlb";
    logging.level.default = "info";
  }
  ```

### `securityPolicy`

Envoy Gateway `SecurityPolicy` `spec` fields
(`gateway.envoyproxy.io/v1alpha1`) applied to every route on this
`Gateway` unless overridden by a route-level policy. When non-empty,
the package creates a `SecurityPolicy` attached to this `Gateway`. Kix
rejects `targetRef`, `targetRefs`, and `targetSelectors`.

Use `authorization` with `principal.clientCIDRs` to restrict access by
client IP range. Envoy Gateway evaluates the connection's source IP, or
the client IP extracted via `clientTrafficPolicy.clientIPDetection`
from a trusted proxy.

- **Type:** `attribute set of anything`
- **Default:** `{ }`
- **Example:**

  ```nix
  {
    authorization = {
      defaultAction = "Deny";
      rules = [
        {
          action = "Allow";
          principal.clientCIDRs = [ "10.0.0.0/8" ];
        }
      ];
    };
  }
  ```