1、创建configmap
vim logstash-cm.yaml
apiVersion: v1 kind: ConfigMap metadata: name: logstashconf-consul namespace: fat-s data: logstash.conf: |- input { file{ path=>["/var/log/*.log"] type=>"logstash_log" start_position =>"end" codec => "json" } } output { elasticsearch { action => "index" hosts => ["http://172.31.24.33:9200"] index => "fat-s-consul.log" } }
2、创建deployment
vim consul.yaml
apiVersion: apps/v1 kind: StatefulSet metadata: name: consul namespace: fat-s labels: k8s.eip.work/layer: consul spec: serviceName: consul replicas: 1 selector: matchLabels: app: consul template: metadata: labels: app: consul spec: nodeName: zy-nph-skg-fat-k8s-worker09 containers: - name: consul image: fat.harbor.bjshxg.com/consul/consul:1.9.5-fat-s-v3 ports: - containerPort: 8500 name: ui-port volumeMounts: - name: consul-data mountPath: "/data/app/consul" - name: consul-log mountPath: /var/log - name: logstash image: fat.harbor.bjshxg.com/elfk/logstash:7.17.1 #securityContext: # allowPrivilegeEscalation: true volumeMounts: - name: consul-log mountPath: /var/log - name: logstashconf-consul mountPath: /usr/share/logstash/pipeline/logstash.conf subPath: usr/share/logstash/pipeline/logstash.conf volumes: - name: consul-data hostPath: path: /data/app/consul type: DirectoryOrCreate - name: consul-log hostPath: path: /data/consul-log type: DirectoryOrCreate - name: logstashconf-consul configMap: name: logstashconf-consul items: - key: logstash.conf path: usr/share/logstash/pipeline/logstash.conf #- name: consul-log # emptyDir: {} --- apiVersion: v1 kind: Service metadata: name: consul labels: name: consul namespace: fat-s spec: type: NodePort ports: - name: http port: 8500 nodePort: 28500 targetPort: 8500 selector: app: consul
3、进入指定pod
kubectl exec -it consul-0 -c logstash -n fat-s bash
标签:name,consul,fat,日志,k8s,data,logstash,Sidecar,log From: https://www.cnblogs.com/linjiangCN/p/16755739.html