/logo_transparent.png

蜷缩的蜗牛

专注云原生运维

Golang热加载工具

在用 Go 和 gin 框架开发网站时,gin 缺乏实时重载的功能是令人遗憾的,修改完代码之后经常需要 ctrl + c 结束服务,重新运行 go run,影响开发效率。 Air 是为 Go 应用开发设计的另外一个热重载的命令行工具。只需在你的项目根目录下输入 air,然后把它放在一边,专注于你的代码即可

安装

1
2
3
4
5
6
7
# binary 文件会是在 $(go env GOPATH)/bin/air
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

# 或者把它安装在 ./bin/ 路径下
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s

air -v

深入Istio系列-Pilot Agent

查看监听端口和进程

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
istio-proxy@istio-ingressgateway-799bbc9474-hf7kv:/$ ss -ntlp
State           Recv-Q          Send-Q                     Local Address:Port                      Peer Address:Port          Process                                       
LISTEN          0               128                            127.0.0.1:15000                          0.0.0.0:*              users:(("envoy",pid=16,fd=18))               
LISTEN          0               128                            127.0.0.1:15004                          0.0.0.0:*              users:(("pilot-agent",pid=1,fd=15))          
LISTEN          0               128                              0.0.0.0:15021                          0.0.0.0:*              users:(("envoy",pid=16,fd=24))               
LISTEN          0               128                              0.0.0.0:15021                          0.0.0.0:*              users:(("envoy",pid=16,fd=23))               
LISTEN          0               128                              0.0.0.0:8080                           0.0.0.0:*              users:(("envoy",pid=16,fd=40))               
LISTEN          0               128                              0.0.0.0:8080                           0.0.0.0:*              users:(("envoy",pid=16,fd=39))               
LISTEN          0               128                              0.0.0.0:15090                          0.0.0.0:*              users:(("envoy",pid=16,fd=22))               
LISTEN          0               128                              0.0.0.0:15090                          0.0.0.0:*              users:(("envoy",pid=16,fd=21))               
LISTEN          0               128                                    *:15020                                *:*              users:(("pilot-agent",pid=1,fd=12))          
istio-proxy@istio-ingressgateway-799bbc9474-hf7kv:/$ ps -ef |grep pilot-agent
istio-p+     1     0  0 Sep14 ?        00:01:27 /usr/local/bin/pilot-agent proxy router --domain istio-system.svc.cluster.local --proxyLogLevel=warning --proxyComponentLogLevel=misc:error --log_output_level=default:info
istio-p+    74    30  0 09:37 pts/0    00:00:00 grep --color=auto pilot-agent

深入Ingress - Ingress Controller源码解析

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# ss -ntlp
State          Recv-Q          Send-Q                   Local Address:Port                    Peer Address:Port         Process                                                            
LISTEN         0               4096                         127.0.0.1:10245                        0.0.0.0:*             users:(("nginx-ingress-c",pid=2671,fd=8))                         
LISTEN         0               511                          127.0.0.1:10246                        0.0.0.0:*             users:(("nginx",pid=2783,fd=17),("nginx",pid=2738,fd=17))         
LISTEN         0               511                          127.0.0.1:10247                        0.0.0.0:*             users:(("nginx",pid=2783,fd=18),("nginx",pid=2738,fd=18))         
LISTEN         0               4096                           0.0.0.0:80                           0.0.0.0:*             users:(("nginx",pid=2783,fd=11),("nginx",pid=2738,fd=11))         
LISTEN         0               4096                           0.0.0.0:8181                         0.0.0.0:*             users:(("nginx",pid=2783,fd=15),("nginx",pid=2738,fd=15))         
LISTEN         0               4096                           0.0.0.0:443                          0.0.0.0:*             users:(("nginx",pid=2783,fd=13),("nginx",pid=2738,fd=13))         
LISTEN         0               4096                                 *:10254                              *:*             users:(("nginx-ingress-c",pid=2671,fd=33))                        
LISTEN         0               4096                              [::]:80                              [::]:*             users:(("nginx",pid=2783,fd=12),("nginx",pid=2738,fd=12))         
LISTEN         0               4096                              [::]:8181                            [::]:*             users:(("nginx",pid=2783,fd=16),("nginx",pid=2738,fd=16))         
LISTEN         0               4096                                 *:8443                               *:*             users:(("nginx-ingress-c",pid=2671,fd=34))                        
LISTEN         0               4096                              [::]:443                             [::]:*             users:(("nginx",pid=2783,fd=14),("nginx",pid=2738,fd=14)) 

