All Products
Search
Document Center

Container Service for Kubernetes:Migrate from SLB Ingresses to ALB Ingresses

Last Updated:Mar 05, 2024

Server load Balancer (SLB) Ingresses will be phased out on February 28, 2023. ACK Serverless no longer provides technical support for SLB Ingresses after they are phased out. After SLB Ingresses are phased out, you cannot install or manage the SLB Ingress controller in an ACK Serverless cluster. We recommend that you migrate from SLB Ingresses to ALB Ingresses at the earliest opportunity. This topic describes how to migrate from SLB Ingresses to ALB Ingresses.

Background information

SLB provides limited features at Layer 7. For example, SLB does not support HTTP rewrites, redirects, overwrites, and throttling. In addition, you must manually specify the specifications of SLB instances. Therefore, SLB Ingresses provide limited support for traffic routing. ALB Ingresses provide improved traffic routing capabilities based on Application Load Balancer (ALB).

Compared with SLB Ingresses, ALB Ingresses can handle complex routing based on headers or cookies and support automatic certificate discovery. ALB Ingresses also support the HTTP, HTTPS, and Quick UDP Internet Connections (QUIC) protocols to meet the requirements of Layer 7 traffic distribution for cloud-native applications. For more information about the comparison between ALB and SLB, see What is SLB?.

Migration example

In this example, an SLB Ingress that maps its endpoint to the domain name demo.ingress.vip is used.

Example:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-ingress
  namespace: default
spec:
  ingressClassName: slb
  rules:
    - host: demo.ingress.vip
      http:
        paths:
          - backend:
              service:
                name: nginx
                port:
                  number: 80
            path: /
            pathType: Prefix

Enter demo.ingress.vip in the address bar of a browser and press Enter. Welcome to nginx! appears on the page.

Step 1: Create an ALB Ingress

  1. Install the ALB Ingress controller. For more information, see Manage the ALB Ingress controller.

  2. Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.

  3. Create an AlbConfig object.

    1. Create a file named albconfig.yaml and copy the following content to the file:

      apiVersion: alibabacloud.com/v1
      kind: AlbConfig
      metadata:
        name: alb-demo
      spec:
        config:
          name: alb-test
          addressType: Internet
          zoneMappings:
          - vSwitchId: vsw-wz9e2usil7e5an1xi****
          - vSwitchId: vsw-wz92lvykqj1siwvif****
        listeners:
          - port: 80
            protocol: HTTP

      zoneMappings: the IDs of the vSwitches used by the ALB Ingress. You must specify at least two vSwitches that belong to different zones. However, the vSwitches that you specify must belong to the same virtual private cloud (VPC) as your cluster.

    2. Run the following command to create an AlbConfig object:

      kubectl apply -f albconfig.yaml
    3. Run the following command to check whether the AlbConfig object is created:

      kubectl get albconfig <AlbConfig name>

      Expected output:

      NAME       ALBID                    DNSNAME                                               PORT&PROTOCOL   CERTID   AGE
      alb-demo   alb-eeee6gtqbmrm19****   alb-eeee6gtqbmrm19****.cn-shenzhen.alb.aliyuncs.com                            27s
  4. Create an IngressClass.

    1. Create a file named ingressclass.yaml and copy the following content to the file:

      apiVersion: networking.k8s.io/v1
      kind: IngressClass
      metadata:
        name: alb
      spec:
        controller: ingress.k8s.alibabacloud/alb
        parameters:
          apiGroup: alibabacloud.com
          kind: AlbConfig
          name: alb-demo

      parameters.name: the name of the AlbConfig object that you want to use.

    2. Run the following command to create an IngressClass:

      kubectl apply -f ingressclass.yaml
  5. Create an ALB Ingress.

    1. Create a file named albingress.yaml and copy the following content to the file:

      apiVersion: networking.k8s.io/v1
      kind: Ingress
      metadata:
        name: demo-ingress-alb
        namespace: default
      spec:
        ingressClassName: alb
        rules:
          - host: demo.ingress.vip
            http:
              paths:
                - backend:
                    service:
                      name: nginx
                      port:
                        number: 80
                  path: /
                  pathType: Prefix
      • name: the name of the Ingress that you want to use. The name cannot be the same as the name of the SLB Ingress.

      • ingressClassName: the name of the IngressClass that you want to use.

    2. Run the following command to create an ALB Ingress:

      kubectl apply -f albingress.yaml
    3. Run the following command to query the endpoint of the ALB Ingress:

      kubectl get ing

      Expected output:

      NAME                CLASS   HOSTS              ADDRESS                                               PORTS   AGE
      demo-ingress       slb     demo.ingress.vip   120.79.**.**                                           80      35m
      demo-ingress-alb   alb     demo.ingress.vip   alb-eeee6gtqbmrm1****.cn-shenzhen.alb.aliyuncs.com   80      10m     46s

      The endpoint of the ALB Ingress is alb-eeee6gtqbmrm1****.cn-shenzhen.alb.aliyuncs.com.

    4. Run the following command to access the NGINX application by using the ALB Ingress:

      curl -H "Host: demo.ingress.vip" http://alb-eeee6gtqbmrm1****.cn-shenzhen.alb.aliyuncs.com

      Expected output:

      <!DOCTYPE html>
      <html>
      <head>
      <title>Welcome to nginx!</title>
      <style>
          body {
              width: 35em;
              margin: 0 auto;
              font-family: Tahoma, Verdana, Arial, sans-serif;
          }
      </style>
      .............

Step 2: Use the ALB Ingress to forward traffic

Modify the DNS record for demo.ingress.vip by replacing the endpoint of the SLB Ingress with the endpoint of the ALB Ingress. This way, the ALB Ingress is used to forward traffic.

  1. Log on to the Alibaba Could DNS console.

  2. On the Domain Name Resolution page, click demo.ingress.vip in the Authoritative Domain Names column.

  3. On the DNS Settings for demo.ingress.vip page, click Modify in the Actions column.

  4. In the Modify DNS Record panel, set Record Value to the endpoint of the ALB Ingress, which is alb-eeee6gtqbmrm1****.cn-shenzhen.alb.aliyuncs.com in this example. Then, click OK.

  5. Enter demo.ingress.vip in the address bar of a browser and press Enter.

    nginx

    Welcome to nginx! appears on the page. This indicates that you can access the NGINX application by using the ALB Ingress.

Step 3: Delete the SLB Ingress

  1. Delete the SLB Ingress.

    1. In the left-side navigation pane of the details page, choose Network > Ingresses.

    2. In the upper part of the Ingresses page, select the namespace to which the SLB Ingress belongs. Find the SLB Ingress and choose More > Delete in the Actions column.

    3. In the message that appears, click OK.

  2. Uninstall the SLB Ingress controller.

    1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

    2. On the Clusters page, click the name of the cluster that you want to manage and choose Operations > Add-ons in the left-side navigation pane.

    3. On the Add-ons page, click the Others tab. Find SLB Ingress Controller and click Uninstall.

    4. In the message that appears, click OK.

FAQ

Is smooth migration from SLB Ingresses to ALB Ingresses supported?

Smooth migration from SLB Ingresses to ALB Ingresses is not supported because SLB Ingresses are different from ALB Ingresses.