Migrating from Ingress to Gateway API
Gateway API is a modern alternative to Ingress. In Ingress, the balancer functions and routing rule management are combined into a single Service object of type Loadbalancer. In Gateway API, two separate objects are used for this:
- Gateway – defines network entry points and traffic routing rules for a cluster;
- HTTPRoute – defines traffic routing rules to services.
This separation makes infrastructure easier to maintain. For more details on the differences between Ingress and Gateway API, see the Key Differences Between Ingress API and Gateway API guide in the Migrating from Ingress section of 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:
ingress2gateway— an official utility. Converts Ingress objects to Gateway API objects. For example, a Service object of type Loadbalancer to Gateway and HTTPRoute objects;- or
ingress2eg— an unofficial experimental version of theingress2gatewayutility. Additionally, it generates objects from NGINX annotations that are specific to Envoy Gateway CRD (Custom Resource Definition). For example, BackendTrafficPolicy and SecurityPolicy.
Objects that cannot be converted automatically must be added manually. For example, the 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 to Gateway API.
1. Check quotas
Make sure that the pool has a quota for at least one public IP address and a cloud load balancer. To do this, check the cloud platform quota consumption.
2. Install Envoy Gateway
Follow the instructions on how to install Envoy Gateway.
3. Create an EnvoyProxy object
-
Create a yaml file
envoyproxy.yamlwith the 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: Clusterindicates that all nodes will participate in traffic balancing;envoyDaemonSet: {}indicates that Envoy replicas will be launched 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 yaml file
gatewayclass.yamlwith the 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 utility.
ingress2gateway
ingress2eg
-
Install the ingress2gateway utility.
-
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— a flag for the controller you are migrating from;-A— a flag indicating that Ingress manifests should be looked up in all namespaces (namespaces);gateway-resources.yaml— the name of the yaml file containing manifests for the new objects.
-
Open the saved file
gateway-resources.yaml. -
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 -
Ensure that your services are available via the new IP address that was 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.