Help Center/ Ubiquitous Cloud Native Service/ Getting Started/ Quickly Connecting an Attached Cluster
Updated on 2023-04-12 GMT+08:00

Quickly Connecting an Attached Cluster

UCS supports registration of Huawei Cloud clusters, local clusters, and attached clusters. This section uses attached clusters as an example to describe how to quickly connect a Kubernetes cluster to UCS through public network access.

  • If you are connecting a cluster located outside China to UCS, ensure that this connection and the subsequent actions you will take comply with the local laws and regulations.
  • Ensure that the registered cluster is a Kubernetes cluster that has passed the CNCF Certified Kubernetes Conformance Program and its version is 1.19 or later.

Obtaining kubeconfig

  1. Log in to the master node in the cluster to be connected.
  2. Obtain the cluster kubeconfig file.

    cat $HOME/.kube/config

    By default, the kubeconfig file of a self-built cluster is stored in the $HOME/.kube/config directory of the master node. If another kubeconfig file is specified for your cluster, change the directory. For details about the kubeconfig file, see Organizing Cluster Access Using kubeconfig Files.

  3. Copy the credential content.
  4. Create a YAML file on the local PC, paste the credential content copied in the previous step to the file, and save the file.

Creating a Fleet

  1. Log in to the UCS console. In the navigation pane, choose Fleets. On the Fleets tab page, click Create Fleet.
  2. Enter the fleet information, as shown in Figure 1.

    Figure 1 Creating a fleet
    • Fleet Name: Enter a name, starting with a lowercase letter and not ending with a hyphen (-). Only lowercase letters, digits, and hyphens (-) are allowed.
    • Add Cluster: If you do not select a cluster, an empty fleet will be created. After the fleet is created, add the cluster to the fleet by referring to Registering a Cluster.
    • Description: description of the fleet to which the cluster is added

  3. Click OK.

Registering a Cluster

  1. Log in to the UCS console. In the navigation pane, choose Fleets.
  2. Click the Register Cluster button in the card view of the target attached cluster.
  3. Select a cluster service provider and set cluster parameters as prompted. In this example, only key parameters listed in Table 1 are set.

    Table 1 Parameters for connecting a cluster

    Parameter

    Description

    * Cluster Name

    Enter a name for the cluster. Start with a lowercase letter and do not end with a hyphen (-). Use only digits, lowercase letters, and hyphens (-).

    * Service Provider

    Select a cluster service provider.

    * Region

    Select a region where the cluster is deployed.

    * kubeconfig

    Upload the kubectl configuration file to complete cluster authentication. The file can be in JSON or YAML format.

    * Context

    Select the corresponding context. The option list is available after the kubeconfig file is uploaded. By default, the option list is the context specified by the current-context field in the kubeconfig file. If the file does not contain this field, you need to manually select an option from the list.

    Fleets

    Select the fleet created in Creating a Fleet.

    Figure 2 Registering a cluster

  4. Click OK.

Enabling Network Access

After a cluster is connected, you need to configure a proxy for the cluster to access the network so that the cluster can be taken over by UCS. The following section uses public network access as an example.

Connecting a cluster through a public network is easy, flexible, and cost-effective. If you require high speed, stability, and security while low latency, you can access the cloud through a private network. For details, see Registering an Attached Cluster (Private Access).

  1. On the UCS console, click Public access in the card view of the cluster to be accessed to view the detailed public network access process.
  2. Download the configuration file of the cluster agent.

    The agent configuration file contains keys and can be downloaded only once. Keep the file secure.

  3. Use kubectl to connect to the cluster, create a YAML file named agent.yaml (customizable) in the cluster, and copy the agent configuration in 2 and paste it to the YAML file.

    vim agent.yaml

  4. Run the following command in the cluster to deploy the agent:

    kubectl apply -f agent.yaml

  5. Check the deployment of the cluster agent.

    kubectl -n kube-system get pod | grep proxy-agent

    Expected output for successful deployment:

    proxy-agent-5f7d568f6-6fc4k 1/1 Running 0 9s

  6. Check the running status of the cluster agent.

    kubectl -n kube-system logs <Agent Pod Name> | grep "Start serving"

    Expected log output for normal running:

    Start serving

  7. Go to the UCS console and refresh the cluster status. The cluster is in the Running status.

    Figure 3 Cluster in running status