All jobs

Expose a GKE App Through the Gateway API

Yes. An agent replaces a GKE app's LoadBalancer Service with a Gateway, an HTTPRoute and a health check policy, validates the manifests and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads how the app reaches the internet today before it adds a Gateway. In a repository like GoogleCloudPlatform/microservices-demo, kubernetes-manifests/frontend.yaml holds the frontend Deployment, whose server container listens on 8080 and answers readiness and liveness probes on /_healthz with a shop_session-id cookie header, a ClusterIP Service frontend on port 80 to targetPort: 8080, and a second Service frontend-external of type: LoadBalancer with the same ports, which is the one the README reads an address from with kubectl get service frontend-external. kustomize/components/non-public-frontend/kustomization.yaml is a Component whose only patch deletes that external Service, istio-manifests/frontend-gateway.yaml is an Istio Gateway and VirtualService for the mesh variant, and the Helm chart's frontend.externalService: true renders the same LoadBalancer. terraform/main.tf creates the cluster with enable_autopilot = true and applies var.filepath_manifest, ../kustomize/ by default, with kubectl apply -k. src/frontend/main.go registers /_healthz as a handler that writes ok and wraps every route in ensureSessionID, which sets the session cookie on any request without one; that is why the probes send a cookie of their own.

GKE's Gateway documentation says the Gateway controller is always enabled on Autopilot clusters, that a Standard cluster turns it on with gcloud container clusters update --gateway-api=standard, and that the managed classes are gke-l7-global-external-managed for a global external Application Load Balancer with an Anycast address, gke-l7-regional-external-managed for a regional one and gke-l7-rilb for an internal one. The agent adds a Component at kustomize/components/gateway-api, following the layout of non-public-frontend: a gateway.yaml with a gateway.networking.k8s.io/v1 Gateway named frontend-gateway on gke-l7-global-external-managed with one HTTP listener on port 80, an httproute.yaml with an HTTPRoute whose parentRefs name that Gateway and whose single rule sends everything to backendRefs frontend port 80, and a healthcheckpolicy.yaml with a networking.gke.io/v1 HealthCheckPolicy targeting the frontend Service with requestPath: /_healthz, because the load balancer's default check would request /, which renders the home page and calls the product catalog, currency and cart services to do it. The component also carries the same $patch: delete for frontend-external so the cluster does not keep paying for a second forwarding rule; a README in the directory says to compose it with non-public-frontend instead if the team prefers.

Because kustomize-build-ci.yaml builds kustomize/ and every directory under kustomize/tests/ on each pull request that touches them, the agent adds kustomize/tests/gateway-api-with-all-components/kustomization.yaml in the shape of the three existing combinations, so the new component is rendered together with cymbal-branding, google-cloud-operations and network-policies on every change. kustomize/README.md gets a row in its variations list, and the root README's address command gains the Gateway form from Google's docs, kubectl get gateway frontend-gateway -o=jsonpath="{.status.addresses[0].value}", next to the Service one.

The sandbox has no Google Cloud project, so the agent proves what can be proved without one and says so. It runs kubectl kustomize on the base, on the new test combination and with non-public-frontend composed in, and checks each rendered document with kubeconform against the Gateway API v1 CRD schemas and the GKE HealthCheckPolicy schema it fetches, in strict mode. It also confirms that the network-policies component still lets the load balancer reach the frontend: network-policy-frontend.yaml in kustomize/components/network-policies selects app: frontend and allows all ingress and egress with empty rules, and the agent reads that policy rather than assuming. The pull request lists the two commands to run after merging on a real cluster, kubectl get gatewayclass to confirm the class exists and kubectl get gateway frontend-gateway until the ADDRESS column fills, and notes that HTTPS on a global Gateway needs a Certificate Manager map referenced with the networking.gke.io/certmap annotation, which it leaves for a follow-up because it needs a domain.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Expose this app's frontend on GKE through the Gateway API instead of a LoadBalancer Service. Read kubernetes-manifests/frontend.yaml, kustomize/kustomization.yaml, every directory under kustomize/components and kustomize/tests, istio-manifests/, terraform/main.tf, the root README and kustomize/README.md, and the frontend's health handler in src/frontend first. Add a Kustomize component with a gateway.networking.k8s.io/v1 Gateway on the gke-l7-global-external-managed class with one HTTP listener, an HTTPRoute to the frontend Service, a networking.gke.io/v1 HealthCheckPolicy pointing at the frontend's health path, and a patch that removes the frontend-external Service, with a README. Add a test combination under kustomize/tests so the kustomize CI builds it. Render every combination with kubectl kustomize and validate the output with kubeconform against the Gateway API and GKE policy schemas. Update the READMEs with the command that reads the Gateway address. Do not claim anything you could not run; list the post-merge checks instead. Open a pull request with the commands and their output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

