TIS1503 - Listener Must Have a Unique Combination of Hostname, Port, and Protocol
Each listener in a Kubernetes Gateway must have a unique combination of Hostname, Port, and Protocol.
Hostname, Port, and ProtocolTo prevent conflicts and ensure predictable behavior, update the hostname, port, or protocol so that each listener in the Gateway has a unique combination of these attributes.
Examples
-
Two Listeners with the Same Hostname, Port, and Protocol
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
name: my-gateway
namespace: example-namespace
spec:
listeners:
- name: http-1
port: 80
protocol: HTTP
hostname: "example.com"
- name: http-2
port: 80
protocol: HTTP
hostname: "example.com"Explanation: The
Gatewaydefines two listeners that have the sameHostname(example.com),Port(80), andProtocol(HTTP). This configuration is invalid because each listener must have a unique combination ofHostname,Port, andProtocolto avoid conflicts and ensure predictable behavior.
Recommendation
Update the hostname, port, or protocol to ensure there is only one listener for the reported combination.
-
Update One of the Listeners to Use a Different Port
If the intent is to have separate listeners, modify one of the listeners to use a different port.
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
name: my-gateway
namespace: example-namespace
spec:
listeners:
- name: http-1
port: 80
protocol: HTTP
hostname: "example.com"
- name: http-2
port: 8080
protocol: HTTP
hostname: "example.com"Explanation: Changing the port of one of the listeners to
8080ensures that each listener has a unique combination, preventing conflicts and making the configuration valid. -
Update the Hostname for One of the Listeners
Alternatively, update the hostname of one of the listeners to ensure uniqueness.
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: Gateway
metadata:
name: my-gateway
namespace: example-namespace
spec:
listeners:
- name: http-1
port: 80
protocol: HTTP
hostname: "example.com"
- name: http-2
port: 80
protocol: HTTP
hostname: "another-example.com"Explanation: By changing the hostname of one of the listeners, the combination becomes unique, which resolves the conflict.