Prometheus

Prometheus 简介 概念 prometheus server exporter,用于server采集数据,有官方提供的node-exporter,也可以通过各种SDK自定义导出内容,暴露一个类似/metrics的路径用于采集 注意,exporter在多进程(gunicorn 多进程)模式下使用会有限制,参考文档 数据模型,和influxdb类似,是时序数据库,以metric为名称,多个label(key-value形式)组成:<metric name>{<label name>=<label value>, ...} 重载配置 Yes, sending SIGHUP to the Prometheus process or an HTTP POST request to the /-/reload endpoint will reload and apply the configuration file. The various components attempt to handle failing changes gracefully.

May 28, 2020 · 1 min · Peter

PyCharm Docker

PyCharm 使用 Docker pycharm use docker for development and stage Development 使用windows和virtualbox,没有打开hyper-v所以无法使用docker,在虚拟机中使用docker并打开tcp,但是由于volume只能挂载宿主机,所以要先用pycharmm将文件拷贝到远程的映射目录,再使用。 此方法适合还没有准备开发环境和需要使用docker作为开发环境,但是windows本机没有docker的情况 我已使用虚拟机和pycharm远程同步功能达到同样的效果 在宿主机中开发时,可以很方便的将docker配置集成到configuration中 Stage PyCharm的docker也支持修改registry,如果有远程仓库需要的,也可以方便分发镜像

May 22, 2020 · 1 min · Peter

Django打开gzip导致文件流content-length丢失

Django打开gzip导致文件流content-length丢失 code GZipMiddleware use gzip middleware will del response['Content-Length'] if response.streaming. nginx gzip is the same problem. If file feature is important. You’d better be independent from the api or system.

May 18, 2020 · 1 min · Peter

k3s

k3s 初次使用 multipass 环境准备 quick-start 参考1 参考2 # k3s1 node for master 192.168.64.5 multipass launch -v --name k3s1 20.04 multipass shell k3s1 curl -sfL https://get.k3s.io | sh - # default config sudo cat /etc/rancher/k3s/k3s.yaml # node-token sudo cat /var/lib/rancher/k3s/server/node-token # Check for Ready node, takes maybe 30 seconds sudo kubectl get nodes # k3s2 node 192.168.64.6 multipass launch -v --name k3s2 20.04 multipass shell k3s2 # add node to cluster # token in master cat /var/lib/rancher/k3s/server/node-token # K3S_NODE_NAME for unique hostname export K3S_TOKEN=x export K3S_URL=https://192.168.1.21:6443 curl -sfL https://get.k3s.io | K3S_URL=${K3S_URL} K3S_TOKEN=${K3S_TOKEN} sh - # if not register successfully, 查看日志可能是因为之前有重复node hostname # 原因:https://github.com/rancher/k3s/issues/802 移除node没有一同移除密码 sudo vim /var/lib/rancher/k3s/server/cred/node-passwd 查看节点状态: ...

May 16, 2020 · 3 min · Peter

Multipass

multipass to set development environment 官网 指定配置 $ multipass launch --name XXX -c 2 -d 20G -m 2G 删除 $ multipass delete --purge XXXXX 问题 macos下面使用virtualbox暂时拿不到ip,只能使用NAT,最好使用hyperkit windows下面也不行,尝试添加第二个网络(gui操作 or vboxmanager),我这里使用了桥接,之后修改/etc/network/interfaces填写相关信息,重启之后查看网卡能获得ip # ubuntu 18.04 allow-hotplug enp0s8 iface enp0s8 inet static address 10.200.242.200 netmask 255.0.0.0 gateway 10.0.0.3 ubuntu20.04操作: 修改 /etc/netplan/50-cloud-init.yaml 应用 sudo netplan apply 重启 sudo reboot # ubuntu 20.04 /etc/netplan/50-cloud-init.yaml network: ethernets: enp0s3: dhcp4: true match: macaddress: 08:00:27:bc:97:36 set-name: enp0s3 version: 2 # change like following part network: ethernets: enp0s3: dhcp4: false addresses: [10.200.242.200/8] gateway4: 10.0.0.3 nameservers: addresses: [8.8.8.8, 8.8.4.4] match: macaddress: 08:00:27:bc:97:36 set-name: enp0s3 version: 2

April 23, 2020 · 1 min · Peter