Create Services

This section explains how to create services.

Prerequisites

You should join a cluster and have the Application Workload Management permission within the cluster. For more information, refer to “Cluster Members” and “Cluster Roles”.

Steps

  1. Log in to the KubeSphere web console with a user who has the Application Workload Management permission, and access your cluster.

  2. Click Application Workloads > Services in the left navigation pane.

  3. Click Create on the page.

  4. On the Basic Information tab, configure the basic information for the service, and then click Next.

    ParameterDescription

    Name

    The name of the service. Service names within the same project must be unique. Names can only contain lowercase letters, numbers, and hyphens (-), and must start and end with a lowercase letter or number, with a maximum length of 253 characters.

    Alias

    The alias of the service. Aliases can be the same for different services. Aliases can only contain Chinese characters, letters, numbers, and hyphens (-), and must not start or end with a hyphen (-), with a maximum length is 63 characters.

    Project

    The project to which the service belongs. System projects are typically used for managing system resources, and it is recommended to choose a user project.

    Description

    The description of the service. The description can contain any characters, with a maximum length of 256 characters.

  5. On the Service Settings tab, configure the service’s internal access mode, workload selector, and ports, then click Next.

    ParameterDescription

    Internal Access Mode

    The way to access the service within the cluster.

    • Internal Domain Name: The system does not assign a virtual IP address to the service. It can be accessed internally by using the format <service name>.<namespace>.svc.cluster.local or <service name>.<namespace>.

    • Virtual IP Address: The system assigns a virtual IP address to the service for internal access within the cluster. It also supports access internally by using the format <service name>.<namespace>.svc.cluster.local or <service name>.<namespace>.

    Workload Selector

    Specify the workloads with specific labels to which the service routes business traffic.

    • Manually set selectors by entering the key and value of a label. Click Add to set multiple labels.

    • Manually select workloads by clicking Specify Workload.

    • Click trash-light on the right side of a created label to delete it.

    Ports

    Map service ports and their corresponding container ports.

    • Protocol: The protocol that the application in the target container actually listens on. To use the application governance features provided by KubeSphere, ensure that the protocol selected here matches the one the application in the target container actually listens on.

    • Name: The name of the service port. The application governance features of KubeSphere require the service port name to have the protocol name in lowercase as a prefix. To use the application governance features provided by KubeSphere, use the lowercase protocol name as the prefix for the port name (e.g., http-).

    • Container Port: The port number on which the application in the target container actually listens.

    • Service Port: The port number of the service.

    Click Add to set multiple service ports. Click trash-light on the right side of a created service port to delete it.

  6. On the Advanced Settings tab, configure the service’s external access mode, session persistence settings, and metadata, then click Create.

    ParameterDescription

    External Access

    The external access mode for the service.

    • NodePort: The system maps the ports of nodes to the service ports, and the service can be accessed through the node IP address and node port.

    • LoadBalancer: On the basis of a NodePort service, the system assigns an external IP address to the service and binds the external IP address to an external load balancer. The external load balancer listens on the node port corresponding to the service, allowing access to the service through the external IP address. To achieve this, LoadBalancer-type services need support from load balancer plugins and the infrastructure environment, and relevant annotations need to be set. For more information, please contact your infrastructure environment provider.

    Session Persistence

    Configure the system to forward all requests from the same client in the same session to the same pod within a specified duration. The default maximum stickiness duration is 10800 seconds, and you can also change it.

    Add Metadata

    Set labels for the service.

    • Click Add to set multiple labels.

    • Click trash-light on the right side of a created label to delete it.

    Services will be displayed in the service list after creation.