forked from alibaba/loongcollector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathilogtail-sidecar-file-to-sls.yaml
137 lines (135 loc) · 4 KB
/
ilogtail-sidecar-file-to-sls.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Copyright 2022 iLogtail Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# To collect file logs in container with ilogtail deployed as a sidecar container and write to SLS.
#
# You may change <sls_endpoint>, <sls_project> and <sls_logstore> according to you SLS setup.
# For a full list of parameters, visit https://ilogtail.gitbook.io/ilogtail-docs/plugins/flusher/sls
---
apiVersion: v1
kind: ConfigMap
metadata:
name: ilogtail-user-cm
namespace: default
data:
json_log.yaml: |
enable: true
inputs:
- Type: input_file
FilePaths:
- /root/log/json.log
processors:
- Type: processor_json
SourceKey: content
KeepSource: false
ExpandDepth: 1
ExpandConnector: ""
flushers:
- Type: flusher_sls
Endpoint: <sls_endpoint>
Project: <sls_project>
Logstore: <sls_logstore>
---
apiVersion: v1
kind: Secret
metadata:
name: ilogtail-secret
namespace: default
type: Opaque
data:
access_key: <base64_access_key_secret>
access_key_id: <base64_access_key_id>
---
apiVersion: batch/v1
kind: Job
metadata:
name: file-log-demo
namespace: default
spec:
template:
metadata:
labels:
k8s-app: file-log-demo
spec:
restartPolicy: Never
containers:
- name: log-demo
image: <image>
volumeMounts:
- name: file-log
mountPath: /root/log
- name: logtail
env:
- name: "ALIYUN_LOG_ENV_TAGS"
value: "_pod_name_|_pod_ip_|_namespace_|_node_name_|_node_ip_"
- name: "_pod_name_"
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: "_pod_ip_"
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: "_namespace_"
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: "_node_name_"
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: "_node_ip_"
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: default_access_key_id
valueFrom:
secretKeyRef:
name: ilogtail-secret
key: access_key_id
optional: true
- name: default_access_key
valueFrom:
secretKeyRef:
name: ilogtail-secret
key: access_key
optional: true
- name: cpu_usage_limit
value: "1"
- name: mem_usage_limit
value: "512"
image: >-
sls-opensource-registry.cn-shanghai.cr.aliyuncs.com/ilogtail-community-edition/ilogtail:latest
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 100m
memory: 512MI
requests:
cpu: 10m
memory: 30Mi
volumeMounts:
- mountPath: /usr/local/ilogtail/checkpoint
name: checkpoint
- mountPath: /usr/local/ilogtail/config/local
name: user-config
readOnly: true
volumes:
- hostPath:
path: /var/lib/ilogtail-file-log-demo/checkpoint
type: DirectoryOrCreate
name: checkpoint
- configMap:
defaultMode: 420
name: ilogtail-user-cm
name: user-config