Create a Service
This section describes how to create a Service.
Prerequisites
You need to join a cluster and have the Application Workload Management permission in the cluster. For more information, see Cluster Members and Cluster Roles.
Steps
-
Log in to the KubeSphere web console with a user who has Application Workload Management permissions and enter your cluster.
-
Click Application Workloads > Services in the left navigation pane.
-
Click Create on the page.
-
On the Basic Information tab, configure the basic information for the service, then click Next.
Parameter Description Name
The name of the service. Service names must be unique within a project. The name can only contain lowercase letters, numbers, and hyphens (-), must start with a lowercase letter, and must end with a lowercase letter or a number. The maximum length is 63 characters.
Alias
The alias of the service. Different services can have the same alias.
Project
The project to which the Service belongs. System projects are typically used for managing system resources. It is recommended to select a user project.
Description
The description of the service. The description can contain any characters, with a maximum length of 256 characters.
-
On the Service Settings tab, configure the service’s internal access mode, workload selector, and ports, then click Next.
Parameter Description Internal Access Mode
The method for accessing the service from within the cluster.
-
Internal Domain Name: The system does not assign a virtual IP address to the service. It can be accessed from within the cluster using a domain name in the format
<service name>.<namespace>.svc.cluster.localor<service name>.<namespace>. -
Virtual IP Address: The system assigns a virtual IP address to the service for internal cluster access. It also supports access from within the cluster using a domain name in the format
<service name>.<namespace>.svc.cluster.localor<service name>.<namespace>.
Workload Selector
Specifies the workload(s) with specific labels to which the service will forward business traffic to their managed pods.
-
Enter label keys and values to manually set the selector. Click Add to set multiple labels.
-
Click Specify Workload to manually select workloads.
-
Click
to the right of a created label to delete it.
Ports
Service ports and their mapping relationships with target container ports.
-
Protocol: The protocol actually listened to by the application in the target container. To use the application governance features provided by KubeSphere, ensure the protocol selected here matches the one actually listened to by the application in the target container.
-
Name: The name of the service port. KubeSphere’s application governance features require service port names to be prefixed with the lowercase protocol name. 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 actually listened to by the application in the target container.
-
Service Port: The port number of the service.
Click Add to set multiple service ports. Click
to the right of a created service port to delete it.
-
-
On the Advanced Settings tab, configure the service’s external access mode, session persistence settings, and metadata, then click Create.
Parameter Description External Access
The external access mode for the service.
-
NodePort: The system maps a node’s port to the service port, allowing access to the service via the node’s IP address and the node port.
-
LoadBalancer: The system allocates an external IP address for the service based on a NodePort 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, enabling access to the service via the external IP address. To achieve this functionality, a LoadBalancer type service requires support from a load balancer plugin and the underlying infrastructure environment, and relevant annotations need to be set. For more information, please contact your infrastructure environment provider.
Session Affinity
Configure the system to forward all requests from the same client within the same session to the same pod within a specified time period. The default maximum session affinity time is 10800 seconds, but you can also manually set the maximum session affinity time.
Add Metadata
Set labels for the service.
-
Click Add to set multiple labels.
-
Click
on the right side of a created label to delete it.
The service will appear in the service list after creation.
-