Workflow clusters support integration with Log Service. After you enable Log Service for a workflow cluster, Log Service collects and stores the logs of workflow pods in the cluster. After the pod logs are collected to Log Service, you can view the logs by using the Argo CLI or Argo UI, regardless of whether the pods are deleted. If workflows are deleted, you can view the logs in the Log Service console. This topic describes how to configure Log Service for a workflow cluster .
Table of contents
Usage notes
If
oss-artifact-repository
is enabled andarchiveLogs: true
is specified for a workflow cluster, Log Service does not collect pod logs from the cluster. In this case, the pod logs are collected tooss-artifact-repository
.Compared with
oss-artifact-repository
, Log Service provides automated log lifecycle management and powerful log query features. Log Service also allows you to configure the retention period of logs. To enable Log Service in this case, delete thearchiveLogs: true
setting.
Enable Log Service
After you create a workflow cluster, a Log Service project named k8s-log-<clusterid> is automatically created by the system to collect pod logs from the cluster. If no project named k8s-log-<clusterid> exists, create one. For more information about how to create a Log Service project, see Create a Log Service project.
You can enable Log Service by using the Alibaba Cloud Argo CLI or by creating an AliyunLogConfig.
Enable Log Service by using the Alibaba Cloud Argo CLI
The Alibaba Cloud Argo CLI is fully compatible with the open source Argo CLI and has enhanced the logging capability. The Alibaba Cloud Argo CLI can collect the logs of pods that are deleted from a workflow.
Download the Alibaba Cloud Argo CLI package based on the OS that you use and rename the package as Argo.
Darwin: Download the Alibaba Cloud Argo CLI.
Run the following command to configure Log Service:
argo config sls
Please input log retention days. Default is 7 days.
10
Expected output:
Start to config SLS for your cluster.
Created AliyunLogConfig CR workflow-sls-config in default namespace.
Created SLS logstore workflow-logstore in SLS project k8s-log-<clusterid>, log retention days is 10 days
The output shows that Log Service is configured. The logs of all workflows in the cluster are collected to the workflow-logstore Logstore.
Log on to the Log Service console, find the k8s-log-<clusterid> project, and then click workflow-logstore to view logs.
Enable Log Service by creating an AliyunLogConfig
Run the following command to create an AliyunLogConfig. The Log Service controller automatically creates a project named k8s-log-<clusterid> and a Logstore named workflow-logstore.
cat << EOF | kubectl apply -f -
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: workflow-sls-config
namespace: default
spec:
# log will store for 5 days
lifeCycle: 5
logstore: workflow-logstore
logtailConfig:
inputType: plugin
configName: workflow-sls-config
inputDetail:
plugin:
inputs:
- detail:
Stderr: true
Stdout: true
type: service_docker_stdout
EOF
Access Log Service
Access Log Service by using the Argo CLI
If you want to view the logs of the deleted pods by using the Argo CLI, you must first configure the required parameters.
To query workflow logs collected by Log Service, you must specify
<pod-name>
.To access workflows or pods in another namespace, you must obtain the
KUBE_TOKEN
for the namespace.
Run the following commands to enable Argo Server and configure parameters:
export ARGO_SERVER=argo.<cluster id>.<region>.alicontainer.com:2746 export KUBE_TOKEN=$(k create token default -n default --duration 24h) export ARGO_TOKEN="Bearer $KUBE_TOKEN" export ARGO_INSECURE_SKIP_VERIFY=true
Run the following command to query the log of a workflow pod:
argo logs <workflow-name> <pod-name>
Access Log Service by using the Argo UI
You can view the logs of workflow pods by using the Argo CLI, regardless of whether the pods are deleted. If you query the log of a deleted pod, the log of the pod is displayed in the Argo UI, as shown in the following figure.
Disable Log Service
Run the following command to delete the AliyunLogConfig:
kubectl delete aliyunlogconfigs.log.alibabacloud.com workflow-sls-config -n default
Log on to the Log Service console and delete the workflow-logstore Logstore.