学习
使用 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

二进制部署 Thanos
· ☕ 1 分钟
1. 下载二进制文件 1 2 3 4 wget https://github.com/thanos-io/thanos/releases/download/v0.26.0/thanos-0.26.0.linux-amd64.tar.gz tar xvf thanos-0.26.0.linux-amd64.tar.gz mv thanos-0.26.0.linux-amd64/thanos /usr/bin/ rm -rf thanos-0.26.0.linux-amd64* 2. 安装 Thanos Query 1 vim /etc/systemd/system/thanos-query.service 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [Unit] Description=Thanos Query After=network-online.target [Service] Restart=on-failure ExecStart=/usr/bin/thanos query \ --log.level=debug \ --query.auto-downsampling \ --grpc-address=0.0.0.0:30091 \ --http-address=0.0.0.0:30092 \ --query.partial-response \ --query.replica-label=prometheus_replica \ --query.replica-label=rule_replica \ --store=1.0.0.0:30091 \ --store=2.0.0.0:30091 [Install] WantedBy=multi-user.target --store 参数添加需要聚合的全部源。 1 systemctl daemon-reload && systemctl enable thanos-query 1 systemctl start thanos-query && systemctl status thanos-query 3. 安装 Thanos Sidecar 1 vim /etc/systemd/system/thanos-sidecar.service 1 2 3 4 5

Thanos 进阶使用指南
· ☕ 4 分钟
1. 使用 Query 聚合数据 如上图,Thanos Query 可以对接的组件有: Thanos Store Gateway Thanos Query Thanos Receive Prometheus,借助于 Sidecar 利用 Thanos Query 之间的级联,我们可以实现跨组件的关联查询,组建超大型的监控系统。这也意味着,每个对接的组件应该提供足够快的 Prometheus API。整个接口的响应时

面向全球的镜像分发网络
· ☕ 5 分钟
1. 全球的网络规划 很多面向全球的多区域基础设施,在设计之初并没有在网络规划上花费太多心思。当业务复杂到一定程度时,又被逼着进行网络调整和优化。而任何网络上的大调整,都将对业务产生巨大影响。最终会陷入进退两难之地,只能投入更多人力,背上历史包袱

如何升级 Kubernetes 集群
· ☕ 1 分钟
升级思路是,驱逐负载、摘除流量之后,先升级控制节点,后升级工作节点。 1. 查看集群版本 1 2 3 4 kubectl version Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.4", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"clean", BuildDate:"2021-02-18T16:12:00Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.0", GitCommit:"c2b5237ccd9c0f1d600d3072634ca66cefdf272f", GitTreeState:"clean", BuildDate:"2021-08-04T17:57:25Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"} 当前版本是 1.22,由于 kubeadm 不允许跨版本升级,这里准备升级到 1.23 。 2. 添加 Kubernetes 安装源 CentOS 操作系统: 1 2 3 4 5 6 7