简体   繁体   English

将环境变量添加到OpenShift中已部署的应用程序中

[英]Adding environment variables to already deployed application in OpenShift

I currently have a process in place to build and deploy our application to OpenShift utilizing the Jenkins OpenShift plugin via the commands below: 我目前有一个使用Jenkins OpenShift插件通过以下命令将应用程序构建和部署到OpenShift的过程:

openshift.newBuild("--image-stream=${builderImageName}", "--binary=true", "-n ${projectName}", "--to=${applicationName}:${targetEnv}")
openshift.startBuild("${applicationName}", "--from-dir=.", "--wait=true", "-n ${projectName}")
openshift.newApp("-n ${projectName}", "--template=${templateName}", "--param-file=${appDeployConfigFileName}", "--env-file=${appEnvFileName}")

This works as intended. 这按预期工作。 My question is once the app has been deployed how can I update the env variables if additional ones need to be added? 我的问题是,一旦部署了应用程序,如果需要添加其他变量,如何更新环境变量? I basically want to duplicate the functionality of going through the ui and adding env variables. 我基本上想复制通过ui和添加env变量的功能。 However I would want to do this using the openshift plugin or oc tool and use a file of variables not just a set of key values. 但是,我想使用openshift插件或oc工具来执行此操作,并使用变量文件而不只是一组键值。

您将需要为您的应用程序更新部署配置

oc set env dc/<your_app> MYVAR=foo -n <project_name>

If you're trying to store environment variables in SCM with a builder image (w/ S2I aka source-to-image enabled container image), use an environment file .s2i/environment . 如果您尝试将环境变量与构建器映像(带有S2I或启用了源到映像的容器映像)存储在SCM中,请使用环境文件.s2i/environment

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM