This topic describes how to install Logtail components in a Kubernetes cluster.
Background information
- Create a ConfigMap named alibaba-log-configuration. The ConfigMap contains the configuration information of Log Service, such as projects.
- Optional. Create a Custom Resource Definition (CRD) named AliyunLogConfig.
- Optional. Create a Deployment controller named alibaba-log-controller. The Deployment controller is used to monitor the changes in the AliyunLogConfig CRD and the creation of Logtail configurations.
- Create a DaemonSet named logtail-ds to collect logs from nodes.
Alibaba Cloud Container Service for Kubernetes (ACK) clusters
You can install Logtail components in an existing ACK cluster. You can also install Logtail components when you create an ACK cluster. To install Logtail components when you create an ACK cluster, you must select Enable Log Service.
Install Logtail components in an existing ACK cluster
Install Logtail components when you create an ACK cluster
Self-managed Kubernetes clusters
FAQ
- How do I view the version of a container image?
You can view the version of a container image by visiting the following image repository: https://cr.console.aliyun.com/repository/cn-shanghai/log-service/logtail/images.
- How do I collect container logs from multiple Kubernetes clusters to the same Log
Service project?
- Alibaba Cloud ACK clusters
If you want to collect container logs from multiple ACK clusters to the same Log Service project, you must select the same project when you create the ACK clusters.
- Self-managed Kubernetes clusters
If you want to collect container logs from multiple self-managed Kubernetes clusters to the same Log Service project, you must set the {your-project-suffix} parameter to the same value that you specified when you install Logtail components in each Kubernetes cluster.
Note You can collect container logs from multiple self-managed Kubernetes clusters to the same Log Service project only if the Kubernetes clusters reside in the same region. - Alibaba Cloud ACK clusters
- How do I view the logs of Logtail?
The logs of Logtail are stored in the ilogtail.LOG and logtail_plugin.LOG files in the /usr/local/ilogtail/ directory of a Logtail container.
The standard output of the container is irrelevant to this case. Ignore the following standard output:
start umount useless mount points, /shm$|/merged$|/mqueue$ umount: /logtail_host/var/lib/docker/overlay2/3fd0043af174cb0273c3c7869500fbe2bdb95d13b1e110172ef57fe840c82155/merged: must be superuser to unmount umount: /logtail_host/var/lib/docker/overlay2/d5b10aa19399992755de1f85d25009528daa749c1bf8c16edff44beab6e69718/merged: must be superuser to unmount umount: /logtail_host/var/lib/docker/overlay2/5c3125daddacedec29df72ad0c52fac800cd56c6e880dc4e8a640b1e16c22dbe/merged: must be superuser to unmount ...... xargs: umount: exited with status 255; aborting umount done start logtail ilogtail is running logtail status: ilogtail is running
- How do I view the status of Log Service components in Kubernetes clusters?
Run the following commands:
kubectl get deploy alibaba-log-controller -n kube-system kubectl get ds logtail-ds -n kube-system
- What do I do if alibaba-log-controller fails to start?
Check whether alibaba-log-controller is installed by using the following method:
- Run the installation command on the master node of your Kubernetes cluster.
- Specify the ID of your Kubernetes cluster in the installation command.
If alibaba-log-controller is not installed by using the preceding method, run the
kubectl delete -f deploy
command to delete the installation template that is generated. Then, rerun the installation command. - How do I view the status of the Logtail DaemonSet in a Kubernetes cluster?
Run the
kubectl get ds -n kube-system
command to view the status of the Logtail DaemonSet.Note The default namespace in which a Logtail container resides is kube-system. - How do I view the version number, IP address, startup time, and status of Logtail?
- Run the following command to view the status of Logtail:
kubectl get po -n kube-system | grep logtail
The following output is returned:
NAME READY STATUS RESTARTS AGE logtail-ds-gb92k 1/1 Running 0 2h logtail-ds-wm7lw 1/1 Running 0 4d
- Run the following command to view the version number and IP address of Logtail:
kubectl exec logtail-ds-gb92k -n kube-system cat /usr/local/ilogtail/app_info.json
The following output is returned:
{ "UUID" : "", "hostname" : "logtail-ds-gb92k", "instance_id" : "0EBB2B0E-0A3B-11E8-B0CE-0A58AC140402_172.20.4.2_1517810940", "ip" : "192.0.2.0", "logtail_version" : "0.16.2", "os" : "Linux; 3.10.0-693.2.2.el7.x86_64; #1 SMP Tue Sep 12 22:26:13 UTC 2017; x86_64", "update_time" : "2021-02-05 06:09:01" }
- Run the following command to view the status of Logtail:
- How do I view the operational logs of Logtail?
The operational logs of Logtail are stored in the ilogtail.LOG file in the /usr/local/ilogtail/ directory. If the log file is rotated, the generated files are compressed and stored as ilogtail.LOG.x.gz.
Example:[root@iZbp1dsu6v77zfb40qfbiaZ ~]# kubectl exec logtail-ds-gb92k -n kube-system tail /usr/local/ilogtail/ilogtail.LOG [2018-02-05 06:09:02.168693] [INFO] [9] [build/release64/sls/ilogtail/LogtailPlugin.cpp:104] logtail plugin Resume:start [2018-02-05 06:09:02.168807] [INFO] [9] [build/release64/sls/ilogtail/LogtailPlugin.cpp:106] logtail plugin Resume:success [2018-02-05 06:09:02.168822] [INFO] [9] [build/release64/sls/ilogtail/EventDispatcher.cpp:369] start add existed check point events, size:0 [2018-02-05 06:09:02.168827] [INFO] [9] [build/release64/sls/ilogtail/EventDispatcher.cpp:511] add existed check point events, size:0 cache size:0 event size:0 success count:0
- How do I restart Logtail for a pod?
- Stop Logtail.
In the following command,
logtail-ds-gb92k -n
specifies the container, andkube-system
specifies the namespace. Configure the parameters based on your business scenario.kubectl exec logtail-ds-gb92k -n kube-system /etc/init.d/ilogtaild stop
If the following output is returned, Logtail is stopped.kill process Name: ilogtail pid: 7 kill process Name: ilogtail pid: 9 stop success
- Start Logtail.
In the following command,
logtail-ds-gb92k -n
specifies the container, andkube-system
specifies the namespace. Configure the parameters based on your business scenario.kubectl exec logtail-ds-gb92k -n kube-system /etc/init.d/ilogtaild start
If the following output is returned, Logtail is started.ilogtail is running
- Stop Logtail.
What to do next
- DaemonSet mode
- For information about how to collect container logs by using CRDs, see Use CRDs to collect container logs in DaemonSet mode.
- For information about how to collect container stdout and stderr logs by using the Log Service console, see Use the Log Service console to collect container stdout and stderr in DaemonSet mode.
- For information about how to collect container text logs by using the Log Service console, see Collect log data from containers by using Log Service.
- Sidecar mode
- For information about how to collect container logs by using CRDs, see Use CRDs to collect container text logs in Sidecar mode.
- For information about how to collect container logs by using the Log Service console, see Use the Log Service console to collect container text logs in Sidecar mode.