This topic describes how to create a NodePort Service in the cluster named Kubernetes-piggymetrics-cluster. The Service is used to handle production traffic forwarded from the SLB instance that is attached to a Container Service for Swarm cluster.

Prerequisites

A managed Kubernetes cluster is created. For more information, see Create a managed Kubernetes cluster.

Procedure

  1. Log on to the Container Service for Kubernetes (ACK) console.
  2. In the left-side navigation pane of the ACK console, click Clusters.
  3. On the Clusters page, find the cluster that you want to manage and click the name of the cluster, or click Details in the Actions column. The details page of the cluster appears.
  4. In the left-side navigation pane of the details page, choose Services and Ingresses > Services.
  5. Click Create on the right side of the cluster named Kubernetes-piggymetrics-cluster.
  6. In the Create Service dialog box, set the required parameters and click Create. For more information, see Manage Services.
    Note
    • Name: Enter a name for the Service. gateway-swarm-slb is entered in this example.
    • Type: Select the Service type, which specifies how the Service is accessed. Node Port is selected in this example.

      Node Port: enables access to the Service by using the IP address and static port on each node. The NodePort field specifies the static port. A NodePort Service can be used to route requests to a ClusterIP Service. The ClusterIP Service is automatically created by the system. You can access the NodePort Service from outside the cluster by sending requests to <NodeIP>:<NodePort>.

    • Backend: Select the backend instance to be associated with the Service. The gateway Service is selected in this example.
    • Port Mapping: Set the Service port and container port. The container port must be the same as the one that is exposed by the backend pod. The node port range is from 30000 to 32767.