## nginx-ingress-controller进程
# ps aux |grep -w 2671
_rpc        2671  0.4  0.2 743856 42000 ?        Ssl  Sep15   5:06 /nginx-ingress-controller --publish-service=ingress-nginx/ingress-nginx-controller --election-id=ingress-controller-leader --controller-class=k8s.io/ingress-nginx --ingress-class=nginx --configmap=ingress-nginx/ingress-nginx-controller --validating-webhook=:8443 --validating-webhook-certificate=/usr/local/certificates/cert --validating-webhook-key=/usr/local/certificates/key
root      284760  0.0  0.0   3100   812 pts/1    S+   04:15   0:00 grep -w 2671
# 

## Nginx Master 进程
# ps aux |grep -w 2738
_rpc        2738  0.0  0.2 145128 35448 ?        S    Sep15   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf
root      284662  0.0  0.0   3100   844 pts/1    S+   04:15   0:00 grep -w 2738
# 

## Nginx worker 进程
# ps aux |grep -w 2783
_rpc        2783  0.0  0.2 157240 41060 ?        Sl   Sep15   0:31 nginx: worker process
root      285147  0.0  0.0   3100   832 pts/1    S+   04:17   0:00 grep -w 2783
# 

从上面可以看出整个Ingress Nginx Controller Pod 包含两部分 nginx-ingress-controller 和 Nginx

https://raw.githubusercontent.com/kbsonlong/notes_statics/main/diagrams/ingress-nginx-controller.png

Grafana Mimir 和 VictoriaMetrics 之间的性能测试

Grafana 实验室的 Mimir 是一个在 AGPLv3 许可下新的时间序列数据库,该工程团队从 Cortex TSDB 中汲取精华,同时降低了复杂性并提高了可扩展性。

根据 Grafana 实验室的测试,Mimir 可以扩展到 10 亿个活跃时间序列和 5000 万个样本/秒的摄取率,该基准测试要求运行一个具有 7000 个 CPU 核心和 30TiB 内存的集群,这已经是我听说的最大、最昂贵的时间序列数据库的公共基准测试了。要重现这样规模的基准测试并不那么容易,幸运的是,在大多数情况下,用户的工作负荷要求要低得多,比较容易模拟。在本文我们将尝试比较 VictoriaMetricsGrafana Mimir 集群在相同硬件上的中等工作负载下运行的性能和资源使用情况。

Iptable的概念

Iptales四表五链

四表五链关系概览

raw 表mangle 表nat 表filter 表
PREROUTING 链
INPUT 链
FORWARD 链
OUTPUT 链
POSTROUTING 链

Prometheus Operator 常用指标

Prometheus Operator 安装完成后会有很多默认的监控指标,一不注意就大量的报警产生,所以我们非常有必要了解下这些常用的监控指标,有部分指标很有可能对于我们自己的业务可有可无,所以可以适当的进行修改,这里我们就来对常用的几个指标进行简单的说明。

1. Kubernetes 资源相关

1.1 CPUThrottlingHigh

关于 CPU 的 limit 合理性指标。查出最近5分钟,超过25%的 CPU 执行周期受到限制的容器。表达式:

1
2
3
4
sum(increase(container_cpu_cfs_throttled_periods_total{container!="", }[5m])) by (container, pod, namespace)
          /
sum(increase(container_cpu_cfs_periods_total{}[5m])) by (container, pod, namespace)
          > ( 25 / 100 )

相关指标:

    • container_cpu_cfs_periods_total:容器生命周期中度过的 cpu 周期总数
  • container_cpu_cfs_throttled_periods_total:容器生命周期中度过的受限的 cpu 周期总数

Istio性能指标

Istio 指标

Istio 自己的 Metrics

标准指标说明

参考:https://istio.io/latest/docs/reference/config/metrics/

Metrics

对于 HTTP、HTTP/2 和 GRPC 流量,Istio 默认生成以下指标:

  • Request Count (istio_requests_total): This is a COUNTER incremented for every request handled by an Istio proxy.
  • Request Duration (istio_request_duration_milliseconds): This is a DISTRIBUTION which measures the duration of requests.
  • Request Size (istio_request_bytes): This is a DISTRIBUTION which measures HTTP request body sizes.
  • Response Size (istio_response_bytes): This is a DISTRIBUTION which measures HTTP response body sizes.
  • gRPC Request Message Count (istio_request_messages_total): This is a COUNTER incremented for every gRPC message sent from a client.
  • gRPC Response Message Count (istio_response_messages_total): This is a COUNTER incremented for every gRPC message sent from a server.
0%