Change proxy config

Customize your gateway proxy with the GatewayParameters resource.

Before you begin

  1. Follow the Get started guide to install kgateway.

  2. Follow the Sample app guide to create a gateway proxy with an HTTP listener and deploy the httpbin sample app.

  3. Get the external address of the gateway and save it in an environment variable.

    export INGRESS_GW_ADDRESS=$(kubectl get svc -n kgateway-system http -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}")
    echo $INGRESS_GW_ADDRESS  
    kubectl port-forward deployment/http -n kgateway-system 8080:8080

Customize the gateway proxy

Choose between the following options to customize your gateway proxy:

ℹ️
To change the default proxy template and inject your own Envoy configuration, use a self-managed gateway instead.

Built-in customization

You can use the built-in customization fields in the GatewayParameters resource to change settings on the proxy. This way, your configuration is validated when you apply the GatewayParameters resource in your cluster.

  1. Create a GatewayParameters resource with your custom configuration. The following example changes the proxy Service type from LoadBalancer to NodePort. For other examples, see the Gateway customization guides.

    kubectl apply -f- <<EOF
    apiVersion: gateway.kgateway.dev/v1alpha1
    kind: GatewayParameters
    metadata:
      name: gw-params
      namespace: kgateway-system
    spec:
      kube:
        service:
          type: NodePort
    EOF
  2. Create a Gateway resource that references your custom GatewayParameters.

    kubectl apply -f- <<EOF
    kind: Gateway
    apiVersion: gateway.networking.k8s.io/v1
    metadata:
      name: custom
      namespace: kgateway-system
    spec:
      gatewayClassName: kgateway
      infrastructure:
        parametersRef:
          name: gw-params
          group: gateway.kgateway.dev
          kind: GatewayParameters
      listeners:
      - protocol: HTTP
        port: 80
        name: http
        allowedRoutes:
          namespaces:
            from: All
    EOF
  3. Verify that the proxy Service is of type NodePort.

    kubectl get svc custom -n kgateway-system

    Example output:

    NAME     TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
    custom   NodePort   10.96.123.456   <none>        80:30xxx/TCP   30s

Overlays

You can define Kubernetes overlays in the GatewayParameters resource to override default settings for the Deployment, Service, and ServiceAccount that are created for a gateway proxy. Overlays use Kubernetes strategic merge patch semantics.

  1. Create a GatewayParameters resource with your custom overlay. The following example changes the default replica count from 1 to 3. For other examples, see Overlay examples.

    kubectl apply -f- <<EOF
    apiVersion: gateway.kgateway.dev/v1alpha1
    kind: GatewayParameters
    metadata:
      name: gw-params
      namespace: kgateway-system
    spec:
      kube:
        deploymentOverlay:
          spec:
            replicas: 3
    EOF
  2. Create a Gateway resource that references your custom GatewayParameters.

    kubectl apply -f- <<EOF
    kind: Gateway
    apiVersion: gateway.networking.k8s.io/v1
    metadata:
      name: custom
      namespace: kgateway-system
    spec:
      gatewayClassName: kgateway
      infrastructure:
        parametersRef:
          name: gw-params
          group: gateway.kgateway.dev
          kind: GatewayParameters
      listeners:
      - protocol: HTTP
        port: 80
        name: http
        allowedRoutes:
          namespaces:
            from: All
    EOF
  3. Check the number of gateway proxy pods that are created. Verify that you see 3 replicas.

    kubectl get pods -l app.kubernetes.io/name=custom -n kgateway-system

    Example output:

    NAME                      READY   STATUS    RESTARTS   AGE
    custom-54975d9598-qrh8v   1/1     Running   0          7s
    custom-54975d9598-tb6qx   1/1     Running   0          7s
    custom-54975d9598-w4cx2   1/1     Running   0          7s

Next

Explore common overlay configurations such as deployment replicas, pod scheduling, security contexts, and cloud provider load balancer annotations.

Cleanup

You can remove the resources that you created in this guide.
kubectl delete gateway custom -n kgateway-system
kubectl delete GatewayParameters gw-params -n kgateway-system