eSurfing Cloud CCSE Kubernetes clusters integrate with the ALS logging service. You can enable the logging service when creating a cluster to quickly collect container logs from the Kubernetes cluster, including container standard output and text files within containers.
Step 1: Enable the ALS Logging Service Component
You can enable the ALS component for an existing cluster.
Enabling ALS for an Existing Cluster
l Log in to the CCSE console.
l In the left navigation pane of the console, click on Clusters.
l In the cluster list page, click on the target cluster name.
l In the left navigation pane on the Cluster Management page, select Plug-ins > Plug-in Market, and locate ctg-log-operator in the Logging and Monitoring area.
l Click Install on the log-operator.
l In the Install Plug-in dialog box, select the plug-in version and timeout, then click Install.
Step 2: Configure Logging Service When Creating Applications
You can configure the ALS logging service while creating applications to collect container logs. Currently, applications can be created using either the console wizard or YAML.
Creating Applications and Configuring Logging Service Through Console Wizard
l Log in to the container service console.
l In the left navigation pane of the console, click on Clusters.
l In the cluster list page, click on the target cluster name.
l In the left navigation pane on the Cluster Management page, select Workload > Stateless.
l At the top of the Stateless page, you can set the namespace using the dropdown box. Click the Add button in the upper left corner.
l In the application basic information tab, configure settings such as the application name, volumes, and instance count.
The following covers only the configuration related to ALS logging service .
l Configure the logs. Click Add Log Mounting to create a new collection configuration. Each collection configuration consists of the container log paths.
n Container Log Path: You can use it to specify the paths of the logs for collection. For example, you can use /usr/local/tomcat/logs/catalina.log to collect the text logs of tomcat.
l After completing all configurations, click Next at the top right to proceed to the subsequent steps.
Creating using YAML
l Log in to the container service console.
l In the left navigation pane of the console, click on Clusters.
l In the cluster list page, click on the target cluster name.
l In the left navigation pane on the Cluster Management page, select Workload > Stateless.
l At the top of the Stateless page, select the appropriate namespace using the dropdown box. Then, click the Add YAML button in the upper left corner.
l The syntax of the YAML template is the same as the Kubernetes syntax. To specify the collection configuration for the container, you need to use env to add collection configuration and custom tag for the container, and create corresponding volumeMounts and volumns. The following is a simple pod example:
apiVersion: v1 kind: Pod metadata: name: my-demo annotations: ctyun.sls.logs: '[{"sls.capture.type":"stdout"}, {"sls.capture.type":"applog","sls.log.path":"/usr/local/tomcat/logs/catalina.log"}]' spec: containers: - name: my-demo-app image: 'registry-nm6b-crs.ctyun.com/log-service/docker-log-test:latest' ######### Configure Volume Mount ########### volumeMounts: - name: volumn-sls-mydemo mountPath: usr/local/tomcat/logs/catalina.log volumes: - name: volumn-sls-mydemo emptyDir: {} ############################### |
Step 3: View Logs
In this example, you can view logs of the tomcat application created based on the console guide. After you complete the application configuration, logs of the tomcat application are collected and stored in the ALS logging service. You can view the container logs in the CCSE console. To resume the CDN service, perform the following steps:
l After successful installation, enter the CCSE console.
l Log in to the CCSE console.
l In the left navigation pane of the console, click on Clusters.
l In the cluster list page, click on the target cluster name.
l In the left navigation pane on the Cluster Management page, select O&M Management > Log Center.
l On the log search page, you can view the standard output logs of the tomcat application and text logs in the container.