Skip to content

Instantly share code, notes, and snippets.

View chenchun's full-sized avatar
🦖
go for{vacation()}

Chun Chen chenchun

🦖
go for{vacation()}
View GitHub Profile
@chenchun
chenchun / close_nf_conntrack.sh
Last active November 12, 2020 07:14
bash expect, close nf_conntrack
#!/usr/bin/expect -f
set node [lindex $argv 0]
set passwd [lindex $argv 1]
set timeout 30
spawn ssh root@$node
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "$passwd\r" }
}
expect "*#"
@chenchun
chenchun / connect-apiserver.md
Last active July 30, 2018 07:39
kubernetes apiserver #apiserver #k8s #kubernetes

In the diagram below you can see the full authentication flow with all options, starting with the browser on the lower left hand side.


Kubernetes                                                  Workstation
+---------------------------------------------------+     +------------------+
|                                                   |     |                  |
|  +-----------+   apiserver        +------------+  |     |  +------------+  |
|  |           |   proxy            |            |  |     |  |            |  |
|  | apiserver |                    |  ingress   |  |     |  |  ingress   |  |
@chenchun
chenchun / vxlan.sh
Last active August 21, 2019 07:29
setup unicast vxlan on two hosts
## 10.2.0.3
ip link add vxlan0 type vxlan id 2 dev eth1 dstport 8472
ip link set dev vxlan0 address 72:74:8b:9d:56:e4
ip link set dev vxlan0 up
ip ad add 192.168.50.1/24 dev vxlan0
vxlan_dev=vxlan0
peer_vxlan_mac=3e:33:f7:c5:a3:5b
peer_vxlan_ip=192.168.50.2
peer_host_ip=10.2.0.2
@chenchun
chenchun / ipint.go
Created September 16, 2016 08:03 — forked from ammario/ipint.go
Golang ip <-> int conversion
func ip2int(ip net.IP) uint32 {
if len(ip) == 16 {
return binary.BigEndian.Uint32(ip[12:16])
}
return binary.BigEndian.Uint32(ip)
}
func int2ip(nn uint32) net.IP {
ip := make(net.IP, 4)
binary.BigEndian.PutUint32(ip, nn)
主机1--路由器1--网络--路由器2--主机2
这样的组网模型中,从主机1 ping 主机2,网络通信的基本原理是怎样的?
2、路由基本原理
将整个ping包过程进行分解,步骤如下:
1)主机1发送ping包前,需要先进行arp相关操作,具体包括:
(1)检查dst ip和local ip,如果不是在同一个网段(本例就不是一个网段),则查看本地arp缓存,确认是否有网关(路由器1)IP对应的mac地址,如果没有,则向网关发送arp请求包。
(2)本地网关收到其arp包后,回复相应的mac地址。
(3)主机1收到arp回复,得到网关mac,更新相应的arp缓存。
2)主机向路由器1发送ping数据包,数据包的dst IP仍为主机2的IP,但dst MAC为路由器1的MAC。
@chenchun
chenchun / debug_ipip.md
Last active August 5, 2019 05:24
flannel vxlan ipip

debug两台机器ipip是否通

#10.59.194.141上执行下面创建的ipip0网卡:
node=10.59.194.141
peer=10.59.194.154
ip tun add ipip0 mode ipip remote $peer local $node
ip link set ipip0 up
ip add add 192.168.200.1 brd 255.255.255.255 peer 192.168.200.2 dev ipip0
ip ro add 192.168.200.0/24 via 192.168.200.1
@chenchun
chenchun / kubelet.md
Last active July 30, 2018 07:38
kubernetes kubelet component #kubernetes #kubelet

kubelet

Component

Ordered by the goroutine start time

  • eventBroadcaster
  • Watching apiserver
  • garbageCollection(containerGC/imageManager)
  • imageManager
@chenchun
chenchun / go.bash
Last active July 30, 2024 08:00
go cross compile, compile linux binary on mac osstatic compile, go memory cpu debug
go version < 1.5
cd /usr/local/go/src
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 ./make.bash --no-clean
all go version, compile your app
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -v .
env GOOS=linux GOARCH=amd64 go build -v .
@chenchun
chenchun / opentsdb.md
Last active July 1, 2016 08:14
opentsdb
rest api
http://localhost:4242/api/query?start=1466564936&m=avg:20s-max:rate:cpu_usage_total{queue=gaia_queue,user=11,appName=rami_test,instance=3}
curl 'http://localhost:4242/api/query?start=1466564936&m=avg:20s-max:rate:cpu_usage_total\{queue=root.demo,user=null,appName=rami,instanceId=1\}'
put sys.cpu.user 1356998400 1 h=w1 c=0
put sys.cpu.user 1356998401 3 h=w1 c=1
put sys.cpu.user 1356998400 5 h=w2 c=0
@chenchun
chenchun / db.md
Last active June 23, 2018 00:46
time series database, prometheus opentsdb influxdb Graphite

CAAS platform APP resource monitoring

APP resource monitoring

  • Data should be kept as long as Long time apps running
  • Data should be kept months after apps die
  • Support querying data per container
  • Support querying data per app
  • Support querying data per cluster
  • Tens of thousands of collectors
  • Load balancing multiple query engines