CronJob,django和环境变量

时间:2017-10-20 03:04:41

标签: django openshift

我已经使用django-ex模板在Openshift v3 PRO上构建了一个django应用程序。它很棒。我使用POSTGRESQL和持久存储。

我需要一个预定的cron作业来每小时触发一次django管理命令。我正在使用CronJob pod。

我的问题是:我需要使用与创建django pod相同的环境变量创建CronJob作业(DATABASE_ ,DJANGO _ 等),但不要看这是一个简单的方法。

任何帮助都会很感激。

1 个答案:

答案 0 :(得分:1)

您应该能够包含一个环境变量列表,以便在作业的模板规范中设置为containers定义的一部分。我无法在OpenShift 3.6中使用CronJob正确提取oc explain的资源定义,因为它的注册方式,但我希望该字段类似于:

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.
相关问题