博文
如何查看 Tekton 的流水线指标
· ☕ 3 分钟
1. 抓取 Tekton Metrics 新增 ConfigMap 配置文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 cat <<EOF | kubectl apply -f - apiVersion: v1 kind: ConfigMap metadata: name: config-observability namespace: tekton-pipelines labels: app.kubernetes.io/instance: default app.kubernetes.io/part-of: tekton-pipelines data: metrics.backend-destination: prometheus metrics.taskrun.level: "task" metrics.taskrun.duration-type: "histogram" metrics.pipelinerun.level: "pipeline" metrics.pipelinerun.duration-type: "histogram" EOF 修改 data 中的配置,会改变上报指标的粒度,甚至会严重影响 Prometheus 的性能,需要谨慎修改。 重启 Tekton 1 kubectl -n tekton-pipelines rollout restart deployment tekton-pipelines-controller [可选] 将 tekton-pipelines-controller 设置为 NodePort

如何采集 Kubernetes 对象的 labels 和 annotations
· ☕ 2 分钟
1. 为什么需要 kube-status-metrics Kubernetes 的监控主要关注两类指标: 基础性能指标 CPU、内存、磁盘、网络等指标,可以通过 DaemonSet 部署 node-exporter,由 Prometheus 抓取相关指标。 资源对象指标 Deployment 的副本数量、Pod 的运行状态等。这些指标需要 kube-status-metrics 轮询 Kubernetes 的 API 查询,并暴露给 Prometheus 才能够看到

等价域名
· ☕ 1 分钟
1. 含义 如果一个服务有多个域名入口,通过这些入口访问得到的内容一样,那么称这些域名为等价域名。 比如,通过等价域名,可以提供 3 个一模一样的文件或者接口服务。 https://server.chenshaowen.com/static/index.html https://server-peer-a.chenshaowen.com/static/index.html https://server-peer-b.chenshaowen.com/static/index.html 2. 用途 2.1 增加浏览器并发上限 浏览器通常会限制对单个域名最大并发数量不超过 6 个/秒。通

海外多区下的流量分发
· ☕ 4 分钟
1. 关于流量分发 流量的治理分为南北向和东西向。在典型的 Network Diagrams 的绘图习惯中,核心网络组件绘制在顶部,客户端绘制在底部,不同的服务水平绘制,因此有了南北和东西流量的称呼。 其中,南北流量指的是从客户端发起的流量,东西流量指的是服务与服务之间的流量。目

使用 systemd timer 配置定时任务
· ☕ 2 分钟
1. 准备定时脚步 如果是 Bash 脚本,第一行需要指定解释器。 1 2 mkdir -p /root/scripts vim /root/scripts/quick-clear.sh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #!/bin/sh /usr/local/bin/kubectl --kubeconfig /root/.kube/config get pods --all-namespaces -o wide | grep Evicted | awk '{print $1,$2}' | xargs --no-run-if-empty -L1 /usr/local/bin/kubectl --kubeconfig /root/.kube/config delete pod -n || true /usr/local/bin/kubectl --kubeconfig /root/.kube/config get pods --all-namespaces -o wide | grep Error | awk '{print $1,$2}' | xargs --no-run-if-empty -L1 /usr/local/bin/kubectl --kubeconfig /root/.kube/config delete pod -n || true /usr/local/bin/kubectl --kubeconfig /root/.kube/config get pods --all-namespaces -o wide | grep Completed | awk '{print $1,$2}' | xargs --no-run-if-empty