Migrate an Ingress configuration to Kong Operator

Migrate your existing Ingress resources from Kong Ingress Controller to Kong Operator while you keep the Service and address your clients use. During the migration, both controllers read the same Ingress resources. You don’t need to convert your Ingress resources to Gateway API routes.

When you finish this guide, a Kong Operator-managed gateway serves traffic behind your retained Service. You continue to manage that Service yourself. If you use both Ingress and Gateway API resources, start with the migration overview.

Before you begin

This guide assumes a DB-less installation deployed with the kong/kong or kong/ingress Helm chart, and uses an HTTP listener on port 80. The replacement gateway must be in the same namespace as the existing proxy Service. If you use HTTPS or other protocols, adapt the listeners and validation requests.

You need the following tools and access:

  • Administrative access to the cluster
  • Bash
  • Helm
  • kubectl
  • jq
  • cert-manager

Before you start, back up your Kubernetes configuration and Helm values, and upgrade to Kong Ingress Controller 3.5. Make sure the cluster has enough capacity to run both installations at the same time.

Set the following values for your installation. To find the existing release name and chart version, run helm list. Keep the current gateway image, and choose a replica count that can serve your traffic. KO only deploys Kong Gateway 3.4.1 or later. If your current image is older, upgrade it before you start.

Set INGRESS_CLASS to the class that your existing Ingress resources use.

export NAMESPACE=default
export RELEASE_NAME=kong
export KIC_CHART_VERSION='<installed-chart-version>'
export PROXY_SERVICE=kong-proxy
export GATEWAY_IMAGE='<current-image:tag>'
export GATEWAY_REPLICAS=2
export INGRESS_CLASS=kong

This guide names the new resources kong-migrated. If that name is already in use, choose another name and use it throughout this guide.

Preserve the existing Service

To keep the proxy Service and its address when you uninstall KIC, add the helm.sh/resource-policy: keep annotation to your existing Helm values. This way, Helm records the annotation in the release manifest. Use the tab for your installed chart.

Check that the Service has the helm.sh/resource-policy: keep annotation:

kubectl get svc -n "$NAMESPACE" "$PROXY_SERVICE" -o yaml

Add the retained Service to the manifests you maintain. If you use GitOps, make sure that it preserves this Service and the selector you set during cutover.

Install Kong Operator

Update the Kong Helm repository:

helm repo update kong

Install KO alongside your existing installation:

helm upgrade --install kong-operator kong/kong-operator \
  -n kong-system \
  --create-namespace \
  --take-ownership \
  --set env.ENABLE_CONTROLLER_KONNECT=true \
  --set ko-crds.enabled=true \
  --set global.webhooks.conversion.enabled=true \
  --set global.webhooks.options.certManager.enabled=true

Check that the KO pods are running:

kubectl get pods -n kong-system

Complete any Kong Operator upgrades before cutover. Avoid Kong Operator restarts while you change routing resources.

Create the replacement gateway

KO uses a Gateway resource to manage the replacement deployment, even though your application routing still uses Ingress resources. To make the replacement process those Ingress resources, set controlPlaneOptions.ingressClass to your existing ingress class.

Create a GatewayConfiguration, a GatewayClass, and a Gateway that use your current image and replica count. The new Service is internal (ClusterIP), so it doesn’t change client traffic:

cat <<EOF | kubectl apply -f -
kind: GatewayConfiguration
apiVersion: gateway-operator.konghq.com/v2beta1
metadata:
  name: kong-migrated
  namespace: ${NAMESPACE}
spec:
  dataPlaneOptions:
    deployment:
      replicas: ${GATEWAY_REPLICAS}
      podTemplateSpec:
        spec:
          containers:
          - name: proxy
            image: ${GATEWAY_IMAGE}
    network:
      services:
        ingress:
          type: ClusterIP
  controlPlaneOptions:
    ingressClass: ${INGRESS_CLASS}
    cache:
      initSyncDuration: 30s
    controllers:
    - name: INGRESS_NETWORKINGV1
      state: enabled
    - name: INGRESS_CLASS_NETWORKINGV1
      state: enabled
    - name: KONG_PLUGIN
      state: enabled
    - name: KONG_CLUSTERPLUGIN
      state: enabled
    - name: KONG_CONSUMER
      state: enabled
---
kind: GatewayClass
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: kong-migrated
spec:
  controllerName: konghq.com/gateway-operator
  parametersRef:
    group: gateway-operator.konghq.com
    kind: GatewayConfiguration
    name: kong-migrated
    namespace: ${NAMESPACE}
