Create Services Using Existing Workloads
This section explains how to create services using existing workloads as backend workloads.
Prerequisites
You should join a project and have the Application Workload Management permission within the project. For more information, refer to "Project Members" and "Project Roles".
You should have workloads created in the project beforehand. For more information, refer to Create Workloads.
Steps
Log in to the KubeSphere web console with a user who has the Application Workload Management permission, and access your project.
Click Application Workloads > Services in the left navigation pane.
Click Create on the page.
In the Create Service dialog, select Specify Workload.
On the Basic Information tab, configure the basic information for the service, and then click Next.
Parameter Description 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.
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 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 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 on the right side 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 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 on the right side of a created label to delete it.
Services will be displayed in the service list after creation.
Feedback
Was this page Helpful?
Receive the latest news, articles and updates from KubeSphere
Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.