这是我的部署配置的摘录:
...
spec:
containers:
- env:
- name: GIT_USERNAME
valueFrom:
secretKeyRef:
key: username
name: git
- name: GIT_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: git
initContainers:
- args:
- clone
- '--single-branch'
- '--'
- 'https://$(GIT_USERNAME):$(GIT_PASSWORD)@someurl.com/something.git'
- '/testing/'
image: alpine/git
imagePullPolicy: Always
name: init-clone-repo
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /testing
name: test-volume
volumes:
- emptyDir: {}
name: test-volume
...
initContainer失败,因为 $(GIT_USERNAME)和 $(GIT_PASSWORD)照原样使用并且未扩展。我已经尝试过 $ GIT_USERNAME , $ {GIT_USERNAME} ,但我几乎没有想法。
如何在args中为初始化容器正确使用环境变量?
答案 0 :(得分:3)