构建与调试 Linux 内核

Linux Kenrel

1
2
wget http://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v4.x/linux-4.19.171.tar.gz
tar -xvf linux-4.19.171.tar.gz

Install Build

1
apt-get install -y libncurses5-dev libssl-dev bison flex libelf-dev gcc make openssl libc6-dev bc

CP Old Config

1
2
3
4
cp /boot/config-4.19.0-14-amd64 .config
make oldconfig
# for debian
sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' .config

Read More

Proxy

shadowsocks 代理

1
docker run -dt --name ss -p 6443:6443 mritd/shadowsocks -s "-s 0.0.0.0 -p 6443 -m aes-256-cfb -k Dangerous@123"

参考 README

Socket 5 代理

1
docker run -d --name socket5-proxy -p 80:1080 -e PROXY_USER=root  -e PROXY_PASSWORD=Dangerous@123 serjs/go-socks5-proxy

Read More

Tips

自定义指标前缀

istio 没有将所有的配置项都释放出来,因此我们可以通过 EnvoyFilter 这个 CRD 进行操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
kind: EnvoyFilter
apiVersion: networking.istio.io/v1alpha3
metadata:
annotations:
name: mysql-stats-settings
namespace: wordpress
spec:
configPatches:
- applyTo: NETWORK_FILTER
match:
context: ANY
listener:
filterChain:
filter:
name: envoy.filters.network.mysql_proxy
patch:
operation: MERGE
value:
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.network.mysql_proxy.v3.MySQLProxy"
stat_prefix: egress_mysql

Envoy 指标对外暴露

istio 没有将所有的指标对外暴露,因此需要额外配置: envoy-stats

1
$ kubectl edit configmaps -n istio-system istio

Read More

Gist

为Kube Object增加Type信息

因为 Client-GO 返回的 TypeMeta 永远为 Null,因此需要自己添加

addTypeInformationToObjectsource_code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
func addTypeInformationToObject(obj runtime.Object) error {
gvks, _, err := scheme.Scheme.ObjectKinds(obj)
if err != nil {
return fmt.Errorf("missing apiVersion or kind and cannot assign it; %w", err)
}

for _, gvk := range gvks {
if len(gvk.Kind) == 0 {
continue
}
if len(gvk.Version) == 0 || gvk.Version == runtime.APIVersionInternal {
continue
}
obj.GetObjectKind().SetGroupVersionKind(gvk)
break
}

return nil
}

搭建 Istio 开发测试环境

Pilot Discovery

构建

1
2
3
4
5
6

# 下载,检出版本
git clone https://github.com/istio/istio.git && cd istio && git checkout <YOUR_WANT_ISTIO>

# 构建
go build pilot/cmd/pilot-discovery

运行

为了让我们在本地开发测试 Pilot,首先准备好 kube-config

启动 poilot

1
pilot-discovery discovery --kubeconfig ~/.kube/config <默认配置>

Read More