Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change prefix-name for the orchestrated pods via an environment variable/cli argument #82

Closed
prashantmishr opened this issue Mar 27, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@prashantmishr
Copy link

I am trying to apply prefix name for all the orchestrated pods by kubedock.

Referring below -

"By default, all containers will be orchestrated using kubernetes pods. If a container has been given a specific name, this will be visible in the name of the pod. If the label com.joyrex2001.kubedock.name-prefix has been set, this will be added as a prefix to the name."

Attempts Made:

  1. Setting the label com.joyrex2001.kubedock.name-prefix on the pod containing the kubedock container.
  2. Setting the environment variable "K8S_LABEL_com.joyrex2001.kubedock.name-prefix" within the kubedock container.

Observation:

Despite these attempts, the pods are still being created using the format kubedock-containerId.

What is the correct approach to ensure the prefix name is successfully applied to the pod-names?

@joyrex2001
Copy link
Owner

Currently, the label should be added on the docker container. For example, using testcontainers-java, it would be something in the line of:

GenericContainer myContainer = new GenericContainer(DockerImageName.parse(MY_CONTAINER_IMAGE))
            .withLabel("com.joyrex2001.kubedock.name-prefix","my-prefix");

See also: #36

@joyrex2001 joyrex2001 added the question Further information is requested label Mar 27, 2024
@prashantmishr
Copy link
Author

Thank you, @joyrex2001, for your response. I'm seeking a method to manage this within my pipeline template without altering the test cases directly.

Could we potentially utilize Kubernetes container environment variables within Kubedock or labels at the pod holding kubedock? My goal is to transmit the pipeline job name(or its hash) as a prefix. This way, if multiple pipeline instances are running Kubedock concurrently, we can assign distinct prefixes to the pods orchestrated by each instance.

Overall I want to make sure that we have no clashes with names of orchestrated pods when multiple pipelines are running with their own kubedock container in same namespace?
container id won't be enough in this case right? how we generate this id?

@joyrex2001
Copy link
Owner

This is not possible at the moment, but it makes sense to be able to configure this behaviour via an environment variable/cli argument as well.

@joyrex2001 joyrex2001 added enhancement New feature or request and removed question Further information is requested labels Mar 28, 2024
@joyrex2001 joyrex2001 changed the title Not able to apply prefix-name for the orchestrated pods by kubedock Change prefix-name for the orchestrated pods via an environment variable/cli argument Mar 28, 2024
@joyrex2001
Copy link
Owner

I added the environment variable POD_NAME_PREFIX and the --pod-name-prefix argument to allow configuring this gloabally.

@prashantmishr
Copy link
Author

Thanks @joyrex2001 for prompt action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants