您应该能够在作业的模板规范中包含一个环境变量列表,作为containers
定义的一部分。我不能正确地提取在OpenShift 3.6使用oc explain
的,因为它是注册的方式CronJob
资源定义,但我希望的领域是相似的:
CronJob.spec.jobTemplate.spec.template.spec.containers.env
RESOURCE: env <[]Object>
DESCRIPTION:
List of environment variables to set in the container. Cannot be updated.
EnvVar represents an environment variable present in a Container.
FIELDS:
name <string> -required-
Name of the environment variable. Must be a C_IDENTIFIER.
value <string>
Variable references $(VAR_NAME) are expanded using the previous defined
environment variables in the container and any service environment
variables. If a variable cannot be resolved, the reference in the input
string will be unchanged. The $(VAR_NAME) syntax can be escaped with a
double $$, ie: $$(VAR_NAME). Escaped references will never be expanded,
regardless of whether the variable exists or not. Defaults to "".
valueFrom <Object>
Source for the environment variable's value. Cannot be used if value is not
empty.
格雷厄姆,感谢您的答复。那么你会建议我将它添加到创建整个应用程序的初始模板(即django-ex/openshift/django.json)或稍后添加它?我以为我在过去的问题上遇到了麻烦,上面的规范在模板中是不允许的。再次感谢您的帮助。 – YoFlynn
原始模板不包含任何作业。你是否建议增加工作?如果您的应用程序已经部署,这没有帮助。如果您打算将应用程序映像用于作业,那么您将不得不使用某些技巧来让作业使用它。在这里包含您的cronjob规范,以便我可以看到它。 –
是的,我仍然在POC阶段如何让我的django应用程序从OS2 - > OS3移动,因此将它添加到应用程序模板不是问题。无法张贴评论我的代码,这在SO中并不太容易。 – YoFlynn