Migrating from Ingress to Gateway API
Gateway API is a modern alternative to Ingress. In Ingress, the functions of a load balancer and routing rule management are combined in a single Service object of the LoadBalancer type. In Gateway API, two separate objects are used for this:
- Gateway — defines network entry points and traffic routing rules to the cluster;
- HTTPRoute — defines traffic routing rules to services.
This separation makes the infrastructure easier to maintain. Learn more about the differences between Ingress and Gateway API in the Key Differences Between Ingress API and Gateway API section of the Migrating from Ingress guide in the Gateway API documentation.
Migration principle
When working with Ingress and Gateway API, different Kubernetes objects are used. Main objects:
- Ingress — IngressClass and Ingress;
- Gateway API — GatewayClass, Gateway and HTTPRoute.
To migrate, you need to replace Ingress objects with Gateway API objects.
To simplify migration, some objects can be converted automatically using a utility:
ingress2gatewayis the official tool. It converts Ingress objects into Gateway API objects. For example, a LoadBalancer type Service object into Gateway and HTTPRoute objects;- or
ingress2eg— an unofficial experimental version of theingress2gatewaytool. Additionally, it generates objects specific to Envoy Gateway CRD (Custom Resource Definition) from NGINX annotations. For example, BackendTrafficPolicy and SecurityPolicy.
Objects that cannot be converted automatically must be added manually. For example, a GatewayClass object.
Migration example from Ingress NGINX to Envoy Gateway
- Check quotas.
- Install Envoy Gateway.
- Create an EnvoyProxy object.
- Create a GatewayClass object.
- Convert Ingress objects into Gateway API objects.
1. Check quotas
Make sure that the pool has an allocated quota for at least one public floating IP address and a cloud load balancer. To do this, view the cloud platform quota consumption.
2. Install Envoy Gateway
Use the instructions in Install Envoy Gateway.
3. Create an EnvoyProxy object
-
Create an
envoyproxy.yamlYAML file with a manifest for the EnvoyProxy object.EnvoyProxy manifest example:
apiVersion: gateway.envoyproxy.io/v1alpha1kind: EnvoyProxymetadata:name: custom-proxy-confignamespace: defaultspec:provider:type: Kuberneteskubernetes:envoyDaemonSet: {}envoyService:externalTrafficPolicy: ClusterWhere:
externalTrafficPolicy: Clusterspecifies that all nodes will participate in traffic load balancing;envoyDaemonSet: {}specifies that Envoy replicas will run on all nodes.
-
Apply the manifest:
kubectl apply -f envoyproxy.yamlHere,
envoyproxy.yamlis the name of the YAML file with the manifest for creating the EnvoyProxy object. -
Ensure that the EnvoyProxy object is created:
kubectl get envoyproxy -n default
4. Create a GatewayClass object
To use HTTPRoutes, you need a GatewayClass that will be associated with the Envoy Gateway controller.
-
Create a
gatewayclass.yamlYAML file with a manifest for the GatewayClass object.GatewayClass manifest example:
apiVersion: gateway.networking.k8s.io/v1kind: GatewayClassmetadata:name: egspec:controllerName: gateway.envoyproxy.io/gatewayclass-controllerparametersRef:group: gateway.envoyproxy.iokind: EnvoyProxyname: custom-proxy-confignamespace: default -
Apply the manifest:
kubectl apply -f gatewayclass.yamlHere,
gatewayclass.yamlis the name of the YAML file with the manifest for creating the GatewayClass object. -
Ensure that the GatewayClass object is created:
kubectl get gatewayclass
5. Convert Ingress objects to Gateway API
If you are using NGINX with annotations, use the ingress2eg tool.
ingress2gateway
ingress2eg
-
Install the ingress2gateway tool.
-
Convert Ingress objects to Gateway API objects. All changes will only be printed to the console and will not be applied automatically. For example:
ingress2gateway print -A --providers ingress-nginx > gateway-resources.yamlWhere:
--providers ingress-nginx— flag for the controller you are migrating from;-A— flag indicating that Ingress manifests should be checked across all namespaces;gateway-resources.yaml— name of the YAML file with manifests for the new objects.
-
Open the saved
gateway-resources.yamlfile. -
If a Gateway manifest was generated:
4.1. In the
gatewayClassNamefield, replacenginxwitheg.4.2. If you are using HTTPS, specify the path to the secret containing the domain certificate.
Gateway manifest example for HTTPS protocol:
apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata:name: example-gatewaynamespace: defaultspec:gatewayClassName: eglisteners:- name: httpshostname: "*.example.com"port: 443protocol: HTTPSallowedRoutes:namespaces:from: Alltls:mode: TerminatecertificateRefs:- name: wildcard-certname-tlsnamespace: secret-namespacekind: Secret -
Create the objects specified in the manifests:
kubectl apply -f gateway-resources.yaml -
Ensure that all objects are created:
kubectl get gateways -Akubectl get httproutes -A -
Make sure that your services are available at the new IP address automatically assigned to the new cloud load balancer. You can view the load balancer IP address in the Control panel: in the top menu, click Products and select Cloud Servers → Load Balancers section → Load Balancers tab → load balancer card.