All Products
Search
Document Center

Container Compute Service:Create a ClusterIP service

Last Updated:Mar 26, 2026

When backend pods are replaced, rescheduled, or scaled, their IP addresses change. A frontend application that connects directly to pod IPs loses connectivity every time this happens. A Service solves this by providing a stable virtual IP that routes traffic to healthy backend pods, regardless of which specific pods are running.

This topic shows how to create a ClusterIP Service in the ACS console. ClusterIP exposes the Service on a cluster-internal IP address, making it accessible only from within the cluster. It is the default Service type.

Prerequisites

Before you begin, ensure that you have:

  • An Alibaba Cloud Container Service (ACS) cluster

  • Access to the ACS console

What you'll do

  1. Create an Nginx Deployment with two replicas.

  2. Create a ClusterIP Service that routes traffic to the Deployment.

Step 1: Create a Deployment

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

  2. On the Clusters page, find the cluster you want to manage and click its ID. In the left-side navigation pane of the cluster details page, choose Workloads > Deployments.

  3. On the Deployments page, click Create from YAML.

  4. Select a sample template or a custom template, then click Create. The following YAML creates an Nginx Deployment with two replicas:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: my-nginx-svc
      namespace: default
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: registry.cn-hangzhou.aliyuncs.com/acs-sample/nginxdemos:latest
            ports:
            - containerPort: 80
  5. On the Deployments page, click the application name or Details in the Actions column, and wait for all pod instances to become available.

Step 2: Create a ClusterIP Service

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

  2. On the Services page, click Create. In the Create Service dialog box, configure the following parameters and click OK.

    ParameterDescriptionExample
    NameThe name of the Service.my-nginx-svc
    Service TypeSelect Cluster IP. This type exposes the Service on a cluster-internal IP address, making it accessible only from within the cluster. It is the default Service type. To use a Headless Service — for example, to integrate with a custom service discovery mechanism — enable Headless Service.Cluster IP
    BackendThe backend application to attach to the Service. A label selector matches backend pods. If you do not associate the Service with a backend, no Endpoint object is created. For more information, see Services without selectors.Name: app, Value: nginx
    Port MappingThe service port (port in the Service YAML) and the container port (targetPort in the Service YAML). The container port must match the port exposed by the backend pod.Service Port: 80, Container Port: 80, Protocol: TCP
    AnnotationsAn annotation to add to the Service.None
    LabelA label to identify the Service.None

    After the Service is created, you can find it on the Services page and click Update, Edit YAML, or Delete in the Actions column.

For more information about Kubernetes Services, see Kubernetes Services.