- 博客(47)
- 问答 (1)
- 收藏
- 关注
原创 linux安装autopep8使用
pip3 install autopep8/usr/local/python3/bin/autopep8 --in-place --aggressive --aggressive main.py
2022-03-15 10:44:02 2426
原创 yum/apt改源
yum源:cd /etc/yum.repos.d/cp /CentOS-Base.repo /CentOS-Base-repo.bakwget http://mirrors.aliyun.com/repo/Centos-7.repoyum clean allmv Centos-7.repo CentOS-Base.repoyum makecacheyum updateapt源:mv -f /etc/apt/sources.list /etc/apt/sources.list.ba
2022-03-10 16:55:16 1232
原创 calico网络策略
关于优先级order:为了与 Kubernetes 兼容,Calico 网络策略执行遵循 Kubernetes pod 的标准约定:如果没有网络策略适用于 Pod,则允许所有进出该 Pod 的流量。如果一个或多个网络策略应用于类型为 ingress 的 pod,则仅允许这些策略明确允许的入口流量。如果一个或多个网络策略应用于类型为 egress 的 pod,则仅允许这些策略明确允许的出口流量。对于其他端点类型(VM、主机接口),默认行为是拒绝流量。即使没有网络策略应用于端点,也只允许网
2022-03-03 15:08:48 733
原创 记一次开源PR
提示:不要懒得看英文文档,要认真看别人的贡献文档,否则会浪费更多的时间开源PR一般流程:1.远程仓库fork2.你得发现bug或有优化修改,提交到fork的仓库3.(提issue)(沟通)4.提PR5.机器审核(修改问题)6.等待人工审核(修改审核意见)注意事项:1.PR描述信息参考模板写2.commit信息包含(DCO签名)如:fixbug: 描述信息 #issue问题号Signed-off-by username <邮箱>3.CLA签名
2022-01-06 17:36:45 469 1
原创 pod网络流量限制性能测试
apiVersion: v1kind: Podmetadata: name: netperf-server annotations: kubernetes.io/egress-bandwidth: 1M kubernetes.io/ingress-bandwidth: 1Mspec: containers: - image: sirot/netperf-latest command: ["/bin/sh","-c","netserver -p 4444 -...
2022-01-04 11:24:39 824
原创 [bug]:记一个k8s client-go leaderelection的bug
环境:k8s 1.17.2申请租约后,进程异常结束没有正常释放租约leaderelection.go:308] Failed to release lock: Lease.coordination.k8s.io "go-demo" is invalid: spec.leaseDurationSeconds: Invalid value: 0: must be greater than 0源码:client-go/leaderelection.go at v0.17.2 · kuberne
2021-12-31 09:51:24 412
原创 基于scheduler framework调度插件开发踩过的坑
1. 关于调度器插件调用顺序问题:如果某个扩展点没有配置对应的扩展,调度框架将使用默认插件中的扩展如果为某个扩展点配置且激活了扩展,则调度框架将先调用默认插件的扩展,再调用配置中的扩展默认插件的扩展始终被最先调用,然后按照KubeSchedulerConfiguration中扩展的激活enabled顺序逐个调用扩展点的扩展可以先禁用默认插件的扩展,然后在enabled列表中的某个位置激活默认插件的扩展,这种做法可以改变默认插件的扩展被调用时的顺2.调度插件名称重复不会报错,可...
2021-12-21 16:31:28 480
原创 k8s-静态pod
1.kubelet 启动时由 --pod-manifest-path 指定的目录(默认/etc/kubernetes/manifests),kubelet会定期扫描这个目录,并根据这个目录下的 .yaml 或 .json 文件进行创建和更新操作。2.静态pod总是由kubelet创建的,并且只在kubelet所在的Node上运行。3. 静态pod 不能通过 api-server来管理,但是可以通过api查看4. 常用的静态pod资源:etcd kube-apiserver kube-con
2021-12-21 15:26:14 465
原创 k8s leaderelection
const ( LEASELOCKNAME = "tes" LEASELOCKNAMESPACE = "kube-system")func main () { LeaseLockID = uuid.New().String() client.InitClientSet() run := func(ctx context.Context) { // 添加运行逻辑代码 klog.Info("Controller loop...") select{}.
2021-12-16 20:55:08 653
原创 go的gin框架从请求中获取参数
type Parms struct { Weight string `json:"weight"`}func HelloWorld(ctx *gin.Context) { id := ctx.Param("id") //取得URL中参数 name := ctx.Query("name") //查询请求URL后面的参数 sex := ctx.DefaultQuery("sex", "女") .
2021-12-16 15:24:53 686
原创 k8s资源定义yaml转结构体
import ( "encoding/json" "io/ioutil" v3 "github.com/projectcalico/libcalico-go/lib/apis/v3" ffmt "gopkg.in/ffmt.v1" yaml2 "k8s.io/apimachinery/pkg/util/yaml") logrus.Printf("parse gnp yaml:%s ", fp) data, err := ioutil.ReadFile(fp) if err !=.
2021-12-14 17:16:01 533
原创 golang http
import ( "bytes" "encoding/json" "io" "io/ioutil" "net/http" "time")func Get(url string) string { client := &http.Client{Timeout: 5 * time.Second} resp, err := client.Get(url) if err != nil { panic(err) } defer resp.Body.Close() var .
2021-11-26 14:36:32 970
原创 k8s Patch
// annotation nodefunc AnnotaClusterNodes(nodeName string, annotationKey string, annotationNewValue string) error { node, err := K8sClientSet.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{}) if err != nil { return err } annotations := node.Annot.
2021-11-26 14:33:05 543
原创 k8s Informer(node)
func NodeListWatch() { fmt.Printf("Start Node List Watch...\n") restClient := K8sClientSet.CoreV1().RESTClient() watchlist := cache.NewListWatchFromClient(restClient, "nodes", k8smetav1.NamespaceAll, fields.Everything()) _, controller := cache.NewIn..
2021-11-26 14:27:56 273
原创 k8s clientset
import ( "github.com/sirupsen/logrus" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd")var ( K8sClientSet kubernetes.Interface)func InitClientSet() { // init clientset for k8s operation // if kubeconf path is empty, Using the .
2021-11-26 14:24:13 245
原创 prometheus聚合运算
修改prometheus rules configmap,增加规则:(修改后需重启prometheus)groups: - name: cpu_mem_usage_active interval: 30s rules: - record: cpu_usage_active expr: 100 - (avg by (node_name) (irate(node_cpu_seconds_total{mode="idle"}[2m])) ...
2021-11-26 14:22:20 1171
原创 prometheus pushgateway
counter := prometheus.NewCounter(prometheus.CounterOpts{ Name: name , }) if err := prometheus.Register(counter); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { // A counter for that metric has been registered before. ...
2021-11-26 14:12:37 240
原创 golang-cobra使用
Cobra提供简单的接口来创建强大的现代化CLI接口,比如git与go工具。Cobra同时也是一个程序, 用于创建CLI程序。 ▾ appName/ ▾ cmd/ root.go main.gomain.gopackage mainimport ( "fmt" "os" "{pathToYourApp}/cmd")func main() { cmd.Execute()}root.gopackage update
2021-11-17 10:10:31 365
原创 prometheus数据查询——golang
package prometheusimport ( "encoding/json" "fmt" "net/http" "net/url" "runtime/debug" "time" "gopkg.in/ffmt.v1")func GetPromResult(url string, result interface{}) error { httpClient := &http.Client{Timeout: 10 * time.Second} r, err := ..
2021-11-17 09:56:08 2752
原创 ceph常用命令
ceph -sceph -wceph healthceph osd treeceph osd pool get 【poolname】 pg_num查看pg数量ceph osd crush rule lsceph-volume inventory --format json-pretty /dev/sddceph osd getmap -o binfileceph osd statceph osd set-fulll-ratio 0.95ceph osd pool s.
2021-08-26 15:34:52 236
原创 chrony配置外部时钟源后stratum=16
ntpdate -q -u 报错:Looking for host 172.42.12.35 and service ntphost found : web.icfre.orgtransmit(172.42.12.35)receive(172.42.12.35)transmit(172.42.12.35)receive(172.42.12.35)transmit(172.42.12.35)receive(172.42.12.35)transmit(172.42.12.35)receive
2021-07-20 17:19:11 589
原创 linux vnc远程登录
安装所需软件:yum install xrdpyum install tigervnc-servervncpasswd root #设置vnc密码(可选)修改最大连接数:vim /etc/xrdp/xrdp.inimax_bpp=32 #即最大连接数32关闭防火墙systemctl stop firewalld.service设置开机不启动防火墙:systemctl disable firewalld.servie关闭SElinuxSElinux应该关闭它。查看S
2021-07-18 17:22:15 753
原创 改yum源脚本
#!/bin/sh#Please run this script as root.wget http://mirrors.aliyun.com/repo/Centos-Base.repo -O /etc/yum.repos.d/CentOS-Base.repowget http://***/your-repo.repo-O /etc/yum.repos.d/your-repo.repoyum clean all && yum makecacheyum update ..
2021-07-18 17:05:13 177
原创 创建loop设备方法
1. 创建100G大文件# dd if=/dev/zero of=/home/test.img bs=1M count=1024002.创建loop设备# losetup /dev/loop0 /home/test.img3.创建开机自动生成loop设备vim /etc/rc.d/rc.local追加:losetup /dev/loop0 /home/test.img
2021-07-02 14:06:01 847
原创 pgsql常用命令
进入数据库 pgsql -U pgsql -d test列出出数据库 \l列出表 \d切换数据库 \c test删除数据库 drop database test删除表 drop table xxx查看表详细结构 \d+查看表内容 selet * from xxx插入记录 inser into table_name(column...)value(value...)更新记录 update table_name set "colume1"='value1' "co...
2021-07-02 13:55:23 3316
原创 go build静态编译报错:/bin/ld: cannot find -ldl/-lpthread/-lc
缺少依赖库:yum install glibc-static
2021-07-02 13:44:02 922
原创 Python操作Excel和word
Python操作Excel依赖两个库:pip installxlwt pip installxlrdimport xlwt import xlrd #创建一个excel对象excel_table=xlwt.Workbook(encoding='utf-8',style_compression=0) #增加一个sheet对象Sheet_1 = excel_table.add_sheet(‘sheet1’)#写sheet_1的第i行第j列,填入内容是str...
2021-06-28 23:26:45 492
原创 centos安装fio和gfio(图形界面)
安装1. yum install gcc2. yum install libaio-devel (必须先安装,否则卸载fio后重新执行)3.从官网下载最新安装包http://freecode.com/projects/fio4.解压tar -zxvf fio-2.1.10.tar.gz5. 进入目录 cd fio-2.1.106.执行./configguremakemake install...
2021-06-28 23:25:57 3791
空空如也
python socket connect一直阻塞问题如何解决?
2021-08-13
TA创建的收藏夹 TA关注的收藏夹
TA关注的人