Laborer 是一个 Kubernetes 小工具,代替我们完成一些在开发、测试时的重复动作,比如推送镜像后修改 tag,修改配置文件后重新部署等
APACHE-2.0 License
Laborer
是一个 Kubernetes
小工具,代替我们完成一些在开发、测试时的重复动作,比如推送镜像后修改 tag
,修改配置 configmap
后重新部署等.
harbor webhook image push
事件, 更新对应 deployment.container
镜像 tag
。github webhook published
事件,更新对应 deployment.container
镜像 tag
。configmap
被修改时重新部署关联的 deployment
。deployment
时将镜像 tag
修改为 harbor 中最新的 tag
。克隆代码
git clone [email protected]:arugal/laborer.git
创建 namespace
kubectl create ns laborer-system
替换镜像(可选步骤)
默认镜像为 ghcr.io/arugal/laborer/manager:latest
,如果需要使用自定义镜像,通过设置环境变量 export IMG=<image name>
替换。
安装 cert-manager
部署 controller
make deploy
启用镜像tag
更新和 configmap
变化重新部署
kubectl label ns <namespace name> laborer.enable=true
注意: 镜像 push
后更新对应 tag
依赖于镜像仓库的回掉事件,请先根据一下方法设置 webhook
Harbor Webhook URL:
http://laborer-webhook-service.laborer-system/webhook-v1alpha1-harbor-image
如果 laborer
和 harbor
部署在同一个 Kubernetes
集群内,直接使用上述地址,如果 harbor
部署在集群外,请先通过 NodePort
、Ingress
或者 LoadBalance
暴露服务
GitHub Webhook URL:
http://<ip:port>/webhook-v1alpha1-github-package
需要先将 laborer-webhook-service 的 80 端口暴露至公网。(局域网环境可使用内网穿透)
configmap
关联规则
deployment
,假设 configmap
名称为 test-config
则关联的 deployment
为 test
annotations/laborer.configmap.associate.deployment
指定的 deployment
集合设置 configmap
关联的 deployment
集合
kubectl annotate configmaps <configmap name> -n <namespace name> --overwrite laborer.configmap.associate.deployment="[<deployment array>]"
启用创建 deployment
时修改镜像 tag
kubectl label ns <namespace name> laborere.latest-tag=enabled
基于 Tag.PushTime 排序
controller
运行日志 kubectl logs -f -l app=laborer -n laborer-system