Repository navigation
Open
Labels
communityCommunity contributionenhancementNew feature or requestneeds triageRequires review from the maintainers
Description
How to apply dynamic labels to workflow job pods
We are running ARC v0.13.0 on K8s in containerMode: Kubernetes. Can you please inform how can we apply the below key-value pairs as labels to the workflow job pod dynamically. Just an FYI - The variables can be accessed in the workflow job as $<variable-name>. Though the variables don't appear when we exec to the workflow job pod and run env
GITHUB_REPOSITORY
GITHUB_WORKFLOW
GITHUB_JOB
RUNNER_NAME
ACTIONS_RUNNER_POD_NAME
We would like to apply the below labels so we can group resource utilization metrics while presenting in Grafana for a specific actions workflow. We can run a RunnerScaleSet instance for each repo, but this might not be feasible if the GitHub org has a few hundred repos
Tried below
- Tried applying dynamic labels through runner-container-hooks, but seems it works on applying static labels, as Kubernetes complains on rendering the dynamic labels. Please refer below:
- configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: workflow-job-hook-extension-cm
namespace: arc-poc
data:
template.yaml: |
metadata:
labels:
github-workflow: "{{ .WorkflowName }}"
spec:
containers:
- name: "$job"
resources:
requests:
cpu: 1000m
memory: 1Gi
limits:
cpu: 2000m
memory: 2Gi
- Workflow job execution gives below error:
Error: failed to create job pod: Pod "my-runners-workflow" is invalid: metadata.labels: Invalid value: "{{ .WorkflowName }}": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
Additional context
Possible solutions
- Update
runner-container-hooksas per suggestions - Though not sure if its feasible as don't see the above variables as environment variables by runningkubectl exec -it <pod> -n <namespace> -- envfor runner and workflow job pods - Use
K8s Admission Controllersas per suggestions - Though not sure if it's feasible as don't see these variables as labels or annotations in runner job pods
Reacted by Lukasz Bandzarewicz and Carter
Metadata
Metadata
Assignees
Labels
communityCommunity contributionenhancementNew feature or requestneeds triageRequires review from the maintainers
Activity
github-actions commentedon Nov 21, 2025
Hello! Thank you for filing an issue.
The maintainers will triage your issue shortly.
In the meantime, please take a look at the troubleshooting guide for bug reports.
If this is a feature request, please review our contribution guidelines.
rikeshpatel14 commentedon Nov 21, 2025
As per the below "Data Flow", hence not showing when running env (PID 1) inside runner pod:
The variables are set (please refer below), hence the suggested possible solutions should work
valenvb-ag commentedon Dec 4, 2025
We solve this with a pre-run script that the Actions runner invokes before
runner-container-hooksthat builds up our Pod template.Script looks like this:
and it modifies the "template" pod spec that looks like this
rikeshpatel14 commentedon Dec 5, 2025
@valenvb-ag - Thank you for sharing the information. Assuming the configmap
runner-templateneeds to be mounted in the runner pod template, can you please share the environment variable specific to pre-run script similar toACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE... ( or a complete runner pod template will be even better :) )valenvb-ag commentedon Dec 5, 2025
Here's what our container & volume runner template spec looks like - we just provide an
emptyDirthat the script dumps the config into, using the same var that container hooks looks for to read the pod template.mkushakov commentedon Feb 25, 2026
hey @valenvb-ag, thanks for sharing this example, i was able to mount this hook script and it is able to generate template spec with resolved values, however i still don't see annotation applied to the pod. Can you point me how can i debug it as i don't see hook logs on listeners?
I am using latest 0.13.1 controller version.
valenvb-ag commentedon Feb 25, 2026
Any logs from a pre-run script will show up in the "Set up runner" stage of a job. When we need to debug changes we usually just add a line to print out the final file. Sounds like you're seeing that it does template as you'd expect but then that's not showing up in the pod that gets created? If that's the case, there might be an issue with the template - I'd take a post-templated version and add a dummy container spec to see if I could
kubectl applyas a test to debug what's wrong with the resulting yaml.mkushakov commentedon Feb 25, 2026
Yes, pre-run script run with no issue:
As i said, it is just pod which is missing all this metadata defined in annotations: