Updated on 2024-08-02 GMT+08:00

Connecting to Cluster Container Assets

HSS can protect Huawei Cloud CCE clusters, third-party cloud clusters, on-premises clusters, and independent containers. This section describes how to connect these assets to HSS.

Context

In earlier versions, HSS provides cluster agent management to connect to containers. However, the containers connected in this way cannot use some container-related functions, such as container firewall and container cluster protection.

To solve this problem, in Linux agent 3.2.12 or later and Windows agent 4.0.23 or later, HSS supports installation and configuration management on containers to replace cluster agent management. Using the new function, cluster assets can fully connect to HSS and enjoy all the container-related functions provided.

If you have connected HSS to your cluster assets through cluster agent management, you are advised to uninstall the agent from your clusters, and then connect to them again by following the instructions provided in this section. In this way, you can fully enjoy cluster security functions. For more information, see Uninstalling the Agent from a Cluster.

Notice on ANP-Agent

ANP-Agent is different from HSS Agent. When a non-CCE cluster is connected to HSS, ANP-Agent is used to enable the communication between HSS and the cluster. For details about the HSS agent, see Agent Overview.

Prerequisites

  • Before connecting CCE clusters to HSS, grant the CCEOperatePolicy permission to HSS. For details, see Granting Permissions on Associated Cloud Services.
  • Before connecting a non-CCE cluster to HSS, prepare the kubeconfig file. The procedure is as follows:

    The kubeconfig file specifies the cluster permissions assigned to HSS. The kubeconfig file configured using method 1 contains the cluster administrator permissions, whereas the file generated using method 2 contains only the permissions required by HSS. If you want to minimize HSS permissions, prepare the file using method 2.

    • Method 1: configuring the default kubeconfig file
      The default kubeconfig file is in the $HOME/.kube/config directory. Perform the following operations to create a dedicated namespace for HSS:
      1. Log in to a cluster node.
      2. Create the hss.yaml file and copy the following content to the file:
        {"metadata":{"name":"hss"},"apiVersion":"v1","kind":"Namespace"}
      3. Run the following command to create a namespace:
        kubectl apply -f hss.yaml
    • Method 2: generating a kubeconfig file dedicated to HSS
      1. Create a dedicated namespace and an account for HSS.
        1. Log in to a cluster node.
        2. Create the hss-account.yaml file and copy the following content to the file:
          {"metadata":{"name":"hss"},"apiVersion":"v1","kind":"Namespace"}{"metadata":{"name":"hss-user","namespace":"hss"},"apiVersion":"v1","kind":"ServiceAccount"}{"metadata":{"name":"hss-user-token","namespace":"hss","annotations":{"kubernetes.io/service-account.name":"hss-user"}},"apiVersion":"v1","kind":"Secret","type":"kubernetes.io/service-account-token"}
        3. Run the following command to create a namespace and an account:
          kubectl apply -f hss-account.yaml
      2. Generate the kubeconfig file.
        1. Create the gen_kubeconfig.sh file and copy the following content to the file:
          #!/bin/bash
          
          KUBE_APISERVER=`kubectl config view  --output=jsonpath='{.clusters[].cluster.server}' | head -n1 `
          CLUSTER_NAME=`kubectl config view -o jsonpath='{.clusters[0].name}'`
          kubectl get secret hss-user-token -n hss -o yaml |grep ca.crt: | awk '{print $2}' |base64 -d >hss_ca_crt
          
          kubectl config set-cluster ${CLUSTER_NAME} --server=${KUBE_APISERVER}  --certificate-authority=hss_ca_crt  --embed-certs=true --kubeconfig=hss_kubeconfig.yaml
          kubectl config set-credentials hss-user --token=$(kubectl describe secret hss-user-token -n hss | awk '/token:/{print $2}') --kubeconfig=hss_kubeconfig.yaml
          kubectl config set-context hss-user@kubernetes --cluster=${CLUSTER_NAME} --user=hss-user --kubeconfig=hss_kubeconfig.yaml
          kubectl config use-context hss-user@kubernetes --kubeconfig=hss_kubeconfig.yaml
        2. Run the following command to generate the kubeconfig file named hss_kubeconfig.yaml:
          bash gen_kubeconfig.sh

Constraints and Limitations

  • CCE cluster constraints:
    • Editions: CCE standard and Turbo editions
    • Node resource requirements: at least 50 MiB memory and 200m CPU available
  • Constraints on third-party or on-premises clusters:
    • Node specifications: at least 2 vCPUs, 4 GiB memory, 40 GiB system disk, and 100 GiB data disk
    • Constraints on private networks to access regions: Currently, only CN North-Beijing1, CN North-Beijing4, CN East-Shanghai1, CN East-Shanghai2, CN South-Guangzhou, AP-Hong Kong, AP-Singapore, CN Southwest-Guiyang1, and AP-Jakarta allow third-party cloud clusters or on-premises clusters to access HSS through private networks.

Connecting an Independent Node to HSS

The method of connecting an independent container to HSS is the same as that of connecting a server to HSS. You simply need to install the agent on the container. For more information, see Installing the Agent on Servers.

Connecting a Cluster to HSS

To connect a cluster to HSS, install the agent on cluster nodes. The following sections describe how to connect different types of clusters to HSS.

Follow-up Procedure

After the cluster nodes or independent containers are connected to HSS, you need to enable protection for them. For details, see Enabling Container Protection.