---
title: "A Quick Glance at the Kubernetes Gateway API - API7.ai"
description: "In one of my recent blog posts, I described several ways to ..."
url: "https://api7.ai/blog/a-quick-glance-at-the-kubernetes-gateway-api"
---

[Blog](https://api7.ai/blog)

[Products](https://api7.ai/category/products)[Technology](https://api7.ai/category/technology)[Ecosystem](https://api7.ai/category/ecosystem)[Case Study](https://api7.ai/category/usercase)[Team & Community](https://api7.ai/category/community)

Search

⌘ + K

[Blog](https://api7.ai/blog)

Ecosystem

# A Quick Glance at the Kubernetes Gateway API

[![Nicolas Fränkel](https://avatars.githubusercontent.com/u/752258?v=4)](https://github.com/nfrankel)

[Nicolas Fränkel](https://github.com/nfrankel)

September 7, 2022

[Ecosystem](https://api7.ai/category/ecosystem)

In [one of my recent blog posts](https://blog.frankel.ch/basics-access-kubernetes-pods/), I described several ways to access Kubernetes pods. One can access a pod through its IP, but pods are naturally transient. The nominal way is to configure a `Service`: its IP is stable, and Kubernetes' job is to keep the mapping between a `Service` and its underlying pods up-to-date. Different kinds of services are available: internal only, `NodePort` to finally allow access from outside the cluster, and `LoadBalancer` that relies on a third-party component - in general, a cloud provider one. Finally, I mentioned the `Ingress` object, which also allows routing.

I deliberately left out the new kid on the block, the Gateway API. It's the subject of this post.

## From Ingress to the Gateway API

External access to Kubernetes pods went through several evolutionary steps, *e.g.*, `Ingress` is the answer to the problem of the lack of routing in `LoadBalancer`. The biggest issue of `Ingress` is its dependency on "proprietary" objects. As a reminder, here's the snippet to create routing using Apache APISIX:

```
apiVersion: apisix.apache.org/v2beta3 #1
kind: ApisixRoute #1
metadata:
  name: apisix-route
spec:
  http:
    - name: left
      match:
        paths:
          - "/left"
      backends:
        - serviceName: left
          servicePort: 80
    - name: right
      match:
        paths:
          - "/right"
      backends:
        - serviceName: right
          servicePort: 80
```

1. Proprietary objects

Proprietary objects are a problem when migrating. While migration from one provider to another is probably uncommon, it should be as seamless as possible. When using proprietary objects, you first need to map from the old object to the new ones. Chances are that it's not a one-to-one mapping. Then, you need to translate the specification into the new model: it's likely to be a full-fledged project.

The idea behind the Gateway API is to have a clean separation between standard objects and the proprietary implementation.

## The Gateway API

> Gateway API is an open source project managed by the SIG-NETWORK community. It is a collection of resources that model service networking in Kubernetes. These resources - `GatewayClass`, `Gateway`, `HTTPRoute`, `TCPRoute`, `Service`, etc - aim to evolve Kubernetes service networking through expressive, extensible, and role-oriented interfaces that are implemented by many vendors and have broad industry support.
>
> \-- [https://gateway-api.sigs.k8s.io](https://gateway-api.sigs.k8s.io/)

The above definition also mentions an organizational concern: different roles should manage a different set of objects.

![Gateway API Model](https://static.api7.ai/2022/10/03/633a3b34999dd.png?imageMogr2/format/webp)

**Picture from gateway-api.sigs.k8s.io**

Indeed, the concerns of a cluster operator and a developer are pretty different. It's quite similar to the Java EE application servers of old, which offered a specification organized around roles: developers, deployers, and operators. IMHO, the most significant difference is that the specification was focused mainly on the developer experience; the rest was up to the implementors. The Gateway API seems to care about all personas.

## Configuring pod access via the Gateway API

Let's replace the `Ingress` we previously configured with the Gateway API. Several steps are necessary.

### Install the new Gateway CRDs

```
k apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.5.0/standard-install.yaml
```

### Install an implementation

I'll be using Apache APISIX. Alternatively, the SIG website maintains [a list of implementations](https://gateway-api.sigs.k8s.io/implementations/).

```
helm install apisix apisix/apisix \
  --namespace ingress-apisix \
  --create-namespace \
  --devel \                                                                #1
  --set gateway.type=NodePort \                                            #2
  --set gateway.http.nodePort=30800 \                                      #2
  --set ingress-controller.enabled=true \                                  #2
  --set ingress-controller.config.kubernetes.enableApiGateway=true \       #3
  --set ingressPublishService="ingress-apisix/apisix-gateway"              #4
```

1. Without the `--devel` option, Helm installs the *latest* release, which *doesn't* work with the Gateway API
2. The Gateway needs to be accessible outside the cluster anyway
3. The magic happens here!
4. I'll get back to it later

Let's check that everything works:

```
k get all -n ingress-apisix
```

```
NAME                                             READY   STATUS    RESTARTS   AGE
pod/apisix-5fc9b45c69-cf42m                      1/1     Running   0          14m    #1
pod/apisix-etcd-0                                1/1     Running   0          14m    #2
pod/apisix-etcd-1                                1/1     Running   0          14m    #2
pod/apisix-etcd-2                                1/1     Running   0          14m    #2
pod/apisix-ingress-controller-6f8bd94d9d-wkzfn   1/1     Running   0          14m    #3

NAME                                TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)
service/apisix-admin                ClusterIP   10.96.69.19     <none>        9180/TCP
service/apisix-etcd                 ClusterIP   10.96.226.79    <none>        2379/TCP,2380/TCP
service/apisix-etcd-headless        ClusterIP   None            <none>        2379/TCP,2380/TCP
service/apisix-gateway              NodePort    10.96.101.224   <none>        80:30800/TCP #4
service/apisix-ingress-controller   ClusterIP   10.96.141.230   <none>        80/TCP
```

1. Apache APISIX itself
2. Apache APISIX stores its configuration in `etcd`. The chart schedules three pods by default, a good practice to handle failures in distributed systems
3. Apache APISIX controller: a Kubernetes controller is a control loop that moves the existing state toward the desired state
4. Apache APISIX Gateway service: it's the `NodePort` `Service` that we installed via the Helm Chart. It's also the name that we referenced during the Helm Chart install - `ingressPublishService`

At this point, the infrastructure is ready.

### Declare the Gateway implementation

As I mentioned above, the API makes a clean separation between the specification and the implementation. However, we need to bind it somehow. It's the responsibility of the `GatewayClass` object:

```
apiVersion: gateway.networking.k8s.io/v1alpha2 #1
kind: GatewayClass #2
metadata:
  name: apisix-gateway-class #3
spec:
  controllerName: apisix.apache.org/gateway-controller #4
```

1. We don't use the latest version on purpose, as Apache APISIX uses this version. Be aware that it will evolve in the (near) future
2. `GatewayClass` object
3. Name it however you want; however, we will use it later to reference the gateway class
4. The controller's name depends on the implementation. Here, we are using Apache APISIX's.

Note that the `GatewayClass` has a cluster-wide scope. This model allows us to declare different Gateway API implementations and use them in parallel inside the same cluster.

### Create the Gateway

With Apache APISIX, it's pretty straightforward:

```
apiVersion: gateway.networking.k8s.io/v1alpha2 #1
kind: Gateway #2
metadata:
  name: apisix-gateway
spec:
  gatewayClassName: apisix-gateway-class #3
  listeners: #4
    - name: http
      protocol: HTTP
      port: 80
```

1. Same namespace as above
2. `Gateway` object
3. Reference the gateway class declared earlier
4. Allow some restrictions at this level so that the cluster operator can avoid unwanted usage

Warning: The Gateway API specifies the option to *dynamically* change the port on the operator side. At the time of this writing, Apache APISIX's port allocation is *static*. The plan is to make it dynamic in the future. Please subscribe to this [GitHub issue](https://github.com/apache/apisix-ingress-controller/issues/610) to follow the progress.

### Routes, routes, routes everywhere

Until now, everything was infrastructure; we can finally configure routing.

I want the same routing as in the previous post; a `/left` branch and a `right` one. I'll skip the latter for brevity's sake.

```
apiVersion: gateway.networking.k8s.io/v1alpha2 #1
kind: HTTPRoute #2
metadata:
  name: left
spec:
  parentRefs:
    - name: apisix-gateway #3
  rules:
    - matches: #4
        - path: #4
            type: PathPrefix #4
            value: /left
      backendRefs: #5
        - name: left #5
          port: 80 #5
```

1. Same namespace as above
2. `HTTPRoute` object
3. Reference the `Gateway` created above
4. Rule matches. In our case, we match regarding a path prefix, but plenty of rules are available. You can match based on a query parameter, on a header, etc.
5. The "upstream" to forward to. We defined the `left` `Service` in the previous blog post.

### Checking it works

Now that we have configured our routes, we can check it works.

```
curl localhost:30800/left
```

When we installed the Helm chart, we told Apache APISIX to create a `NodePort` service on port `30800`. Hence, we can use the port to access the service outside the cluster.

```
left
```

## Conclusion

Many alternatives are available to access a pod from outside the cluster. The CNCF added most of them to improve on the previous one.

The Gateway API is the latest proposal in this regard. The specification is a work in progress and products are at different stages of implementation. For this reason, it's too early to base your production on the API. However, you should probably follow the progress as it's bound to be a considerable improvement over the previous approaches.

The complete source code for this post can be found on [GitHub](https://github.com/ajavageek/k8s-access).

**To go further:**

- [The Gateway API](https://gateway-api.sigs.k8s.io/)
- [Getting started with the Gateway API](https://gateway-api.sigs.k8s.io/guides/getting-started/)
- [Apache APISIX Ingress Controller](https://apisix.apache.org/docs/ingress-controller/design/)

Tags:

[Kubernetes](https://api7.ai/tags/kubernetes)

[Gateway API](https://api7.ai/tags/gateway-api)

Share article link

Share

Related Posts

[![Using APISIX Ingress Controller With AWS ACM](https://static.api7.ai/uploads/2024/12/25/dCJQYedL_apisix-aws-certificate-manager.png)](https://api7.ai/blog/using-apisix-ingress-with-aws-acm)

## [Using APISIX Ingress Controller With AWS ACM](https://api7.ai/blog/using-apisix-ingress-with-aws-acm)

[![How to Use Gateway API in APISIX Ingress Controller](https://static.api7.ai/uploads/2024/09/06/jTbR13pX_Gateway%20API.png)](https://api7.ai/blog/how-to-use-gateway-api-in-apisix-ingress-controller)

## [How to Use Gateway API in APISIX Ingress Controller](https://api7.ai/blog/how-to-use-gateway-api-in-apisix-ingress-controller)

Table of Contents

- [From Ingress to the Gateway API](#from-ingress-to-the-gateway-api)

- [The Gateway API](#the-gateway-api)

- [Configuring pod access via the Gateway API](#configuring-pod-access-via-the-gateway-api)

  - [Install the new Gateway CRDs](#install-the-new-gateway-crds)
  - [Install an implementation](#install-an-implementation)
  - [Declare the Gateway implementation](#declare-the-gateway-implementation)
  - [Create the Gateway](#create-the-gateway)
  - [Routes, routes, routes everywhere](#routes-routes-routes-everywhere)
  - [Checking it works](#checking-it-works)

- [Conclusion](#conclusion)

## Related Posts

[![Kubernetes Gateway API v1.0: Should You Switch?](https://static.api7.ai/uploads/2024/12/25/TCUCuIWM_apisix-gateway-api.png)](https://api7.ai/blog/gateway-api-v1)

Ecosystem

December 15, 2023

#### [Kubernetes Gateway API v1.0: Should You Switch?](https://api7.ai/blog/gateway-api-v1)

The Kubernetes API was recently made generally available. Does that mean you should switch away from the Ingress API?

[Gateway API](https://api7.ai/tags/gateway-api)

[Kubernetes](https://api7.ai/tags/kubernetes)

[![Kubernetes Gateway API vs Ingress: Key Differences](https://static.api7.ai/uploads/2023/01/12/61sLscma_k8s.png)](https://api7.ai/blog/gateway-vs-ingress-api)

Ecosystem

October 21, 2022

#### [Kubernetes Gateway API vs Ingress: Key Differences](https://api7.ai/blog/gateway-vs-ingress-api)

Compare Kubernetes Gateway API and Ingress by routing model, roles, portability, extensibility, migration effort, and when to use each approach.

[Kubernetes](https://api7.ai/tags/kubernetes)

[Ingress API](https://api7.ai/tags/ingress-api)

[Gateway API](https://api7.ai/tags/gateway-api)

[![Ingress-NGINX to Gateway API: A Cutover Acceptance Checklist](https://static.api7.ai/uploads/2026/11/02/yHPYTHQA_gateway-api-cutover-acceptance.webp)](https://api7.ai/blog/gateway-api-v1-6-ingress2gateway)

Technology

August 18, 2026

#### [Ingress-NGINX to Gateway API: A Cutover Acceptance Checklist](https://api7.ai/blog/gateway-api-v1-6-ingress2gateway)

Migrate from Ingress-NGINX to Gateway API without treating converted YAML as proof. Inventory annotations, test controller behavior, stage traffic, and preserve rollback.

[Kubernetes](https://api7.ai/tags/kubernetes)

[Gateway API](https://api7.ai/tags/gateway-api)

[Platform Engineering](https://api7.ai/tags/platform-engineering)
