- 2024-05-02klog在日志文件中error级别日志重复打印2次
问题现象packagemainimport( "flag" "gopkg.in/natefinch/lumberjack.v2" "k8s.io/klog/v2")funcmain(){ klog.InitFlags(nil) flag.Set("logtostderr","false") flag.Parse() l:=&lumberjack.Logger
- 2024-02-09client-go 分析Shutdown方法耗时长原因
k8sv1.19.0Shutdown等待结束流程第1步:reflector停止list/watch第2步:Delta先进先出队列对象全部Pop业务代码处理事件场景1:Shutdown方法等待EventHandler回调方法完成klog.InitFlags(nil)flag.Parse()deferklog.Flush()cfg,err:=clientcmd.BuildConfigFromFlags(
- 2024-02-08手写实现cni插件
k8sv1.19.0mycni配置文件cat>>/etc/cni/net.d/mycni.json<<EOF{"cniVersion":"0.2.0","name":"mycni","type":"mycni"}EOFtype对应/opt/cni/bin目录下二进制文件。mycni代码并编译mkdir/run/n
- 2024-02-05client-go http trace分析耗时
klog.InitFlags(nil)flag.Parse()deferklog.Flush()cfg,err:=clientcmd.BuildConfigFromFlags("","/root/.kube/config")iferr!=nil{ klog.Fatalf("Errorbuildingkubeconfig:%s",err.Error())}kubeClient,err:=kubern
- 2024-02-04informer增加过滤标签
labelOptions:=informers.WithTweakListOptions(func(opts*metav1.ListOptions){ opts.LabelSelector="a=b"})informerFactory:=informers.NewSharedInformerFactoryWithOptions(kubeClient,0,labelOptions)hasSynced:=informerFactory.Core().V1()
- 2023-12-30限流算法
计数器在固定时间间隔内,处理请求有上限,请求超出部分丢弃。packagemainimport( "sync" "time" klog"k8s.io/klog/v2")typecounterRateLimiterstruct{ msync.Mutex startPartTimeint64 endPartTimeint64 maxCountint currCou