我正在应用Kubernetes CronJob。到目前为止它有效。现在我想添加环境变量。(env:-name ...见下文)尝试应用时出现错误
io.k8s.api.core.v1.EnvVarSource 中的未知字段“configMapRef”
我不喜欢在这里设置所有单曲变量。我更喜欢将 configmap 链接到不加倍变量。如何在 CronJob 文件中设置指向 configmap.yaml 变量的链接,如何编码?
坦率
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: ad-sync
creationTimestamp: 2019-02-15T09:10:20Z
namespace: default
selfLink: /apis/batch/v1beta1/namespaces/default/cronjobs/ad-sync
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
suspend: false
schedule: "0 */1 * * *"
jobTemplate:
metadata:
labels:
job: ad-sync
spec:
template:
spec:
containers:
- name: ad-sync
image: foo.azurecr.io/foobar/ad-sync
command: ["dotnet", "AdSyncService.dll"]
args: []
env:
- name: AdSyncService
valueFrom:
configMapRef:
name: ad-sync-service-configmap
restartPolicy: OnFailure