Kubernetes:每个集群或每个状态集或副本集需要完成一次的任务 [英] Kubernetes: Tasks that need to be done once per cluster or per statefulset or replicaset

查看:50
本文介绍了Kubernetes:每个集群或每个状态集或副本集需要完成一次的任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我听说了initConainers,它允许您进行应用程序容器之前的初始化.但是,我想要在集群级别或有状态集甚至整个pod上进行初始化.

So i heard about initConainers which allow you to do pre-app-container initialization. However, i want initialization which are done either at the cluster level or statefulset, or even the whole pod.

例如,我想在我的持久卷上执行一次hadoop namenode格式,并以此完成.完成之后,我的namenode statefulset和我的datanode副本集可以每次进行

For instance, I want to perform a one time hadoop namenode format on my persistent volumes and be done with that. After that is done my namenode statefulset and my datanode replicasets can proceed each time

kubernetes可以容纳任何东西吗?

Does kubernetes have anything to accommodate this?

其扩展如何?

推荐答案

Kubernetes本身提供工作用于临时执行.作业与现有Pod/Deployments/Statefulsets的集成不是很紧密.

Kubernetes itself provides Jobs for ad hoc executions. Jobs do not integrate very tightly with existing Pods/Deployments/Statefulsets.

Helm 是部署协调器,其中包括

Helm is a deployment orchestrator and includes pre and post hooks that can be used during an install or upgrade.

helm docco提供了一个Job示例通过注释.

metadata:
  annotations:
    # This is what defines this resource as a hook. Without this line, the
    # job is considered part of the release.
    "helm.sh/hook": post-install
    "helm.sh/hook-weight": "-5"
    "helm.sh/hook-delete-policy": hook-succeeded

如果您有更复杂的要求,可以对查询kubernetes API的管理器或Jobs执行相同的操作,以检查集群状态.

If you have more complex requirements you could do the same with a manager or Jobs that query the kubernetes API's to check on cluster state.

警告称头盔即将移至v3.x,在那里他们从v2重新构造了许多重大问题.如果您刚刚开始掌舵,请留意v3 beta.截至2019年8月仅是Alpha版.

A warning that helm is moving to v3.x soon where they have rearchitected away a lot of significant problems from v2. If you are just getting started with helm, keep an eye out for the v3 beta. It's only alpha as of 08/2019.

这篇关于Kubernetes:每个集群或每个状态集或副本集需要完成一次的任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