Kubernetes
Istio 中的 EnvoyFilter 配置
· ☕ 3 分钟
1. EnvoyFilter 是什么 EnvoyFilter 是 Istio 的 CRD 资源,它允许用户修改 Envoy 的配置,以满足用户针对不同场景的定制需求。 1 2 3 4 5 6 7 8 9 kubectl get envoyfilter -A NAMESPACE NAME AGE istio-system add-request-id-into-ingressgateway 54d istio-system compression-gzip 18d istio-system custom-access-log 3d istio-system ingressgateway-settings 52d istio-system preserve-request-header-us-test-ingress-gateway 95d istio-system preserve-x-request-id 54d 通常在使用 istio 时,或多或少都会用到一些 EnvoyFilter。 EnvoyFilter 提供的功能是基于 Envoy 已有的内

容器下的 Go 应用程序优化
· ☕ 2 分钟
1. 内存对齐 结构体内字段,从大到小排列 减少内存占用 安装 fieldalignment 工具 1 go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest 分析并修复内存对齐 1 2 3 4 5 6 7 8 9 fieldalignment -fix ./... /Users/shaowenchen/Code/app/config/config.go:136:14: struct with 32 pointer bytes could be 24 /Users/shaowenchen/Code/app/config/config.go:150:11: struct of size 96 could be 88 /Users/shaowenchen/Code/app/config/config.go:166:14: struct of size 152 could be 144 /Users/shaowenchen/Code/app/config/config.go:194:12: struct with 80 pointer bytes could be 72 /Users/shaowenchen/Code/app/config/config.go:209:12: struct with 56 pointer bytes could be 40 /Users/shaowenchen/Code/app/dao/gormx/gorm.go:12:13: struct with 16 pointer bytes could be 8 /Users/shaowenchen/Code/app/dao/gormx/entity/cluster.go:5:14: struct with 128 pointer bytes could be 104 查看 fieldalignment 进行

从 CPU 到网络记录一次排查应用慢的过程
· ☕ 7 分钟
1. 现象 业务反馈应用 app-a 的接口慢,查看日志发现是某一个 Pod 慢,删除该 Pod 让其更换节点就好。 从监控指标可以看到,Pod 的 CPU 使用率确实有剧增。 但该 Pod 没有达到 Limit 的限制,没有被限流 CPU。 接着看节点的 CPU 监控,发现节点的 CPU 使用率也有剧增。 并且增加的部分是 System C

源码分析 Kubernetes 对 Pod IP 的管理
· ☕ 9 分钟
1. kube-controller-manager 对网段的管理 在 kube-controller-manager 有众多控制器,与 Pod IP 相关的是 NodeIpamController。 NodeIpamController 控制器主要是管理节点的 podcidr,当有新节点加入集群时,分配一个子网段给节点;当节点删除时,回收子网段。 每个节点的子网段不会重叠,每个节点都能够独立

流水线构建时,凭证作用域问题
· ☕ 2 分钟
在 client 中已经看到 Docker CLI 在给 Docker Daemon 发生构建上下文时,通过设置 X-Registry-Config 传递凭证,但在最近的构建反馈中,还是会出现一些无法解释的现象,本篇主要是进行一些基础的测试,以便于更好排查问题。 1. 宿主机 Docker 下构建 Docker Daemon 以 root 用户权限启动。 未登录任何账户 1 2 3 4 su ansible echo "FROM harbor.chenshaowen.com/private/test:v1" | sudo