The pull request adds kustomize/components/gateway-api/ with kustomization.yaml, gateway.yaml, httproute.yaml, healthcheckpolicy.yaml and a README, adds kustomize/tests/gateway-api-with-all-components/, and edits kustomize/README.md and the root README. Its description shows the rendered Gateway, HTTPRoute and HealthCheckPolicy once, the kubeconform summary for each rendered combination, and a short list of what to run after merging on the cluster, in order.

A reviewer checks the class choice against where the users are, whether the route should carry a hostname once a domain exists, and whether removing frontend-external in the same component is what they want or whether composing with non-public-frontend reads better. After merging and applying, the Gateway's address appears in kubectl get gateway, and the health check stops hitting the home page.

Run it on every GKE cluster in the terminal

A developer with kubectl pointed at the cluster sends this body from their own machine with the repository in resources and picks the pull request up from the console when the webhook on their API key reports the run. A platform team with several apps on one cluster sends one request per repository, each with a request_id that is a UUID v5 of the repository's full name, so a script run twice returns the runs already started instead of a second set of pull requests.

Each run reads its own app: one whose health path takes no cookie gets no header in the policy, one that already deletes its external Service gets no second patch, and one with an Istio gateway gets a note on which of the two should own the external address.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

A Gateway on GKE is three resources and one policy, and the mistakes are in the details the manifests do not show: the health path the load balancer will probe, the Service port versus the container port, the network policy that must admit the load balancer, the second forwarding rule that keeps billing if the old Service stays. The agent reads the handler, the probes and the policies in its own sandbox and renders every component combination before it writes a line of the pull request.

It also keeps the proof honest. The rendered documents are validated against the real CRD schemas, the kustomize CI gains a combination that will build the component on every future change, and the steps that need a Google Cloud project are listed as steps rather than reported as done. Several apps on several clusters get the same treatment at once, each with its own rendered output.

Frequently asked questions

Does this need anything enabled on the cluster?

On Autopilot the Gateway controller is always on, which is what terraform/main.tf creates. A Standard cluster needs gcloud container clusters update --gateway-api=standard, which Google's documentation says can take up to 45 minutes, and the cluster must be VPC-native with the HTTP load balancing add-on; the pull request says which case applies.

Why a HealthCheckPolicy?

Without one the load balancer probes /, which on this frontend renders a full page through the product catalog, currency and cart services, so a slow dependency would mark healthy pods unhealthy. The policy points the check at /_healthz, which the handler answers with ok and nothing else.

What about HTTPS?

The listener in the component is HTTP on port 80, like the Service it replaces. A global Gateway serves HTTPS through a Certificate Manager certificate map named in the networking.gke.io/certmap annotation, and a regional one through a Secret in certificateRefs; both need a domain, so the pull request describes the step rather than guessing a name.

Will the Istio variant still work?

Yes. The service-mesh-istio component and istio-manifests/ are untouched, and the new component is opt-in like every other one under kustomize/components. A site that runs the mesh picks one owner for the external address, and the component README says so.

More GKE jobs

More jobs like this: Hand off a long task

Keep reading