[英]how to git clone from a private github repo in an kubernetes init container
[英]How to use environment variables in init container args in kubernetes/openshift?
这是我的部署配置的摘录:
...
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中为初始化容器正确使用环境变量?
在初始化容器中添加环境变量。
spec:
initContainers:
- args:
- clone
- '--single-branch'
- '--'
- 'https://$(GIT_USERNAME):$(GIT_PASSWORD)@someurl.com/something.git'
- '/testing/'
image: alpine/git
imagePullPolicy: Always
name: init-clone-repo
env:
- name: GIT_USERNAME
valueFrom:
secretKeyRef:
key: username
name: git
- name: GIT_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: git
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /testing
name: test-volume
volumes:
- emptyDir: {}
name: test-volume
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.