惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 热门话题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
V
V2EX
GbyAI
GbyAI
量子位
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
B
Blog
Microsoft Security Blog
Microsoft Security Blog
S
SegmentFault 最新的问题
O
OpenAI News
N
News and Events Feed by Topic
博客园 - Franky
爱范儿
爱范儿
Forbes - Security
Forbes - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Schneier on Security
Schneier on Security
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
Last Week in AI
Last Week in AI
罗磊的独立博客
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
The Cloudflare Blog
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
Y
Y Combinator Blog
J
Java Code Geeks
I
Intezer

陈少文的网站

巨变与机遇的未来十年 Kubernetes 平台管理软件压力测试方案 使用镜像部署 Hexo 静态页面 终于等到你 - GitHub 镜像仓库服务(ghcr.io) 一起来学 Go --(6)Interface 一起来学 Go --(5)Goroutine 和 Channel 什么是函数式编程 如何在 Kubernetes 集群集成 Kata 柯里化与偏函数 使用 PyGithub 自动创建 Label 软件产品是团队能力的输出 Helm 2 、Helm 3 比较 IoT 变现 Kubernetes 中的 DNS 服务 国内的 Helm 镜像源 Harbor 使用自签证书支持 Https 访问 DevOps 工具链之 Prow 如何使用 kfctl 安装 Kubeflow VS Code 无法下载 Go 插件的工具包 工程师更应具有服务精神 你不知道的 Docker 使用技巧 使用 Docker 运行 Tensorflow 论中国 什么是左移 如何清空 Git 仓库全部历史记录 一禅小和尚 有风吹过厨房 时间的玫瑰 如何在 CentOS 安装 GPU 驱动 开发 Tips(19) 使用 Velero 备份 Kubernetes 集群 Kubernetes Cheat Sheet 开发 Tips(18) 如何构建一个 Java 工程 开发 Tips(17) KubeSpray 安装 Kubernetes 报错 ip in ansible_all_ipv4_addresses 基于 Kubernetes 和 Jenkins 搭建自动化测试系统 在 Kubernetes 上动态创建 Jenkins Slave 使用 Jenkins 进行服务拨测 开发 Tips(16) Kubernetes 签发 Ingress 证书及日常故障运维 Kubernetes 中 Deployment 的基本操作 Kubernetes 中的证书 如何使用 KubeBuilder 开发一个 Operator Kubernetes 1.6.0 安装问题汇总 镜像管理工具 -- Harbor 开发 Tips(15) Docker 如何拉取镜像 开发 Tips(14) 使用 Helm 安装 harbor 开发 Tips(13) 使用 S2I 构建云原生应用 在 Kubernetes 中使用 emptyDir、hostPath、localVolume 开发 Tips(12) 开发 Tips(11) 代码质量分析工具 SonarQube 使用 Kubeadm 安装 Kubernetes 集群 一起来学 Go --(4)常用函数 Kubernetes 中的 Ceph Kubernetes 之 Volumes Kubernetes 之 Labels、Selectors 开发 Tips(10) 开源正在重构商业模式 Kubernetes 之网络 Kubernetes 之 API 使用 Helm 和 Operator 快速部署 Prometheus Kubernetes 复杂有状态应用管理框架 -- Operator Kubernetes 的包管理器 -- Helm 一起来学 Go --(3)Go Modules 如何一步一步地优化博客方案 kubectl 实用指南 Kubernetes 中的基本概念 搭建远程 Kubernetes 开发环境 大公司和小公司的 ToB 思路 开发 Tips(9) Go 入门指南 一起来学 Go --(2)数据与逻辑结构 如何预防 Web 富文本中的 XSS 攻击 django-xss-cleaner 云工作时代 一起来学 Go --(1)背景与特点 SaaS 开发团队的不同阶段 你不知道的 Git 使用技巧 输出既服务 微服务设计 继续奔跑 开发 Tips(8) 从账户安全到二次验证 Django 性能之数据库查询优化 Django 性能之分库分表 敏捷开发之研发流程 打造一致性的团队 开发 Tips(7) Pytest 进阶学习之 Mock PaaS 部署之 buildpack Go 开发配置 领域输出才是 PaaS 的核心竞争力 Pytest 入门学习 开发 Tips(6) 如何使用 Jenkins、Docker、GitLab 搭建 Django 自动化部署流程
Loggie 部署与配置
微信公众号 · 2026-04-14 · via 陈少文的网站

1. 下载 Chart 包

1
git clone https://github.com/loggie-io/installation

2. 安装 loggie

1
cd installation/helm-chart
1
helm install loggie ./ -nloggie --create-namespace

3. 全局配置修改

  • 移除标准输出前面的时间戳
1
kubectl -n loggie  edit cm loggie-config-loggie 

将 parseStdout 改为 true,移除标准输出前面的时间戳。

1
2
3
4
5
6
config:
  loggie:
    discovery:
      enabled: true
      kubernetes:
        parseStdout: true
  • podlogs 改成 varlog 挂载
1
kubectl -n loggie edit ds loggie
1
2
3
4
5
6
7
8
9
        volumeMounts:
        - mountPath: /var/log
          name: varlog
          readOnly: true
      volumes:
      - hostPath:
          path: /var/log
          type: DirectoryOrCreate
        name: varlog
  • 给节点级别采集加上元信息
1
kubectl -n loggie  edit cm loggie-config-loggie 
1
2
3
4
    typeNodeFields:
      nodename: "${_k8s.node.name}"
      clusterlogconfig: "${_k8s.clusterlogconfig}"
      os: "${_k8s.node.nodeInfo.osImage}"
  • pod 级别采集加上元信息
1
kubectl -n loggie  edit cm loggie-config-loggie 
1
2
3
    typePodFields:
      workloadkind: "${_k8s.workload.kind}"
      workloadname: "${_k8s.workload.name}"

4. 配置 kubelet

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
cat << 'EOF' | sudo tee /etc/systemd/system/kubelet-log.service
[Unit]
Description=Kubelet log collector
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/journalctl -u kubelet.service -f
StandardOutput=append:/var/log/kubelet.log
StandardError=inherit
LogRateLimitIntervalSec=0
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF
1
2
3
systemctl daemon-reload
systemctl enable kubelet-log.service
systemctl restart kubelet-log.service

5. 业务快速配置

  • 配置环境变量
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
export NAMESPACE=""
export ES_INDEX=""
export ES_PORT=""
export ES_HOSTS=""
export ES_USERNAME=""
export ES_PASSWORD=""
export POD_LABEL_KEY=""
export POD_LABEL_VALUE=""

ES_HOSTS_YAML=""
IFS=',' read -ra _es_host_arr <<< "${ES_HOSTS}"
for _h in "${_es_host_arr[@]}"; do
  _h="${_h#"${_h%%[![:space:]]*}"}"
  _h="${_h%"${_h##*[![:space:]]}"}"
  [[ -z "${_h}" ]] && continue
  ES_HOSTS_YAML+="        - \"http://${_h}:${ES_PORT}\""$'\n'
done
  • 配置 Sink
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
cat << EOF | kubectl apply -f -
apiVersion: loggie.io/v1beta1
kind: Sink
metadata:
  name: default
  namespace: ${NAMESPACE}
spec:
  sink: |
    type: elasticsearch
    index: "${ES_INDEX}"
    hosts: 
${ES_HOSTS_YAML}
    username: "${ES_USERNAME}"
    password: "${ES_PASSWORD}"
EOF
  • 配置 Interceptor
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
cat << EOF | kubectl apply -f -
apiVersion: loggie.io/v1beta1
kind: Interceptor
metadata:
  name: default
  namespace: ${NAMESPACE}
spec:
  interceptors: |
    - type: jsonDecode
      field: message
    - type: schema
      addMeta:
        timestamp:
          key: "@timestamp"
      remap:
        body:
          key: message
EOF
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
cat << EOF | kubectl apply -f -
apiVersion: loggie.io/v1beta1
kind: Interceptor
metadata:
  name: default
  namespace: ${NAMESPACE}
spec:
  interceptors: |
    - type: schema
      addMeta:
        timestamp:
          key: "@timestamp"
      remap:
        body:
          key: message
EOF
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
cat << EOF | kubectl apply -f -
apiVersion: loggie.io/v1beta1
kind: LogConfig
metadata:
  name: default
  namespace: ${NAMESPACE}
spec:
  selector:
    type: pod
    labelSelector:
      "${POD_LABEL_KEY}": "${POD_LABEL_VALUE}"
  pipeline:
    sources: |
      - type: file
        name: common
        paths:
          - stdout
    sinkRef: default
    interceptorRef: default
EOF

6. 参考