Expand value of podSpec patches
What does this MR do?
This MR uses the already existing feature of ExpandValue
to inject Job Variables into the PodSpec added in the runner config.
This resolve issues of interdependent environment variables not append by the strategic merge by kubernetes in the wanted order and bring a lot of possibilities for job based customisation on the pod spec.
Why was this MR needed?
This MR was needed because it isn't possible in this upstream version to use Job variables inside the patches. Examples like those ones were blocked:
Quite a lot of overwritten values are already using the expand (labels, annotation, nodeSelector...) feature which is super useful. Spec could do the same.
What's the best way to test this MR?
Changing the config of the runner and describe a pod is a good way to test the changes:
[[runners.kubernetes.pod_spec]]
name = "set-up otel for build container"
patch = '''
containers:
- name: build
env:
- name: OTEL_RESOURCE_ATTRIBUTES
value: "ci-project-name=${CI_PROJECT_NAME}"
'''
patch_type = "strategic"
Tested with GDK:
k describe pod runner-tn1chnajy-project-8-concurrent-0-5m7cj8br
Containers:
build:
Container ID: containerd://316b566892292e5498736eb145118a3a953401e825a12bf44e0ee37d55ef8b78
Image: alpine
Image ID: docker.io/library/alpine@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
Port: <none>
Host Port: <none>
Command:
sh
-c
if [ -x /usr/local/bin/bash ]; then
exec /usr/local/bin/bash
elif [ -x /usr/bin/bash ]; then
exec /usr/bin/bash
elif [ -x /bin/bash ]; then
exec /bin/bash
elif [ -x /usr/local/bin/sh ]; then
exec /usr/local/bin/sh
elif [ -x /usr/bin/sh ]; then
exec /usr/bin/sh
elif [ -x /bin/sh ]; then
exec /bin/sh
elif [ -x /busybox/sh ]; then
exec /busybox/sh
else
echo shell not found
exit 1
fi
State: Running
Started: Mon, 19 Feb 2024 00:39:10 +0100
Ready: True
Restart Count: 0
Environment:
OTEL_RESOURCE_ATTRIBUTES: ci-project-name=Typeahead.Js
FF_TEST_FEATURE: false
FF_CMD_DISABLE_DELAYED_ERROR_LEVEL_EXPANSION: false
...