Updated on 2022-04-02 GMT+08:00

ClusterIP

A workload can be accessed from other workloads in the same cluster through a cluster-internal domain name. A cluster-internal domain name is in the format of <User-defined Service name>.<Namespace of the workload>.svc.cluster.local, for example, nginx.default.svc.cluster.local.

Methods of Setting the Access Type

You can set the access type by using either of the following methods:

Setting the Access Type When Creating a Deployment

  1. In the Configure Access Settings step, click Create Service. For details, see Deployments.

    • Service Name: Name of the Service to be created, which can be self-defined.
    • Access Mode: Select ClusterIP.
    • Protocol: Select the protocol used by the Service.
    • Container Port: Port on which the workload in the container image listens. For example, the Nginx application listens on port 80 (container port).
    • Access Port: Port mapped to the container port at the cluster-internal IP address. The application can be accessed at <cluster-internal IP address>:<access port>. The port number range is 1–65535.

  2. Click OK.
  3. Click Next and configure advanced settings.
  4. Click Next and customize cluster configurations. Click OK.
  5. Obtain the access address.

    1. Click Cluster Console in the upper part of the page to access the cluster console.
    2. On the cluster console, choose Workloads > Deployments, click the name of the added workload to access the details page, and click View Access Mode to obtain the access address.

  6. Log in to any node in the cluster where the application is located. For details, see Logging In to a Linux ECS.
  7. Run the curl command to check whether the application can be accessed normally. You can perform the verification by using the IP address or domain name.

    Only applications using TCP support the preceding verification modes.

    • By using the IP address

      curl 10.247.84.62:8888

      10.247.84.62:8888 is the access address obtained in 5.

      If the following information is displayed, the application is accessible:

      <html>
      <head>
      <title>Welcome to nginx!</title>
      <style>
          body {
              width: 35em;
              margin: 0 auto;
              font-family: Tahoma, Verdana, Arial, sans-serif;
          }
      </style>
      </head>
      <body>
      <h1>Welcome to nginx!</h1>
      <p>If you see this page, the nginx web server is successfully installed and
      working. Further configuration is required.</p>
      
      <p>For online documentation and support please refer to
      <a href="http://nginx.org/">nginx.org</a>.<br/>
      Commercial support is available at
      <a href="http://nginx.com/">nginx.com</a>.</p>
      
      <p><em>Thank you for using nginx.</em></p>
      </body>
      </html>
    • By using the domain name

      curl nginx.default.svc.cluster.local:8888

      nginx.default.svc.cluster.local is the domain name obtained in 5.

      If the following information is displayed, the application is accessible:

      <html>
      <head>
      <title>Welcome to nginx!</title>
      <style>
          body {
              width: 35em;
              margin: 0 auto;
              font-family: Tahoma, Verdana, Arial, sans-serif;
          }
      </style>
      </head>
      <body>
      <h1>Welcome to nginx!</h1>
      <p>If you see this page, the nginx web server is successfully installed and
      working. Further configuration is required.</p>
      
      <p>For online documentation and support please refer to
      <a href="http://nginx.org/">nginx.org</a>.<br/>
      Commercial support is available at
      <a href="http://nginx.com/">nginx.com</a>.</p>
      
      <p><em>Thank you for using nginx.</em></p>
      </body>
      </html>

Setting the Access Type After Creating a Deployment

  1. Log in to the MCP console. In the navigation pane, choose Resource Management > Network Management. On the page displayed, click Create Service under the Services tab.
  2. Set access parameters.

    • Service Name: Name of a Service to be created. You can use the workload name as the Service name.
    • Namespace: Namespace to which the service belongs.
    • Access Type: Select ClusterIP.
    • Workload: Select an associated workload.
    • Port Configuration
      • Protocol: Protocol used by the Service.
      • Container Port: Port on which the workload listens. For example, the Nginx application listens on port 80 (container port).
      • Access Port: Port mapped to the container port at the cluster-internal IP address. The workload can be accessed at <cluster-internal IP address>:<access port>. The port number range is 1–65535.
    • Cluster: The cluster is the same as that on which the associated workload is deployed. It cannot be manually changed.

  3. Click Create. After the Service is created, you can view it in the list on the Services tab page.