5 Star 21 Fork 8

chuanjiao10/powershell脚本大全

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

traefik control plane written in powershell language.

项目中文名:《手搓 etcd for traefik》

手搓

想怎么搓,就怎么搓!

目的:从客户端(主控机),用powershell,经http(s)协议,读写etcd。

powershell 语言编写的 traefik 控制平面。

开源 + 免费项目

由于目前是第一版,或许bug较多,勿喷!

powershell传教士 作品

技术支持qq群:k4t国产k8s群1

qq群 号:722528388

MIT License


简介:

traefik被我喜爱的原因:跨平台,同时支持监控目录和etcd。

  • 支持win,linux版同时使用。

  • 支持etcd的同时,支持watch文件目录。而另n台traefik,可以配置为只用etcd。

很方便在win上,编辑toml文件调试。然后通过dashboard查看是否成功。

测试正常后,再向etcd中写入,以达到数据面高可用的目的。


etcd不同登录方式,对powershell版本的需求:


  • 无账户密码,但用cert,key,文件登录。k8s使用这种方式。 需要powershell 7.x,如7.4.x。 对于win7,需要安装powershell 7.2.x

https://gitee.com/chuanjiao10/powershell/tree/master/nosql/k8setcd

首先需要合并cert和私钥。在k8s的master上:

openssl pkcs12 -export \
-inkey /etc/kubernetes/pki/etcd/server.key \
-in /etc/kubernetes/pki/etcd/server.crt \
-out ./k8s.pfx

然后把【k8s.pfx】复制到任意win,linux机子上。


系统需求

  • 不依赖任何第三方dll库。

  • 支持win版powershell。

  • 支持linux版powershell。


linux下一键安装powershell:

https://gitee.com/chuanjiao10/kasini3000_agent_linux

注意:安装脚本会默认打开root账户,经过密码登录。 若不想开启,需要用此命令关闭: pwsh -f /your_path/ssh_root_passwd_login_off.ps1

For the security of the linux node, it is recommended to manually run the following command after pushing the SSH public key to close the root + password login.


问:url跳转的源ip是什么?

答: 你的linux的ip

问:url跳转的源端口是什么?

答: 取决于你运行docker时的命令行。

下面例子中,源端口就是80

docker container run -d -p 80:10000

经过ssh,远程命令行的用法:

ssh root@你的linux的ip pwsh -f /xxx.ps1 -参数名1 参数1

问:如何测试url跳转结果?

答:

  • 在linux机上,用curl测试,跳转后的结果。若通了,则下一步。若不同,则检查你的网络。

  • 在linux机上,用curl测试,跳转前的结果。

比如 192.168.1.2:80 ------> www.baidu.com:80

先在linux上curl后面的端口(百度),然后curl前面的端口。


测试版本:traefik v2.9.10 for win。原则上,linux版本一样。

问:手册在哪?

答: https://doc.traefik.io/traefik/reference/dynamic-configuration/kv/

https://doc.traefik.io/traefik/routing/providers/kv


问:如何添加上游?

答:

./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/services/baidushangyou/loadBalancer/servers/0/url' -v 'http://test1.baidu.com:443'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/services/baidushangyou/loadBalancer/servers/1/url' -v 'http://test2.baidu.com:443'

问:如何添加路由?

答:

./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/routers/my-router-https/entryPoints/0' -v 'websecure'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/routers/my-router-https/service' -v 'noop@internal'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/routers/my-router-https/rule' -v 'Host(`test223.com`) && PathPrefix(`/baidu`)'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/routers/my-router-https/middlewares/0' -v 'https-upstream'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/routers/my-router-https/tls' -v 'true'

问:如何添加默认key?

答:

./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/tls/stores/default/defaultCertificate/certFile' -v 'a:/traefik_v2.9.10/test223.cert'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/tls/stores/default/defaultCertificate/keyFile' -v 'a:/traefik_v2.9.10/test223.key'

问:如何添加中间件?

答:

./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/middlewares/https-upstream/redirectRegex/regex' -v '^https://test223.com/baidu$'
./put-etcdKey.ps1 -endpoint 'http://192.168.1.2:2379' -k 'traefik/http/middlewares/https-upstream/redirectRegex/replacement' -v 'https://www.baidu.com'

问:不知道有哪些key怎么办? 如何获得所有key?

答:

./lib/list-etcdKey.ps1 -endpoints 'http://1.2.3.4:2379'

或

./lib/list-k8sKey.ps1 -endpoints 'http://1.2.3.4:2379'

问:如何从测试etcd中读数据,并写入到生产etcd?

答:

$v = ./lib/get-etcdkey.ps1 -k 'foo' -endpoints 'http://1.2.3.4:2379'
./lib/put-etcdkey.ps1 -k 'foo' -v $v -endpoints 'http://5.6.7.8:2379'
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PowerShell
1
https://gitee.com/chuanjiao10/powershell.git
git@gitee.com:chuanjiao10/powershell.git
chuanjiao10
powershell
powershell脚本大全
master

搜索帮助