k8s相关

1、yml文件

apiVersion: apps/v1

kind: StatefulSet

metadata:

name: abc

namespace: abc-q

labels:

app: abc

env: q

product-line: a

spec:

replicas: 3

serviceName: abc

selector:

matchLabels:

app: abc

template:

metadata:

labels:

app: abc

spec:

containers:

- name: abc

image: registry.cn-shanghai.aliyuncs.com/abc-q/abc:v1.0

imagePullPolicy: Always

env:

- name: run_env

value: "q"

resources:

requests:

memory: "2000Mi"

cpu: "2"

limits:

memory: "4000Mi"

cpu: "4"

volumeMounts:

- mountPath: /opt/a/abc/log-q/

name: log-volume

- mountPath: /app/application-q.properties

# name: abc-q-config

# readOnly: true

# subPath: application-s.properties

# - name: filebeat

image: registry.cn-shanghai.aliyuncs.com/filebeat:7.1.1

imagePullPolicy: Always

volumeMounts:

- mountPath: /app/logs/

name: log-volume

- mountPath: /usr/local/filebeat/filebeat.yml

name: filebeat-config

subPath: path/to/filebeat.yml

volumes:

- name: "filebeat-config"

configMap:

name: filebeat.yml

items:

- key: filebeat.yml

path: path/to/filebeat.yml

# - name: "abc-q-config"

# configMap:

# name: abc-q-config

volumeClaimTemplates:

- metadata:

name: log-volume

spec:

accessModes: [ "ReadWriteMany" ]

storageClassName: "log-nas-q"

resources:

requests:

storage: 50Gi

2、filebeat.yml

kind: ConfigMap

apiVersion: v1

metadata:

name: filebeat.yml

namespace: abc-q

data:

filebeat.yml: |

filebeat.inputs:

- type: log #Giorules

enabled: true

paths:

- /app/logs/*.log #根据项目实际路径修改目录

fields:

log_topic: abc_q #根据项目实际名称修改topic名,并告知运维

encoding: utf-8

#exclude_lines: ['^#','HEAD /favicon.ico'] #过滤不需要日志,不需要就删除此行

multiline.pattern: '^2' #以multiline开头的为多行合并设置,用于报错日志堆栈,不需要就删除此行

multiline.negate: true #以multiline开头的为多行合并设置,用于报错日志堆栈,不需要就删除此行

multiline.match: after #以multiline开头的为多行合并设置,用于报错日志堆栈,不需要就删除此行

ignore_older: 5m

close_inactive: 1m

output.kafka:

enabled: true

hosts: ["172.16.212.128:9092","172.16.212.129:9092"]

topic: '%{[fields][log_topic]}'

partition.round_robin:

reachable_only: true

worker: 2

required_acks: 1

compression: gzip

max_message_bytes: 10000000

filebeat.config.modules:

enabled: true

path: ${path.config}/modules.s/*.yml

reload.enabled: true

processors:

- add_cloud_metadata: ~

logging.files:

path: /var/log/filebeat

name: filebeat

keepfiles: 7

permissions: 0644

3、常用命令

#pods查看

kubectl --kubeconfig=accrual.kubeconfig get pods -n abc-q

#后端日志查看

kubectl --kubeconfig=accrual.kubeconfig logs -f abc-0 abc -n abc --tail=1000

#删除

kubectl --kubeconfig=accrual.kubeconfig delete -f abc.yml

#删除configmap

kubectl --kubeconfig=accrual.kubeconfig delete configmap abc-q-config -n abc-q

// 查看日志

kubectl --kubeconfig=accrual.kubeconfig logs -f abc-0 abc -n abc-q --tail=1000

// 查看挂载目录

kubectl --kubeconfig=accrual.kubeconfig get pvc -n abc-q

// 删除挂载目录

kubectl --kubeconfig=accrual.kubeconfig delete pvc -n abc-q

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值