导语:希望设计一个job,首次重启后再执行。
思路是通过判断/proc/uptime
的时间来判断是否为开机。为了确保k8s正常运行,大致设置了15分钟。因为重启之前进行下载解压安装,肯定超过半小时。等reboot之后,job的策略会再次运行。并让其他job等待这个job执行完毕,来夯住整个流程。
关键为wait-for-reboot
这个initcontainer
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: ops-verify-install-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions", "apps"]
resources: ["deployments"]
verbs: ["get", "watch", "list", "patch"]
- apiGroups: ["batch","","apps"]
resources: ["jobs"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: ops-verify-install-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: ops-verify