---
kind: Gateway
apiVersion: gateway.networking.k8s.io/v1
metadata:
  name: kong-migrated
  namespace: ${NAMESPACE}
spec:
  gatewayClassName: kong-migrated
  listeners:
  - name: http
    protocol: HTTP
    port: 80
EOF

Wait for the Gateway to report Programmed:

kubectl wait -n "${NAMESPACE}" --for=condition=Programmed --timeout=300s gateway/kong-migrated

Both installations now translate the same Ingress resources for their own data planes. You don’t need to attach routes.

Validate the replacement

The new data plane doesn’t have an external address, so use a port-forward to reach it.

Find the data plane Service:

INGRESS_SVC=$(kubectl get svc -n "${NAMESPACE}" -l gateway-operator.konghq.com/managed-by=dataplane \
  -o jsonpath='{.items[?(@.spec.ports[0].port==80)].metadata.name}')

Check that INGRESS_SVC contains exactly one Service, and that it belongs to kong-migrated. If you have other Kong Operator-managed data planes, set INGRESS_SVC to the correct Service name.

Start the port-forward:

kubectl port-forward -n "${NAMESPACE}" "svc/$INGRESS_SVC" 18000:80

In another terminal, send requests for every hostname and path your configuration serves, and check that plugin behavior matches. For example:

curl -i -H "Host: example.com" http://127.0.0.1:18000/

Check the response body, status code, and any headers that your plugins add. Compare each response with the same request sent to your existing gateway. Don’t continue until every route matches.

Switch traffic

Before you change the existing Service selector, save it as a rollback patch.

Turn on pipefail so that the save command fails if kubectl fails:

set -o pipefail

Save the selector:

kubectl get svc -n "${NAMESPACE}" "${PROXY_SERVICE}" -o json \
  | jq -e '[{"op":"replace","path":"/spec/selector","value":.spec.selector}]' \
  > rollback-proxy-service.json

Check that the command succeeded and that rollback-proxy-service.json contains the original selector.

Point the Service at the replacement pods:

kubectl patch svc -n ${NAMESPACE} ${PROXY_SERVICE} --type json -p \
  '[{"op":"replace","path":"/spec/selector","value":{"gateway.networking.k8s.io/gateway-name":"kong-migrated"}}]'

Use the JSON replace operation. A merge patch combines the old and new selectors. The gateway-name label keeps the selector tied to the Gateway, even if KO recreates the DataPlane resource.

Check that the Service endpoints point to the replacement pods:

kubectl get endpointslice -n ${NAMESPACE} -l kubernetes.io/service-name=${PROXY_SERVICE} \
  -o jsonpath='{range .items[*].endpoints[*]}{.targetRef.name}{"\n"}{end}'

Repeat your application checks through the original client address. Leave the old pods running so that existing connections can drain. If you use an AWS NLB with IP targets, wait for the new targets to become healthy and for the old targets to drain before cleanup. For more information, see AWS load balancer cutover.

Roll back

If validation fails, restore the saved selector:

kubectl patch svc -n "${NAMESPACE}" "${PROXY_SERVICE}" --type json \
  --patch-file rollback-proxy-service.json

Then check traffic through the original address.

Keep the old installation and routing configuration until you accept the cutover. After cleanup starts, restoring the selector might not be enough to roll back.

Retire the old installation

Before you start cleanup, wait until:

  • Application checks pass through the existing address.
  • Old connections have drained.
  • Load balancer target changes have converged.

You can run cleanup later, in a maintenance window.

Cleanup ends the simple rollback path. Verify traffic after the uninstall, and wait for routing to settle. Avoid Kong Operator restarts during cleanup.

  1. Uninstall the Helm release:

    helm uninstall -n ${NAMESPACE} ${RELEASE_NAME}

    Helm reports the proxy Service as kept.

  2. Verify that traffic through your address is still healthy.

The uninstall also removes the old IngressClass object. If other tooling depends on it, see IngressClass after uninstall.

The migration is complete. Keep the retained Service in your managed manifests. KO publishes the address of its own internal Service in resource status. If your tooling reads that field, see Published addresses.

Troubleshooting

Symptom

Cause

Resolution

