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

Missing support for agent.jar location #859

Closed
zhan9san opened this issue Aug 16, 2024 · 6 comments · Fixed by #860
Closed

Missing support for agent.jar location #859

zhan9san opened this issue Aug 16, 2024 · 6 comments · Fixed by #860

Comments

@zhan9san
Copy link
Contributor

What feature do you want to see added?

All except agent.jar location are supported to defined in environment variables.

exec $JAVA_BIN $JAVA_OPTIONS -jar /usr/share/jenkins/agent.jar $SECRET $AGENT_NAME $TUNNEL $URL $WORKDIR $WEB_SOCKET $DIRECT $PROTOCOLS $INSTANCE_IDENTITY $REMOTING_OPTS "$@"

Upstream changes

No response

Are you interested in contributing this feature?

yes

@dduportal
Copy link
Contributor

Hi @zhan9san , thanks for raising this issue. Would you be willing to make a contribution by opening a PR implementing this feature request?

@dduportal
Copy link
Contributor

Hi @zhan9san , thanks for your PR.
In this PR, you mentions the following element:

The jar file may be downloaded by the user who does not have write permission to directory, /usr/share/jenkins.

Could you describe the use case to see if further improvement could been made later (or in the documentation)?
It feels like you have a situation where you're not using the default container user, I would like to know more

@zhan9san
Copy link
Contributor Author

Thanks for your attention.

It's a long story.

Currently, we are using customized jnlp image which is based on Ubuntu, Debian or CentOS. Using label is not recommended by Kubernetes plugin. It is a historical issue that we are still using it.

jenkins-agent in this repo is used as Entrypoint in our own image.

Previously, the business-related packages and jenkins-related packages are combined in one jnlp image. Each time we upgrade Jenkins, we need to rebuild the jnlp image as well because JDK/inbound version may be not supported in original image.

There are many jnlp images for different business groups. So, I want to decouple them.


How-to

Besides jnlp container, init container is introduced in pod to manage the jenkins-related logic.

Some existing image may define non-root USER in Dockerfile, which doesn't have write permission to /usr/share/jenkins.

JDK, agent.jar and jenkins-agent are downloaded in a shared volume, like /shared in init container. Note, the agent.jar is not in the default location /usr/share/jenkins/.

The Entrypoint of jnlp would be set to /shared/jenkins-agent, and JENKINS_JAVA_BIN would be set in jnlp container in pod template.

With this feature, I'll set JENKINS_AGENT_FILE as well.

It is inspired by https://issues.jenkins.io/browse/JENKINS-64778

Hope I express myself clear.

@dduportal
Copy link
Contributor

Thanks for the clear explanation @zhan9san . I was interested by this details to see if there wasn't an additional way (documentation improvement, adding a new feature to the images, anything else) for us (maintainers) to help.

It looks like, as per your analysis, there is nothing else except delivering your contribution.
Many thanks for taking this time, I'm 100% sure it will help other users!

@zhan9san
Copy link
Contributor Author

To be exact, it is in https://github.com/zhan9san/init-jnlp/blob/main/README.md?plain=1#L58-L59

@dduportal
Copy link
Contributor

Your new feature is now available: https://hub.docker.com/r/jenkins/inbound-agent/tags?page=&page_size=&ordering=&name=3261.v9c670a_4748a_9-2%20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants