Open oleg-z opened 3 years ago
Is there a way to configure additional cloud config using helm chart in addition to default one? If not is it not a bug/limitation?
There is a way to configure additional values via JCasC.configScripts but automatically configured cloud could be incorrectly picked up when using inheritFrom functionality of kubernetes plugin.
@oleg-z What is the workaround, is this documented anywhere? And does the solution require to disable the default kubernetes cloud ?
There is no 100% work around for it. I can deploy additional clouds using JCasC.configScripts
configuration but default cloud stays configured.
The issue is this empty cloud becomes default cloud if user don't specify cloud for inheritance. See next example:
I have 2 clouds configured on my controller.
JCasC.configScripts
block, let's called 'correct-one'. This cloud contains podTemplate with name 'nonprod'User tries to run next code:
stage("Custom Agent") {
podTemplate(inheritFrom: "nonprod", containers: [agentPod]) {
...
}
Current kubernetes plugin behavior is to pick first cloud in Jenkins.instance.clouds (https://github.com/jenkinsci/kubernetes-plugin/blob/master/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java#L166). If this first cloud doesn't exist then plugins ignores inheritance and use default cloud settings. As result user gets agent which doesn't have all the settings which are supposed to be there.
Work around is to specify additional property cloud: 'correct-one'
in podTemplate.
While this workaround works it creates additional work and forces user to specify cloud name even if only one cloud is functional.
Created kubernetes plugin issue as well to resolve non deterministic behavior of plugin: https://issues.jenkins.io/browse/JENKINS-67294
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.
Is your feature request related to a problem? Please describe. Current helm chart assumes kubernetes cloud needs to be configured if deployed on kubernetes. More over cloud is configured even if agent.enabled=false
It may cause issues when additional clouds are required or cloud is configured via different method i.e. via JCasC.configScripts
Describe the solution you'd like Don't configure kubernetes cloud if agent.enabled = false or cloud: is configured as part of JCasC.configScripts (similar to https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/_helpers.tpl#L111)
Describe alternatives you've considered While I can configure cloud in a different way default cloud cause issue when using podInheritence inside of pipeline
Additional context
Example of yaml configuration: