博文
使用 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

海外多区下的监控系统
· ☕ 4 分钟
1. 相关背景 待在工作岗位上,总得做点事,也想做点新鲜事。但并不是你想做就有机会去做,并能做好。 一个人做、还是能和大家一起做,最终的结果是不一样的。这就涉及到时机,大家能否达成一致的动机。 今年是降本增效的一年,很多公司在裁员、减配降本。因此,对

二进制部署 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

运维与业务的系统设计差异
· ☕ 3 分钟
1. 通信协议的选择 运维系统更适合 HTTP 而非 gRpc 。 熟悉 HTTP 的运维、研发人员比其他协议的人多。在掌握 HTTP 协议的基础上,学习 Restful 风格的 HTTP API 很快。更多人熟悉、更易于学习,意味着更好沟通、更低的交接成本,因为他们有着更多共同的领域背景。 支持 HTTP 调试的工具非常多。无论

给 Kubernetes 添加 imagePullSecrets
· ☕ 1 分钟
1. 通过 kubectl create 添加 1 kubectl create secret docker-registry mypullsecret --docker-server=harbor.chenshaowen.com --docker-username=robot-test --docker-password=xxxxxx 通过 kubectl create 可以直接添加拉取镜像的凭证。 2. 通过 ~/.docker/config.json 添加 使用账户密码登录镜像仓库 1 docker login harbor.chenshaowen.com:5000 1 docker login harbor.chenshaowen.com 可以添加多个。 查看本地保存的凭证 1 2 3 4 5 6 7 8 9 10 11 12 cat ~/.docker/config.json { "auths": { "harbor.chenshaowen.com:5000": { "auth": "xxxxxx" }, "harbor.chenshaowen.com": { "auth": "xxxxxx" } } } 对凭证进行 base64 编码 1 2 3 cat ~/.docker/config.json |base64 -w