Migrating from Ingress to Gateway
Prerequisites
Download the Kong preview of the kubernetes-sigs/ingress2Gateway CLI tool:
mkdir ingress2gateway && cd ingress2gateway
curl -L https://github.com/Kong/ingress2gateway/releases/download/v0.1.0/ingress2gateway_$(uname)_$(uname -m).tar.gz | tar -xzv
export PATH=${PATH}:$(pwd)
Convert all the YAML files
In order to migrate your resources from Ingress
API to Gateway API you need all
the Ingress
-based yaml
manifests. You can use these manifests as the source to
migrate to the new API by creating copies that replace the Ingress
resources
with Gateway API resources. Then, use the ingress2gateway
tool to create new manifests
containing the gateway API configurations.
Note: In this guide the Ingress resources refers to Kubernetes networkingv1
Ingress
es, KongTCPIngress
es, and KongUDPIngress
es. This means that All these resources should be included in the files used as a source for the conversion.
-
Export your source and destination paths.
SOURCE_DIR=<your_source_directory> DEST_DIR=<your_destination_directory>
-
Convert the manifests and create new files in the destination directory.
for file in ${SOURCE_DIR}/*.yaml; do ingress2gateway print --input-file ${file} -A --providers=kong --all-resources > ${DEST_DIR}/$(basename -- $file); done
-
Check the new manifest files have been correctly created in the destination directory.
ls ${DEST_DIR}
-
Copy your annotations from the ingress resources to the Routes. The routes’ names use the ingress name as prefix to help you track the route that the ingress generated. All the
konghq.com/
annotations must be copied except for these, that have been natively implemented as Gateway API features.konghq.com/methods
konghq.com/headers
konghq.com/plugins
Check the new manifests
The manifests conversion are as follows:
-
Ingress
es are converted toGateway
andHTTPRoute
s -
TCPIngress
es are converted toGateway
andTCPRoute
s andTLSRoute
s -
UDPIngress
es are converted toGateway
andUDPRoute
s
Migrate from Ingress to Gateway
To migrate from using the ingress resources to the Gateway resources:
-
Apply the new manifest files into the cluster
kubectl apply -f ${DEST_DIR}
-
Wait for all the gateways to be programmed
kubectl wait --for=condition=programmed gateway -A --all
Delete the previous configuration
After all the Gateways have been correctly deployed and are programmed, you can
delete the ingress resources. In other words the Gateways should have the status
condition Programmed
set, and status field set to True
before you delete the
ingress resources. delete the ingress resources.
Note: It is a best practice to not delete all the ingress resources at once, but instead iteratively delete one ingress at a time, verify that no connection is lost, then continue.