Q's blog

一些个人文档笔记

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
kind: CronJob
apiVersion: batch/v1beta1
metadata:
name: hello
spec:
schedule: '* * * * *'
successfulJobsHistoryLimit: 3 #指定应保留多少已完成作业
failedJobsHistoryLimit: 1 #指定应保留多少失败作业
concurrencyPolicy: Allow
suspend: false
jobTemplate:
metadata:
creationTimestamp: null
spec:
template:
metadata:
creationTimestamp: null
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- '-c'
- date; echo Hello from the Kubernetes cluster
resources: {}
imagePullPolicy: Always
restartPolicy: OnFailure
terminationGracePeriodSeconds: 30

因业务需要,需搭建sentry前端监控,并且能承受2000qps的错误信息上报

之前已经再k8s里简单搭建过一套sentry(helm),但是版本2年前的9.1.2,太老了,所以要搭建新版本sentry(20.8.0(同事之前使用官方docker-compose启动的版版本,因为前端已经接了一点,就没用最新版本))

迁移大致规划:

image-20210510145031594
阅读全文 »

1
2
3
4
5
创建一个 admin 用户(至少一个)
# influx
Connected to http://localhost:8086 version 1.7.11
InfluxDB shell version: 1.3.2
> CREATE USER admin with PASSWORD 'admin123' WITH ALL PRIVILEGES

趋势

通过7天的数据预测30天后磁盘剩余

1
((predict_linear(node_filesystem_free_bytes{fstype=~"ext4|xfs|ext3"}[7d], 24 * 3600 * 30 )) / (1024*1024*1024)  )

1 列出待抓包的pod 及分布在哪些节点上

kubectl get pods -n ns1 -o wide | egrep myapp

阅读全文 »

方案1

openresty + lua脚本

优点:

  • openresty直接集成lua库
  • 如果nginx已支持lua,只需添加配置文件即可
阅读全文 »

文档参考:

https://alibaba.github.io/kt-connect/#/zh-cn/cli/connect

安装

1
2
3
4
5
6
7
8
9
10
# 安装pip
wget https://bootstrap.pypa.io/3.5/get-pip.py
python3 get-pip.py
# 安装sshuttle
pip install sshuttle
# 下载并安装KT
curl -OL https://rdc-incubators.oss-cn-beijing.aliyuncs.com/stable/ktctl_linux_amd64.tar.gz
tar -xzvf ktctl_linux_amd64.tar.gz
mv ktctl_linux_amd64 /usr/local/bin/ktctl
ktctl -h

使用

win

1
ktctl connect --mode tun2socks --dnsMode localDNS --shareShadow

用于使用本地服务替换集群中的Service实例。基本用法如下:

1
2
3
ktctl exchange <目标服务名> --expose <本地端口>:<目标服务端口>
ktctl -n devops exchange gva-server --expose 8888:8888 --debug
# 注意 如果有ng的话要添加 proxy_http_version 1.1; 否则接口返回内容为空

查看对端log bin日志和pos值位置

image-20210223113218710

Master配置

1
2
3
4
5
6
7
8
9
10
11
12
13
mysql>>>

GRANT REPLICATION SLAVE ON *.* TO 'replication'@'172.12.1.%' IDENTIFIED BY 'replication';

change master to
master_host='172.12.1.200',
master_user='replication',
master_password='replication',
master_log_file='mysql-bin.000001',
master_log_pos=496; #对端状态显示的值

start slave; #启动同步
show slave status \G;

slave配置

1
2
3
4
5
6
7
8
9
10
11
GRANT  REPLICATION SLAVE ON *.* TO 'replication'@'172.12.1.%' IDENTIFIED  BY 'replication';

change master to
master_host='172.12.1.100',
master_user='replication',
master_password='replication',
master_log_file='mysql-bin.000001',
master_log_pos=496; #对端状态显示的值

start slave; #启动同步
show slave status \G;

主主同步配置完毕,查看同步状态Slave_IO和Slave_SQL是YES说明主主同步成功。

1
GRANT  REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED  BY '123456';

搭建keeplived

清除slave状态

1
reset slave all;
0%