Before collecting container text logs or standard output, you need to install LogCollector in the Kubernetes cluster and configure the relevant environment. This topic introduces how to install LogCollector using DaemonSet deployment.
Background information
After installing LogCollector on a Kubernetes cluster via DaemonSet deployment, LogCollector can collect text logs or standard output from containers inside other Pods. The following steps are mainly required during installation.
- Configure ServiceAccount, ClusterRole, and ClusterRoleBinding; complete LogCollector authentication and authorization.
- Create ConfigMap for LogCollector.
- Create LogCollector DaemonSet.
The IAM user has been created, and the Access Key ID and Secret Access Key have been obtained. Besides, the user is granted at least the TLSLogCollectorAccess permission policy. For details about permissions, see IAM overview. Notice
Helm 3 client is installed (version 3.7 or later version). For detailed instructions, see Helm. 1 Download LogCollector Chart package
Log in to the Kubernetes cluster where you need to install LogCollector. Run the corresponding download command based on the cluster region to download the LogCollector Chart package.
Notice
- Region ID: Replace this with the actual region ID for your environment. For example, cn-beijing for North China 2 (Beijing).
- --version 0.1.0: Used to obtain parameters for the LogCollector chart; this value is fixed.
- LogCollector version: The version is determined by the image parameter specified in the LogCollector Chart deployment command. By default, the latest LogCollector version is used.
2 Deploy the LogCollector Chart package
Run the following command to deploy the LogCollector Chart package.
Notice
- If prompt shows Error: INSTALLATION FAILED: Unable to continue with install: ClusterRole "logcollector" in namespace "" exists and can not be imported into the current release…, a ClusterRole with the same name has already been installed. You need to run kubectl delete clusterrole logcollector to delete this ClusterRole first.
- If prompt shows Error: INSTALLATION FAILED: Unable to continue with install: ClusterRoleBinding "logcollector" in namespace "" exists and cannot be imported into the current release…, it means that a ClusterRoleBinding with the same name has already been installed. You need to run kubectl delete clusterrolebinding logcollector to delete this ClusterRoleBinding first.
The following are required parameters: region, endpoint, secret_id, secret_key, label, image, logcollector_data. Details are provided below.
Shell script installation method
1 Download the LogCollector installation package
Log in to the Kubernetes cluster where you need to install LogCollector; download the LogCollector installation package to the specified directory according to your cluster’s region and network type.
Replace Region ID in the download address with the ID for your actual region.
- Private network download address
- Public network download address
Run the following command to install LogCollector.
Among the parameters, region, endpoint, secret_id, secret_key, label, and logcollector_data are required parameters; namespace and image are optional parameters. Details are as follows.
Manual installation method
1 Create Namespace
This step creates a Namespace .
- Log in to the Kubernetes cluster where LogCollector needs to be installed.
- Create a YAML file named logcollector_ns.yaml .
- Edit the YAML file and enter the following content.
- Configure the following parameters as needed.
- The parameters are described below:
- Run the following command to apply the Namespace configuration.
2 Create ServiceAccount
Create a ServiceAccount for LogCollector and configure basic identity information.
- Create a YAML file named logcollector_sa.yaml.
- Enter the following content in the YAML file.
- Run the following command to apply the ServiceAccount configuration.
3 Create ClusterRole
Create a ClusterRole for LogCollector.
- Create a YAML file named logcollector_cr.yaml.
- Enter the following content in the YAML file.
- Run the following command to apply the ClusterRole configuration.
4 Create ClusterRoleBinding
Create a ClusterRoleBinding for LogCollector.
- Create a YAML file named logcollector_crb.yaml.
- Enter the following content in the YAML file.
- The parameters are described below:
- Run the following command to apply the ClusterRoleBinding configuration.
5 Create ConfigMap
Create a ConfigMap for LogCollector.
- Create a YAML file named logcollector_config.yaml.
- Enter the following content in the YAML file.
- The parameters are described below:
- Run the following command to apply the ConfigMap configuration.
Create a DaemonSet for LogCollector to collect logs from the current broker.
- Create a YAML file named logcollector_ds.yaml.
- Enter the following content in the YAML file and replace the parameters as needed.
- The parameters are described below:
- Run the following command to apply the DaemonSet configuration.
LogCollector image address
The latest LogCollector image addresses provided by Torch log service (TLS) in each region are as follows:
Replace Region ID in the image address with the actual region ID for your environment, such as cn-beijing for North China 2 (Beijing).