You can create different types of Services to configure various access policies for your applications. Alibaba Cloud Container Service for Kubernetes (AKS) lets you create Services in two ways: using the console wizard or by creating a YAML file.
Create a service using the console wizard
Log on to the Container Service for Kubernetes console. In the navigation pane on the left, click Network > Services.
On the Services page, click Create Service.
In the Select Service Type dialog box, select a service type and click Next.
The supported service types are:
Cluster IP: Provides access to the service from within the cluster.
Node Port: Provides access to the service from a static address outside the cluster.
Load Balancer: Provides access to the service node port through a load balancer.
Custom: Allows you to create a custom service using a YAML file.
Configure the Basic Information for the service and click Next.
The basic information includes the following:
Service Name: Required.
Custom Label: Optional.
Custom Annotation: Optional.
Add a Port Mapping (required) and a Cluster IP (optional), and then click Next.
You can add multiple port mappings. A port mapping includes the following:
Name: Required.
Protocol: Required.
Frontend Port: Required. The value must be an integer from 1 to 65535.
Backend Port: Optional. The value must be an integer from 1 to 65535.
Set the Pod Selector and Application Service Selector, and then click Submit.
Create a service using a YAML file
Log on to the Container Service for Kubernetes console. In the navigation pane on the left, click Network > Services.
On the Services page, click Create Service.
In the Select Service Type dialog box, select Custom.
Enter the YAML content in the input box and click Submit.
Example:
apiVersion: v1 kind:Service metadata: name: test # Enter your service name namespace:default spec: externalTrafficPolicy:Cluster ports: - name: http nodePort:30184 port:80 protocol: TCP targetPort:80 - name: https nodePort:30487 port:443 protocol: TCP targetPort:443 sessionAffinity:None type:LoadBalancer status: loadBalancer:{}
If the creation fails, you can correct the YAML content on the page and click Submit again.
If the creation is successful, the service details page opens automatically. On this page, you can view detailed information about the service, such as its event list and YAML content.