The new Gateway is programmed, but it returns 404 for every Ingress resource. controlPlaneOptions.ingressClass doesn’t match the class that your Ingress resources reference. When ingressClass isn’t set, the control plane uses the kong class. Set ingressClass in the GatewayConfiguration to the class that your Ingress resources use.
The Service has no endpoints after the cutover. The selector was applied with --type merge, which combined the old and new selectors. Apply the selector again with --type json and a replace operation.
A second Gateway that uses the same GatewayClass never becomes programmed, and its ingress Service stays <pending>. The shared GatewayConfiguration pins a specific load balancer address, and you can’t assign one address to two Services. If you pin addresses, give each Gateway its own GatewayConfiguration.
Requests return 404 for a few seconds during cleanup. Several Gateway API objects changed while KO was restarting, so the control plane pushed a configuration that was missing routes. Verify traffic after each step, and increase cache.initSyncDuration.
Ingress status.loadBalancer shows a cluster IP after the migration. KO publishes the address of its own data plane ingress Service, which is ClusterIP in this guide. This is expected. See Optional: Transfer address management.

Additional details

Published addresses

KO publishes the ClusterIP of its own data plane Service. This address is different from the address on your retained Service. Account for this difference in tooling that reads resource status.

While both controllers run, the published Ingress status.loadBalancer address can switch between the two installations. Validate application traffic through the retained Service.

GatewayConfiguration settings

The example sets cache.initSyncDuration to 30s. This gives the control plane more time to initialize its Kubernetes caches before the first configuration push. The default value is 5s. For other settings, see the GatewayConfiguration reference.

AWS load balancer cutover

On AWS with aws-load-balancer-nlb-target-type: ip, the load balancer registers pod IPs directly instead of node ports. In this case, the selector change is a target group membership change. New targets must pass health checks while old targets drain, so the cutover is gradual. The old pods keep serving traffic while they’re removed from the target group, so the cutover doesn’t cause an outage. Wait for the target group to fully converge before you start cleanup.

With the default instance target type, the selector change doesn’t affect the load balancer.

Stop the old controller before uninstall

To stop KIC from reconciling before the uninstall, you can scale its controller down to zero replicas. You can only do this with the ingress chart, which runs the controller in its own Deployment:

kubectl scale deploy -n ${NAMESPACE} ${RELEASE_NAME}-controller --replicas=0

The kong chart runs the controller as a container in the same Deployment as the gateway, so you can’t scale it separately. Uninstall the release instead.

IngressClass after uninstall

The Helm uninstall also removes the IngressClass object. This doesn’t affect routing. KO matches Ingress resources on the spec.ingressClassName string, and only reads the IngressClass object to resolve the default class annotation. Recreate the IngressClass only if other tooling depends on it.

Optional: Transfer address management

After the migration, you can move the client address from your retained Service to the KO-managed Service. This operation is optional, separate from the migration, and depends on your load balancer platform.

After the migration, the client address lives on a Service that no chart or Kong Operator manages. KO publishes its own ClusterIP in the status of your Ingress and Gateway resources, and not your client address.

If you move the address to the KO-managed Service, KO manages the whole setup. Whether this is worth doing depends on your platform:

Proxy Service type

Recommendation

ClusterIP or NodePort Not applicable. Your clients resolve the Service by name, and the new Service has a different name. Keep the Service you have.
Self-managed load balancer, such as MetalLB Optional. Reassignment is a local operation and completes in less than a second.
AWS Don’t attempt. A load balancer’s lifecycle is bound to the Service that created it, and AWS has no reassignment operation. Deleting the Service deletes the load balancer, and the replacement load balancer has a different hostname. To pin elastic IPs, you must first release them from the old load balancer.
Azure Don’t attempt. You can’t attach a static public IP to two Services at once. The move is a release followed by a reassignment, and reconciliation takes from tens of seconds to minutes.
Other cloud providers Before you try this, check that your provider supports moving the address between Services. If you aren’t sure, keep the Service you have.

If you keep the existing Service, the migration outcome stays the same. Continue to manage its manifest yourself, and account for the different status address in any tooling that reads it.

If your platform supports the move, request the address on the new Service first, and let the request stay pending. Then release the address from the old Service. In this order, the load balancer assigns the address to the new Service as soon as the old Service releases it.

  1. Request the address on the KO-managed Service. Replace the annotation with the equivalent annotation for your load balancer:

    kubectl patch gatewayconfiguration -n "${NAMESPACE}" kong-migrated --type merge -p \
      '{"spec":{"dataPlaneOptions":{"network":{"services":{"ingress":{
         "type":"LoadBalancer",
         "annotations":{"metallb.universe.tf/loadBalancerIPs":"192.0.2.10"}}}}}}}'
  2. Wait until the new Service has the LoadBalancer type and a pending address.

  3. Release the address from the old Service:

    kubectl patch svc -n ${NAMESPACE} ${PROXY_SERVICE} --type json \
      -p '[{"op":"replace","path":"/spec/type","value":"ClusterIP"}]'
  4. Check that the new Service has the address, and verify traffic. Then delete the old Service.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!