All Products
Search
Document Center

Container Service for Kubernetes:Create a Service

Last Updated:Mar 26, 2026

Because pods are created and deleted frequently, their IP addresses change constantly. A Kubernetes Service provides a stable network endpoint for a group of pods and distributes traffic across them, decoupling frontend clients from backend pods. Use the ACK console to create a Deployment and expose it with a Service.

Prerequisites

Before you begin, ensure that you have:

How Services work

A label selector identifies which pods a Service targets. When the Service receives traffic, it distributes requests across all pods whose labels match the selector.

The following table shows the three Service types and when to use each:

Service typeAccess patternUse when
Cluster IPInternal cluster IP address only (default)Exposing the app to other workloads within the same cluster
Node Port<NodeIP>:<NodePort> from outside the clusterDirect node-level access; not available for ACK Serverless clusters
Server Load BalancerInternet-facing or internal SLB instanceExposing the app to external users or internal VPC consumers

For the full Kubernetes Service specification, see Kubernetes Services.

Step 1: Create a Deployment

  1. Log on to the ACK console. In the left-side navigation pane, click Clusters.

  2. On the Clusters page, click the name of the target cluster. In the left-side navigation pane, choose Workloads > Deployments.

  3. In the upper-right corner of the Deployments page, click Create from YAML.

  4. Select a sample template or paste a custom YAML manifest, then click Create. The following example deploys two NGINX replicas and exposes port 80:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment-basic
      labels:
        app: nginx
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.7.9          # Replace with your image
            ports:
            - containerPort: 80         # This port is referenced in the Service port mapping
  5. On the Deployments page, click the Deployment name or click Details in the Actions column to confirm it is running.

    Deployment status view

Step 2: Create a Service

  1. In the left-side navigation pane of the cluster details page, choose Network > Services.

  2. On the Services page, click Create.

  3. In the Create Service dialog box, configure the parameters described in the following table, then click Create.

    ParameterDescription
    NameA name for the Service.
    Service TypeHow the Service is accessed. See Service type details for guidance.
    External Traffic PolicyAvailable only for Node Port and Server Load Balancer types. Local routes traffic only to pods on the node that received the request. Cluster allows traffic to be routed to pods on any node in the cluster. For a comparison, see Differences between external traffic policies.
    BackendThe Deployment to associate with this Service. If left blank, no Endpoint objects are created. See Services without selectors.
    Port MappingMaps the Service port (port field in YAML) to the container port (targetPort field in YAML). The container port must match the port exposed in the backend pod.
    AnnotationsKey-value annotations that configure the underlying SLB instance. Select Custom Annotation or Alibaba Cloud Annotation from the Type drop-down list. For example, service.beta.kubernetes.io/alicloud-loadbalancer-bandwidth:2 caps bandwidth at 2 Mbit/s. For all supported annotations, see Use annotations to configure CLB instances.
    LabelLabels used to identify this Service.
  4. On the Services page, confirm the Service appears in the list. To access the backend application, click the hyperlink next to External Endpoint on the Service details page.

Service type details

Cluster IP

Cluster IP exposes the Service on an internal cluster IP address, making it reachable only from within the cluster. This is the default type and is suitable for services consumed only by other workloads in the same cluster.

To use a headless Service — for example, to integrate with a custom service discovery mechanism — select the Headless Service checkbox. This option is available only when Service Type is set to Cluster IP.

Node Port

Node Port maps a static port on each node to the Service, allowing access from outside the cluster at <NodeIP>:<NodePort>. The system automatically creates a Cluster IP Service to handle internal routing.

Note

Node Port is supported only for ACK clusters. ACK Serverless clusters do not support this type.

Server Load Balancer

Server Load Balancer (SLB) creates or reuses an SLB instance to expose the Service externally (internet-facing) or internally (VPC-facing). Traffic can be routed to Node Port or Cluster IP Services.

SLB instance options:

  • Create SLB Instance: Click Modify to change the instance specification.

  • Use Existing SLB Instance: Select an SLB instance from your account.

Usage notes:

  • If you use an existing SLB instance, the listeners of the SLB instance overwrite the listeners of the Service.

  • Services sharing the same SLB instance must use different frontend listener ports to avoid port conflicts.

  • Do not rename listeners or vServer groups that Kubernetes manages — Kubernetes uses these names as unique identifiers.

  • SLB instances cannot be shared across clusters.

  • An SLB instance created automatically for a Service cannot be reused by other Services. Only SLB instances created manually in the console or via API can be shared across multiple Services.

What's next