Kubernetes Ingress Controller Log Collection

Prepare the Environment

  1. Apply for a Kubernetes cluster on the Container Service console.
  2. Deploy the service and configure the Ingress Controller to provide services for external systems.

Import the Collected Logs to Log Service

Perform the following steps to import the collected Ingress Controller logs to Log Service:

  1. Deploy Logtail DaemonSet.
  2. Create a log project and configure a machine group.
  3. Configure LogtailConfig (log collection configurations).

Step 1: Deploy Logtail DaemonSet.

Note: Skip this step if you have deployed Logtail DaemonSet in the cluster.

curl http://logtail-release.oss-cn-hangzhou.aliyuncs.com/docker/k8s/logtail-daemonset.yaml > logtail-daemonset.yaml

# Modify the following configuration items according to your environment.
vim logtail-daemonset.yaml
value: "/etc/ilogtail/conf/${your_region_name}/ilogtail_config.json"
value: "${your_aliyun_user_id}"
value: "${your_machine_group_name}"
kubectl apply -f logtail-daemonset.yaml
daemonset "logtail" created
kubectl -n kube-system get pod | grep logtail
logtail-nbpl8 1/1 Running 0 52s
logtail-nr9hf 1/1 Running 0 52s
  1. ${your_region_name}: ID of the region where the Kubernetes cluster is located.
  2. ${your_aliyun_user_id}: Alibaba Cloud UID.
  3. ${your_machine_group_name}: custom ID for configuring a machine group.

Step 2: Create a log project and configure a machine group.

Note: Skip this step if you have created a project for collecting the Kubernetes cluster logs in the corresponding region and you plan to use this project.

Step 3: Configure LogtailConfig (log collection configurations).

Create a Logstore.

Import the Collected Logs to the Self-Built ES

This section describes how to collect Ingress Controller logs to the self-built Elasticsearch (ES). Container Service also provides an appropriate solution if you want to collect and import Kubernetes cluster pod logs to the self-built ES. For more information, see A solution to log collection problems of Kubernetes clusters by using log-pilot, Elasticsearch, and Kibana.

Step 1: Deploy log-pilot, ES, and Kibana.

Note: Skip this step if you have deployed them in the cluster.

Step 2: Perform log collection configurations.

To collect Ingress Controller logs, add the following log collection configurations:

vim nginx-ingress-controller-log-patch.yaml
- name: nginx-ingress-controller
# ingress-controller is the index name.
- name: aliyun_logs_ingress-controller
value: "stdout"

# If you deploy nginx-ingress-controller by using Deployment:
kubectl -n kube-system patch deployment nginx-ingress-controller --patch "$(cat nginx-ingress-controller-log-patch.yaml)"
# If you deploy nginx-ingress-controller by using DaemonSet:
kubectl -n kube-system patch ds nginx-ingress-controller --patch "$(cat nginx-ingress-controller-log-patch.yaml)"



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com