Routes

    A Route on KubeSphere is the same as an Ingress on Kubernetes. You can use a Route and a single IP address to aggregate and expose multiple Services.

    • You need to create a workspace, a project and two users (for example, and project-regular). In the project, the role of admin must be project-admin and that of project-regular must be operator. For more information, see .
    • You need to create at least one Service. This document uses a demo Service as an example, which returns the Pod name to external requests.

    Configure the Route Access Method

    1. Log in to the KubeSphere web console as project-admin and go to your project.

    2. Select Gateway Settings in Project Settings on the left navigation bar and click Enable Gateway on the right.

    3. In the displayed dialog box, set Access Mode to NodePort or LoadBalancer, and click OK.

      Note

      If Access Mode is set to LoadBalancer, you may need to enable the load balancer plugin in your environment according to the plugin user guide.

    1. Log out of the KubeSphere web console, log back in as project-regular, and go to the same project.

    2. Choose Routes in Application Workloads on the left navigation bar and click Create on the right.

    3. On the Basic Information tab, configure the basic information about the Route and click Next.

      • Name: Name of the Route, which is used as a unique identifier.
      • Alias: Alias of the Route.
      • Description: Description of the Route.

    Step 2: Configure routing rules

    1. On the Routing Rules tab, click Add Routing Rule.

      • Auto Generate: KubeSphere automatically generates a domain name in the <Service name>.<Project name>.<Gateway address>.nip.io format and the domain name is automatically resolved by into the gateway address. This mode supports only HTTP.

        • Paths: Map each Service to a path. You can click Add to add multiple paths.
      • Specify Domain: A user-defined domain name is used. This mode supports both HTTP and HTTPS.

        • Domain Name: Set a domain name for the Route.
        • Protocol: Select http or https. If https is selected, you need to select a Secret that contains the (TLS certificate) and tls.key (TLS private key) keys used for encryption.

    (Optional) Step 3: Configure advanced settings

    1. On the Advanced Settings tab, select Add Metadata.

    2. Configure annotations and labels for the Route and click Create.

      Note

      You can use annotations to customize the behavior of the Route. For more information, see the .

    1. Select Routes in Application Workloads on the left navigation bar and click the name of the Route on the right.

    2. Obtain the domain name and Service path and the gateway address in the Rules area.

      • If the Route access mode is set to NodePort, the IP address of a Kubernetes cluster node is used as the gateway address and the NodePort is displayed after the domain name.

      • If the is set to LoadBalancer, the gateway address is assigned by the load balancer plugin.

    Configure Domain Name Resolution

    If Specify Domain is selected in the , you need to configure domain name resolution on your DNS server or add <Route gateway address> <Route domain name> to the etc/hosts file of your client machine.

    NodePort access mode

    1. Log in to a client machine connected to the Route gateway address.

    2. Use the <Route domain name>:<NodePort>/<Service path> address to access the backend Service of the Route.

    LoadBalancer access method

    1. Log in to a client machine connected to the Route gateway address.

    2. Use the <Route domain name>/<Service path> address to access the backend Service of the Route.

    Note

    If you need to access the Route from outside your private network by using either NodePort or LoadBalancer, depending on your network environment:

    • You may need to configure traffic forwarding and firewall policies in your infrastructure environment so that the gateway address and port number of the Route can be accessed.
    • If Auto Generate is selected in the routing rule configuration, you may need to manually to change the gateway address in the Route domain name to the external IP address of your private network.
    • If Specify Domain is selected in the routing rule configuration, you may need to change the configuration on your DNS server or in the etc/hosts file of your client machine so that the domain name can be resolved into the external IP address of your private network.

    Check Route Details

    1. Choose Routes in Application Workloads on the left navigation bar and click the name of the Route on the right.

    2. Click Edit Information, or click More and choose an operation from the drop-down menu.

      • Edit YAML: Edit the YAML configuration file of the Route.
      • Edit Routing Rules: Edit the Route rules.
      • Delete: Delete the Route and return to the Route list page.

    Resource status

    Click the Resource Status tab to view the Route rules.

    Metadata

    Click the Events tab to view the events of the Route.