Support for env variables expansion for image name for kubernetes executor
What does this MR do?
This MR brings the expansion of the env variables for kubernetes executor in the log files for the image name
Why was this MR needed?
This MR was needed to bring more clarity in the log files when using the kubernetes executor
What's the best way to test this MR?
To test this MR, the following steps must be followed (steps for macos)
All variables exist
gitlab-ci.yml
variables:
IMAGE_NAME: alpine
IMAGE_VERSION: latest
start_evaluation:
script:
- echo Done
config.toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Local GitLab Runner for tests and debugging"
url = "https://gitlab.com"
token = "YOUR_TOKEN_HERE"
executor = "kubernetes"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.kubernetes]
host = "CLUSTER_ADDRESS"
cert_file = "MINIKUBE_CERTIFICATE_CLIENT_FILE"
key_file = "MINIKUBE_KEY_CLIENT_FILE"
ca_file = "MINIKUBE_CERTIFICATE_AUTHORITY_FILE"
bearer_token_overwrite_allowed = false
image = "$IMAGE_NAME:$IMAGE_VERSION"
namespace = "default"
namespace_overwrite_allowed = "default"
privileged = false
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.affinity]
[runners.kubernetes.pod_security_context]
[runners.kubernetes.volumes]
[runners.kubernetes.dns_config]
Validation Prerequisites
-
Docker Desktop
installed on the machine. Click following link for the installation steps👉🏿 Install Docker Desktop -
kubectl
installed on the machine. Click following link for the installation steps👉🏿 Install KubeCtl on MacOS -
minikube
installed on the machine. Click following link for the installation steps👉🏿 Install Minikube on MacOS
Validation Step
- Start the kubernetes cluster with the command
minikube start
- Retrieve the cluster configuration with the command
kubectl config view
- Replace the
config.toml
values as follow-
CLUSTER_ADDRESS
replaced byclusters -> - cluster: -> server
value -
MINIKUBE_CERTIFICATE_CLIENT_FILE
replaced byusers -> - user: -> client-certificate
value -
MINIKUBE_KEY_CLIENT_FILE
replaced byusers -> - user: -> client-key
value -
MINIKUBE_CERTIFICATE_AUTHORITY_FILE
replaced byclusters -> - cluster: -> certificate-authority
value
-
- Run
gitlab-runner
by using theconfig.toml
- Trigger a job task from the playground project
Expected result
The log file should contain alpine:latest
instead of $IMAGE_NAME:$IMAGE_VERSION
as displayed below
Logs
At least one variable doesn't exist
gitlab-ci.yml
variables:
IMAGE_NAME: alpine
start_evaluation:
script:
- echo Done
config.toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Local GitLab Runner for tests and debugging"
url = "https://gitlab.com"
token = "YOUR_TOKEN_HERE"
executor = "kubernetes"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.kubernetes]
host = "CLUSTER_ADDRESS"
cert_file = "MINIKUBE_CERTIFICATE_CLIENT_FILE"
key_file = "MINIKUBE_KEY_CLIENT_FILE"
ca_file = "MINIKUBE_CERTIFICATE_AUTHORITY_FILE"
bearer_token_overwrite_allowed = false
image = "$IMAGE_NAME:$IMAGE_VERSION"
namespace = "default"
namespace_overwrite_allowed = "default"
privileged = false
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.affinity]
[runners.kubernetes.pod_security_context]
[runners.kubernetes.volumes]
[runners.kubernetes.dns_config]
Validation Prerequisites
As above
Validation Step
As above
Expected result
The log file should contain alpine:latest
instead of $IMAGE_NAME:$IMAGE_VERSION
as displayed below
Logs
What are the relevant issue numbers?
closes: #25875 (closed)