【问题标题】:altering an Openshift pole automatically on deployment在部署时自动更改 Openshift 杆
【发布时间】:2017-11-23 11:01:24
【问题描述】:

我正在使用提供的 Openshift PaaS 部署 Grafana 应用映像。

我想向 Grafana 添加一个插件,它是通过将某些文件添加到文件系统或调用 grafana-cli 命令来完成的。

通过 oc CLI 访问它,我设法用单极手动完成。我不知道如何让它持久化。我希望在实例化 Openshift 杆时应用它。我发现除了为此提供自定义图像之外别无他法。

是否有支持将文件添加到现有预定义图像的方法? 或者部署后在杆上调用命令?我尝试了部署后挂钩,但文件系统似乎还不存在(或者我不知道如何使用此挂钩)

【问题讨论】:

  • 请注意:我对 Openshift 一无所知,但我假设您使用的是 Grafana docker hub 映像。您可以通过环境变量安装插件,而不是通过添加文件或运行 cli 来安装插件。请参阅 dockerhub 文档中的 Installing plugins for Grafana 3 部分:hub.docker.com/r/grafana/grafana

标签: openshift grafana


【解决方案1】:

部署后生命周期挂钩在其自己的容器中运行,具有自己的文件系统,而不是应用程序的容器。你想看看postStart 钩子。

$ oc explain dc.spec.template.spec.containers.lifecycle
RESOURCE: lifecycle <Object>

DESCRIPTION:
     Actions that the management system should take in response to container
     lifecycle events. Cannot be updated.

    Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.

FIELDS:
   postStart    <Object>
     PostStart is called immediately after a container is created. If the
     handler fails, the container is terminated and restarted according to its
     restart policy. Other management of the container blocks until the hook
     completes. More info:
     http://kubernetes.io/docs/user-guide/container-environment#hook-details

   preStop  <Object>
     PreStop is called immediately before a container is terminated. The
     container is terminated after the handler completes. The reason for
     termination is passed to the handler. Regardless of the outcome of the
     handler, the container is eventually terminated. Other management of the
     container blocks until the hook completes. More info:
     http://kubernetes.io/docs/user-guide/container-environment#hook-details

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-15
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多