本文的环境介绍

[root@m-30-1 ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:22:21Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:10:24Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
[root@m-30-1 ~]# rpm -qf /etc/issue
centos-release-7-4.1708.el7.centos.x86_64

kubernetes集群是通过kubeadm安装的,filebeat版本为6.2.4

具体配置文件如下:

---
apiVersion: v1
kind: ConfigMap
metadata:
name: filebeat-config
labels:
k8s-app: filebeat
data:
filebeat.yml: |-
filebeat.prospectors:
- type: log
paths:
- /logdata/*.log
tail_files: true
fields:
pod_name: '${pod_name}'
POD_IP: '${POD_IP}'
output.file:
path: "/tmp/filebeat"
filename: filebeat
codec.format:
string: '%{[@timestamp]} %{[message]} pod_name %{[fields][pod_name]} %{[fields][POD_IP]}' ---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-test-config
labels:
k8s-app: nginx-test-config
data:
nginx-test-config: |-
server {
listen 80;
server_name localhost;
access_log /logdata/access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
} ---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-prod
labels:
app: nginx-log
spec:
template:
metadata:
labels:
app: nginx-log
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
protocol: TCP
resources: {}
volumeMounts:
- name: logdata
mountPath: /logdata
- name: nginx-test-config
mountPath: /etc/nginx/conf.d/
- name: filebeat
image: docker.elastic.co/beats/filebeat:6.2.4
args: [
"-c", "/opt/filebeat/filebeat.yml",
"-e",
]
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: pod_name
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
securityContext:
runAsUser: 0
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- name: config
mountPath: /opt/filebeat/
- name: data
mountPath: /usr/share/filebeat/data
- name: logdata
mountPath: /logdata
volumes:
- name: nginx-test-config
configMap:
name: nginx-test-config
items:
- key: nginx-test-config
path: test.conf
- name: logdata
emptyDir: {}
- name: config
configMap:
name: filebeat-config
items:
- key: filebeat.yml
path: filebeat.yml
- name: data
emptyDir: {}

最新文章

  1. Java异常总结
  2. 【Java 新建项目】使用程序对新项目的各个实体 创建Dao、DaoImpl、Service、ServiceImpl层的文件
  3. 走进spring之springmvc实战篇(一)
  4. 运行所有sdk目录下的示例,查看它们的功能,方便以后查寻
  5. HDU 1372 Knight Moves【BFS】
  6. 【JSF框架】 是一种标准
  7. FFT矩阵
  8. maven 启动忽略test
  9. memcpy函数的使用方法
  10. border-radius讲解2
  11. Reset and clock control (RCC) STM32L
  12. headless
  13. MFC中应用对象的成员:窗口指针m_pMainWnd说明
  14. 《PHP内核剖析 - 变量/内存管理》
  15. 终于解决了用JAVA写窗口程序在不同的windows界面下的显示保持一致。
  16. Mysql命令行tab自动补全方法
  17. AUTEL MaxiSys MS908S Pro MS908SP Diagnostic Platform
  18. Exchange ActiveSync iOS and Android User Agent Strings
  19. 数学建模-lingo使用
  20. Eclipe快捷键

热门文章

  1. python常见用法
  2. nginx+python+windows 开始_02
  3. SpringMVC 数组类型的参数: Cannot generate variable name for non-typed Collection parameter type
  4. 2Linux常用命令-Liunu就该这么学
  5. linux使用privoxy将55转为http代理
  6. 2018 pycharm最近激活码
  7. list中null或者空的区别
  8. JDBC缺点分析
  9. python安装scrapy等库需要c++ 14.0 下载链接放这里
  10. echo不换行的实现