Prompt and context
A cluster Gateway accepts external HTTPS and forwards requests to an internal Service that accepts only TLS. Explain how to use Gateway API BackendTLSPolicy to configure upstream TLS, validate certificates and hostnames, and handle invalid policies, cross-namespace references, and rollback.
What the interviewer is testing
- Distinguishing client TLS termination from Gateway-to-backend TLS origination.
- Understanding that the policy attaches to a Service through a target reference and reports status through the implementation.
- Explaining CAs, server names, client certificates, and the risk of skipping verification.
- Accounting for cross-namespace authorization, compatibility, observability, rollback, and gradual migration.
Clarifying questions to ask
- Does TLS terminate at the Gateway and restart, or pass through end to end? Which service name is in the backend certificate SAN?
- Which namespace owns the CA, client certificate, and private key, and is a ReferenceGrant or other authorization required?
- Does the Gateway implementation support the current BackendTLSPolicy version and target Route type?
- How will traffic be observed, isolated, and rolled back during certificate rotation, an invalid policy, or a backend TLS outage?
A 30-second answer
I would separate the two TLS legs: termination from the client to the Gateway, and upstream TLS from the Gateway to the Service. BackendTLSPolicy attaches to the Service and declares validation material plus optional client identity; the implementation must report whether the policy is valid. Before rollout I would verify the CA, server name, port, cross-namespace authorization, and implementation support, never bypassing certificate checks. I would canary one backend, monitor policy status, handshake errors, and expiry, and prepare a reversible rollback.
Step-by-step deep dive
1. Define the TLS boundary
The Gateway API TLS guide places upstream TLS configuration in a BackendTLSPolicy attached to a Service. After client TLS termination, the Gateway acts as a TLS client to the backend; the backend certificate must validate against the configured trust material and its server name must match the certificate identity. The external listener certificate is not the backend validation configuration.
2. Design attachment and validation material
The policy target reference points to a Service. Validation can use CA certificate references or the well-known CA option defined by the specification. If the backend requires mutual TLS, configure a client certificate and key and restrict Secret access. This simplified example is for discussing field relationships; verify the API version and supported fields for the implementation:
apiVersion: gateway.networking.k8s.io/v1alpha3
kind: BackendTLSPolicy
metadata:
name: payments-upstream-tls
spec:
targetRefs:
- group: ""
kind: Service
name: payments
validation:
hostname: payments.internal.example
wellKnownCACertificates: SystemBefore deployment, inspect policy status, referenced objects, and the controller's invalid reason; object creation alone does not prove that the policy is active.
3. Handle namespaces and certificate rotation
Keep the policy and target Service namespace boundary explicit. A cross-namespace reference requires the authorization mechanism supported by the implementation; the Gateway's ability to reach a Service does not grant permission to read its Secret. Rotate certificates with an overlap window or dual-CA strategy, observe handshake success, then retire old material and verify that connections are rebuilt.
4. Observe, canary, and roll back
Canary one Service or port first. Record policy status, TLS handshake failures, backend-name mismatches, expiry, and connection retries. When a policy becomes invalid, the safe behavior is to reject an insecure connection and emit a diagnosable event, not silently downgrade to plaintext. Rollback restores the last validated policy or route target and preserves certificate and audit records.
Model answer
I would define the two connections first: external TLS terminates at the Gateway, which then connects to the Service as a TLS client. BackendTLSPolicy attaches to that Service and declares the CA, server name, and optional client certificate; controller status is the primary signal that the policy is effective. I would limit Secret and cross-namespace access and verify the implementation's API and Route support. A canary Service would test certificate SANs, CA trust, rotation, handshake errors, and connection rebuilds. I would never treat disabled verification as a fix. Invalid policy or certificate failures should block insecure traffic, alert, and follow a rollback plan.
Common mistakes
- Configuring only the client-to-Gateway certificate and forgetting upstream TLS origination.
- Pointing
targetRefat the wrong object or assuming every controller supports the same API version. - Trusting a CA without validating the backend certificate's server name.
- Hiding CA, SAN, or rotation problems with skipped verification or plaintext fallback.
- Allowing cross-namespace Secret reads without an authorization and audit boundary.
- Treating successful resource creation as proof, while ignoring status, handshake metrics, and controller events.
Follow-up questions and responses
How does BackendTLSPolicy relate to client TLS termination?
Client TLS termination protects the browser or caller to Gateway leg; BackendTLSPolicy protects the Gateway to Service leg. They can use different certificates and trust domains, so identity and rotation must be verified separately.
What if the backend certificate name does not match?
Issue the backend certificate for the server name used by the Gateway, or make the policy hostname match the certificate SAN. Do not disable name verification; inspect DNS, SNI, Service naming, and the certificate chain.
How do you release an invalid policy?
Connect invalid status to an alert and release gate, stop expanding the canary, and inspect references, CA material, Secret permissions, and implementation support. Continue only after the status is valid and handshakes pass; emergency rollback returns to the last validated policy.