-
Notifications
You must be signed in to change notification settings - Fork 47
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
Migrate Jenkins deployment from Bash to Groovy #253
base: main
Are you sure you want to change the base?
Conversation
Otherwise the gid grepper pod will keep running unnecessarily. This implementation should also be easier to migrate to groovy later. Because it is only a single command. An alternative would have been to use kubectl wait --for=condition=complete pod/tmp-docker-gid-grepper instead of until.
This makes explicit which values need to be changed per tests and otherwise relies on defaults. This way it became obvious that b38f42d (accidentally?) introduced a change that resulted in most of the Jenkins config to be only executed when config.registry.url was set.
This also implements config.jenkins.helm.values, allow for full customization of Jenkins helm deployment
* JCasC was not necessary * sidecars.configAutoReload.enabled might reduce number of Jenkins reboots (or might not be necessary at all) * Update PATH to current agent image (jenkins/inbound-agent:3261.v9c670a_4748a_9-1 as of chart 5.5.11) * Elaborate on comments
After they moved there from ApplicationConfigurator in #241
This allows for better logging. Right now, our build on Jenkins returns empty string when grepping and cutting. This lead to the insight that pretty print of the override JSON causes the gid grepper command to return empty. 🙄
c1ed4ea
to
4e6eddf
Compare
|
||
if (newConfig.application.baseUrl) { | ||
newConfig.jenkins.ingress = new URL(injectSubdomain('jenkins', | ||
newConfig.application.baseUrl as String, newConfig.application.urlSeparatorHyphen as Boolean)).host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newConfig.application.baseUrl as String, newConfig.application.urlSeparatorHyphen as Boolean)).host | |
newConfig.application.baseUrl, newConfig.application.urlSeparatorHyphen)).host |
HelmConfigWithValues helm = new HelmConfigWithValues( | ||
chart: 'jenkins', | ||
repoURL: 'https://charts.jenkins.io', | ||
version: '5.5.11') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version: '5.5.11') | |
version: '5.7.26') |
Maybe we can test and update jenkins to latest? 5.5.11(27 Aug, 2024) -> 5.7.26(22 Dec, 2024). According to the documentation, this should not be a major change. https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/CHANGELOG.md
@@ -51,96 +68,193 @@ class Jenkins extends Feature { | |||
|
|||
@Override | |||
void enable() { | |||
|
|||
if (config.jenkins.internal) { | |||
// Mark the first node for Jenkins and agents. See jenkins/values.yaml "agent.workingDir" for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Mark the first node for Jenkins and agents. See jenkins/values.yaml "agent.workingDir" for details. | |
// Mark the first node for Jenkins and agents. See jenkins/values.ftl.yaml "agent.workingDir" for details. |
} | ||
} | ||
|
||
if (!gid) { | ||
log.warn 'Unable to determine Docker Group ID (GID). Jenkins Agent pods will run as root user (UID 0)!\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps brackets would be better for the uniformity between the logging commands
} | ||
} | ||
|
||
if (!gid) { | ||
log.warn 'Unable to determine Docker Group ID (GID). Jenkins Agent pods will run as root user (UID 0)!\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.warn 'Unable to determine Docker Group ID (GID). Jenkins Agent pods will run as root user (UID 0)!\n' + | |
log.warn('Unable to determine Docker Group ID (GID). Jenkins Agent pod will run as root user (UID 0)!\n' + |
new Tuple2('jenkins-admin-password', config.jenkins.password)) | ||
|
||
def helmConfig = config.jenkins.helm | ||
def templatedMap = templateToMap(HELM_VALUES_PATH, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already rebased onto main and refactored this and the fileSystemUtils part like in the other features. This came with #251. Just for your information. So nothing to do here.
"Group docker not found in /etc/group:\n${etcGroup}" | ||
return '' | ||
} else { | ||
log.debug("Using Docker Group ID (GID) ${gid} for Jenkins Agent pods") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering if it is one or muliple pod/s here?
import org.junit.jupiter.api.Test | ||
import org.mockito.ArgumentCaptor | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@Test | ||
void 'Additional helm values are merged with default values'() { | ||
config.jenkins.helm.values = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good that you thought of this directly and implemented it straight away
Reducing the burden of our bash legacy.
This also introduces some other minor improvements
value.ftl.yaml
, no more imperative helmingvalue.ftl.yaml
Config.groovy
config.jenkins.helm.values
allows for full customization of Jenkins helm deploymentnamespace
variables in Jenkins, ScmManager and RegistryApplication.setNamespaceListToConfig()
to return redundantdefault
namespaces 🤔 which this PR fixedApplicationConfigurator
toConfig
in Typed Config for GOP #241