Helm中从values.yaml传镜像列表至Job并批量触发的技术问询
1. Is the approach of passing Docker images & tags as an array correct?
Absolutely, this is a clean, maintainable approach for managing multiple image-tag pairs. Storing them in an array (list) in values.yaml keeps your configuration organized—you can easily add/remove entries without touching the core Job template, and it’s intuitive to map which images correspond to which tags.
A small optional improvement: if all these images share the same registry (like reldocker.tibco.com/stratosphere/), you could add a top-level imageRegistry field to values.yaml to avoid repeating the registry path in every entry. But even without that, your current structure is perfectly valid for this use case.
2. How to replace placeholders in deployment.yaml and trigger a Job per image-tag pair?
To create a separate Job for each image-tag combination, you’ll need a templating tool (Helm is the most common choice here) to loop through your contributions_list and generate a unique Job resource for each entry. Here’s a step-by-step solution:
Step 1: Modify your Job template (rename to job-template.yaml for clarity)
Update the template to use Helm’s range function to iterate over your image list. Ensure each Job has a unique name to avoid conflicts:
{{- range .Values.contributions_list }} apiVersion: batch/v1 kind: Job metadata: name: container-image-extractor-{{ .image }} namespace: local-tibco-tci labels: app.cloud.tibco.com/name: container-image-extractor app.cloud.tibco.com/image: {{ .image }} spec: backoffLimit: 0 template: metadata: labels: app.cloud.tibco.com/name: container-image-extractor app.cloud.tibco.com/image: {{ .image }} spec: nodeSelector: kubernetes.io/os: linux restartPolicy: Never containers: - name: container-image-extractor image: reldocker.tibco.com/stratosphere/container-image-extractor imagePullPolicy: IfNotPresent env: - name: SOURCE_DOCKER_IMAGE value: "{{ .image }}:{{ .tag }}" {{- end }}
Step 2: Deploy with Helm
- Set up a standard Helm chart structure (place the template in a
templates/folder alongside yourvalues.yaml). - Run
helm template .first to preview the generated Job resources—you’ll see one unique Job per image in your list. - Deploy to your cluster with:
helm install image-extractor-jobs . --namespace local-tibco-tci
Alternative: If Helm isn’t an option
If you don’t want to use Helm, you could write a small script (in Python/Bash) to loop through your values.yaml and generate individual Job YAML files, or use Kustomize with a resource generator. But Helm is purpose-built for this kind of templating and will be the most straightforward solution.
内容的提问来源于stack exchange,提问作者Rajiv Rai

