# traefik

Traefik proxy as a Gateway API implementation (GatewayClass, Gateway, and data plane)

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

| | |
| --- | --- |
| Stability | Experimental |
| `package` value | `packages.experimental.traefik` |
| Default software version | `3.7.19` |
| Default aliases | `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 |
| --- | --- |
| `gatewayApi` | Optional |
| `prometheus` | Optional |

## Options

### `env`

Extra environment variables for Traefik. A value is a string, a
`fieldRef` source, or a `secretKeyRef` source naming a Secret managed
outside Kix with `kix.untrackedRef`. `TRAEFIK_*` variables are
refused: Traefik reads its configuration from them only when it has
no flags, and the package always passes flags. Use `extraArgs`.

- **Type:** ``attribute set of (null or string or env var source with `valueFrom`)``
- **Default:** `{ }`

### `extraArgs`

Flags appended to Traefik's arguments. Flags the package sets or
derives from are refused: each listener entrypoint's address and
`--entryPoints.traefik.address`, `--ping`, `--metrics.prometheus`,
`--providers.kubernetesGateway` and its label selector, status
Service, and experimental channel, `--configFile`, and every flag of
the other Kubernetes providers. Traefik reads flag names in any case.

- **Type:** `list of string`
- **Default:** `[ ]`
- **Example:**

  ```nix
  [
    "--log.level=INFO"
  ]
  ```

### `image`

Image of Traefik.

- **Type:** `submodule`
- **Default:**

  ```nix
  {
    digest = "sha256:a6c0194dda77bcb804824580f36fa7edc56e315b1acfe933366c8b52844a78a4";
    pullPolicy = "IfNotPresent";
    repository = "docker.io/library/traefik";
    tag = "v3.7.19";
  }
  ```

### `image.digest`

Resolved manifest digest, `sha256:` followed by 64 hex characters. What will actually run. Null means not resolved.

- **Type:** `null or string`
- **Default:** the package's digest while `tag` is the package's tag, otherwise null

### `image.note`

Whatever a person wanted to say about this pin. Kix never reads it and a promotion never discards it. Declared here for the same reason as the three fields above: a pin carries its own record-keeping, and the option accepts the whole pin rather than a subset of it.

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

### `image.promotedBy`

Who resolved this pin, for the record. Null when unknown.

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

### `image.pullPolicy`

imagePullPolicy for containers using this image. Null leaves it to Kubernetes.

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

### `image.repository`

Image repository, registry host included.

- **Type:** `string`
- **Default:** `"docker.io/library/traefik"`

### `image.resolvedAt`

When this pin was resolved, RFC 3339. Null when unknown.

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

### `image.sourceRev`

Revision of the source the image was built from, when Kix built it. Null for upstream images.

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

### `image.tag`

Image tag. What was asked for.

- **Type:** `string`
- **Default:** `"v3.7.19"`

### `listeners`

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

Each distinct port becomes a Traefik entrypoint and a Service port,
so a listener port needs no other setting. Port 8080 is
Traefik's internal entrypoint and is refused.

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.backendErrorMinRate`

Requests per second a backend must receive before TraefikBackendErrorsHigh considers its error ratio, so a few failures on a rarely used route do not fire it.

- **Type:** `nonnegative integer or floating point number, meaning >=0`
- **Default:** `0.1`
- **Example:** `1`

### `metrics.backendErrorRatio`

Share of a backend's requests that may end in 502, 503, or 504 before TraefikBackendErrorsHigh fires.

- **Type:** `integer or floating point number between 0 and 1 (both inclusive)`
- **Default:** `0.05`
- **Example:** `0.01`

### `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`

### `metrics.minCertificateValidity`

How long a certificate Traefik serves must still be valid before TraefikCertificateExpiringSoon fires, as a Prometheus duration. cert-manager and Traefik's ACME resolver renew a 90-day certificate 30 days before it expires, so 7 days left means renewal has failed for weeks. Lower it for certificates that live only a few days.

- **Type:** `string matching the pattern ([0-9]+(ms|s|m|h|d|w|y))+`
- **Default:** `"7d"`
- **Example:** `"21d"`

### `replicas`

Traefik replicas. Every replica serves traffic and writes Gateway status.

- **Type:** `positive integer, meaning >0`
- **Default:** 1, 2, 2, or 3 for the cluster's availability level `none`, `pod`, `node`, or `zone`

### `resources`

Resource requests and limits for the Traefik container. There is no
default limit: memory grows with the number of routes and open
connections. Each field keeps its default until set, and null
removes a default.

- **Type:** `submodule`
- **Default:**

  ```nix
  {
    requests = {
      cpu = "100m";
      memory = "64Mi";
    };
  }
  ```

### `resources.claims`

Dynamic resource claims the container uses. Null leaves it unset.

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

### `resources.claims.*.name`

Name of an entry in the pod's `resourceClaims`.

- **Type:** `string`

### `resources.claims.*.request`

Request within the claim to use. Null uses the whole claim.

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

### `resources.limits`

Resource quantities by name.

- **Type:** `open submodule of attribute set of Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `{ }`

### `resources.limits.cpu`

The cpu quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `null`

### `resources.limits.ephemeral-storage`

The ephemeral-storage quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `null`

### `resources.limits.memory`

The memory quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `null`

### `resources.requests`

Resource quantities by name.

- **Type:** `open submodule of attribute set of Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `{ }`

### `resources.requests.cpu`

The cpu quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `"100m"`

### `resources.requests.ephemeral-storage`

The ephemeral-storage quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `null`

### `resources.requests.memory`

The memory quantity. Null leaves it unset.

- **Type:** `null or Kubernetes quantity, such as "500m" or "1Gi" (a non-negative decimal or integer with an optional suffix m, k, M, G, T, P, E, Ki, Mi, Gi, Ti, Pi or Ei)`
- **Default:** `"64Mi"`

### `service.annotations`

Annotations on the Traefik Service, such as a cloud provider's load balancer settings.

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

### `service.spec`

Fields of the Traefik Service's `spec`, with Kubernetes field names
(`loadBalancerClass`, `loadBalancerSourceRanges`,
`ipFamilyPolicy`, ...). The package sets `selector` and `ports`
from the listeners.

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

### `service.spec.externalTrafficPolicy`

`Local` keeps client source addresses on NodePort and LoadBalancer Services. Null leaves the Kubernetes default, `Cluster`.

- **Type:** `null or one of "Cluster", "Local"`
- **Default:** `null`

### `service.spec.type`

Service type. LoadBalancer needs a load balancer provider in the cluster.

- **Type:** `one of "ClusterIP", "NodePort", "LoadBalancer"`
- **Default:** "NodePort" when `cluster.roles.loadBalancer.binding` is "absent", "LoadBalancer" otherwise