×

You can configure network addresses for your gateway to provide a predictable entry point for external traffic. This ensures that clients can reliably resolve and route requests to your load balancers.

The Gateway API uses addresses to define the specific network locations that are assigned to your Gateway resource. In OKD, you rely on the Gateway controller to automatically provision and bind the necessary network addresses, such as an external load balancer IP, to your gateway. The controller then populates the status.addresses field of the Gateway resource with the assigned addresses once they are available.

To successfully assign network addresses to your gateway, complete the following tasks:

  • Understand gateway address assignment and types to plan your DNS and load balancer configuration.

  • Configure automatic address assignment for a gateway to successfully deploy it without violating manual address constraints.

Understand gateway address assignment and types

OKD automatically handles address assignment by provisioning a LoadBalancer service when you create a Gateway resource. The network address assigned to your gateway corresponds to the IP address or hostname of this underlying load balancer.

Do not define the spec.addresses field. Manually requesting specific network addresses is not currently supported in OKD. If you attempt to request a specific address manually, the gateway enters an error state.

The status.addresses field is populated automatically by the gateway controller. This field lists the actual, active network address assigned to your gateway by the load balancing infrastructure.

Address types

When the controller dynamically assigns an address to your gateway and populates the status.addresses field, it uses one of the following primary types to reflect the underlying load balancer:

Hostname

Represents a DNS-based ingress point. This concept is typically used for cloud load balancers where a DNS name exposes the load balancer.

IPAddress

A textual representation of a numeric IP address (IPv4 or IPv6) assigned by the load balancing infrastructure.

Configure automatic address assignment for a gateway

When you create a gateway resource, you must configure it for automatic address provisioning to successfully deploy the gateway without violating OKD manual address constraints. By intentionally omitting the addresses field, you allow the controller to seamlessly provision and bind the necessary external network addresses to your gateway.

Prerequisites
  • You have access to the cluster as a user with the cluster-admin role.

  • You have installed the OpenShift CLI (oc).

  • You have an existing GatewayClass resource, such as openshift-default.

Procedure
  1. Create a YAML file, such as hello-gateway.yaml, that defines your Gateway object without the addresses field:

    apiVersion: gateway.networking.k8s.io/v1
    kind: Gateway
    metadata:
      name: sample-gateway
      namespace: openshift-ingress
    spec:
      gatewayClassName: openshift-default
      listeners:
      - name: http
        hostname: "*.gwapi.<cluster_domain>"
        port: 80
        protocol: HTTP
        allowedRoutes:
          namespaces:
            from: All
    • Replace <cluster_domain> with your actual cluster ingress domain (for example, example.com).

    • The spec.addresses field is omitted from this configuration to ensure automatic assignment.

    • The gatewayClassName dictates which controller provisions the address and populates the status.addresses field.

  2. Apply the Gateway configuration by running the following command:

    $ oc apply -f hello-gateway.yaml
  3. Verify that the controller automatically assigned an address to your gateway by running the following command:

    $ oc -n openshift-ingress get gateway sample-gateway
    Example output
    NAME             CLASS               ADDRESS           PROGRAMMED   AGE
    sample-gateway   openshift-default   <gateway_address> True         6m16s

    The ADDRESS column in the output displays the dynamically provisioned network address for your gateway.