Help Center> Ubiquitous Cloud Native Service> Getting Started> Connecting a Third-Party Kubernetes Cluster
Updated on 2022-10-14 GMT+08:00

Connecting a Third-Party Kubernetes Cluster

UCS automatically takes over your CCE cluster.

This section uses a self-built cluster as an example to describe how to quickly connect a Kubernetes cluster to UCS through a public network.

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.

Connecting a Cluster

  1. Log in to the UCS console. In the navigation pane, choose Container Clusters.
  2. Click Connect under the cluster type.
  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

    * Service Provider

    Select a cluster service provider.

    * 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.

    * 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 (-).

    * Region

    Select a region where the cluster is deployed.

    * Cluster Group

    Select the cluster group to which the cluster belongs. Defaults to default.

    Figure 1 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 Connecting a Non-CCE Cluster (Private Access).

  1. Go to the UCS console and click Public Network Access in the row 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 (the file name can be customized) in the cluster, and paste the agent configuration content in 2 to the YAML file.

    vim agent.yaml

  4. Run the following command in the cluster to be connected 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

    If the deployment is successful, the expected output is as follows:

    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"

    If the is running properly, the expected log output is as follows:

    Start serving

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

    Figure 2 Cluster in running state