Issue
- Don’t know how to add/update Java arguments to Jenkins in CloudBees CI Modern
Environment
- CloudBees CI (CloudBees Core)
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed Master
- CloudBees CI (CloudBees Core) on modern cloud platforms - Operations Center
Resolution
In CloudBees CI on Modern Platforms, the Java Options are passed to the JVM running Jenkins via the JAVA_OPTS
Environment variable set in the Pod spec. The Pod is managed by a StatefulSet and it is therefore the StatefulSet that must be updated. When the StatefulSet is updated, the managed Pod is deleted and a new pod is created with the updated values.
- For Operations Center, the configuration is managed via Helm or manually via the
cloudbees-core.yaml
:- the Java Options must be updated in the configuration file (i.e.
values.yaml
with helm,cloudbees-core.yaml
if manually) - the configuration must be applied (i.e.
helm upgrade
with helm,kubectl apply
if manually): this will update the Operations Center StatefulSet and apply the changes made
- the Java Options must be updated in the configuration file (i.e.
- For Managed Masters, the configuration is managed by Operations Center:
- the Java Options must be updated in the Managed Master’s item configuration
- the configuration must be applied by restarting the Managed Master from Operations Center: this will recreate the Master’s StatefulSet and apply the changes made
Operation Center
The Java Options of the Operations Center must be added to the JAVA_OPTS
environment variable of the cjoc
statefulset.
With Helm
You need to add the Java arguments to the OperationsCenter.JavaOpts
attribute (e.g., --set OperationsCenter.JavaOpts
). For example:
OperationsCenter:
JavaOpts: >-
-Dhudson.slaves.NodeProvisioner.initialDelay=0
-Dhudson.DNSMultiCast.disabled=true
...
Then apply the update configuration - for example helm upgrade cloudbees-core cloudbees/cloudbees-core -f values.yaml --version 3.15.0
.
With .yaml modifications
In the cloudbees-core.yml
locate the cjoc
StatefulSet and add the argument to the existing, i.e:
...
spec:
containers:
- env:
...
- name: JAVA_OPTS
value: >-
-XshowSettings:vm
-XX:+PrintGCDetails
-Dcb.IMProp.warProfiles.cje=kubernetes.json
-Dcom.cloudbees.masterprovisioning.kubernetes.KubernetesMasterProvisioning.fsGroup=1000
-Dhudson.lifecycle=hudson.lifecycle.ExitLifecycle
-Dcom.cloudbees.jce.masterprovisioning.DockerImageDefinitionConfiguration.disableAutoConfiguration=true
-Dcom.cloudbees.jce.masterprovisioning.DockerImageDefinitionConfiguration.masterImageName="CloudBees Core - Managed Master 2.176.1.4"
-Dcom.cloudbees.jce.masterprovisioning.DockerImageDefinitionConfiguration.masterImage=cloudbees/cloudbees-core-mm:2.176.1.4
Then apply the update configuration - for example kubectl apply -f cloudbees-core.yml
.
Alternatively, you can also edit directly JAVA_OPTS
using kubectl edit statefulset/cjoc
.
Managed Masters
The Java Options of Managed Masters can be set in different ways:
- Java Options in the Managed Master configuration (per master configuration)
- System Properties in the Managed Master configuration (per master configuration)
When managing many masters, a better strategy is to configure or enforce defaults:
- Default Java Options in the Kubernetes Master Provisioning global configuration (default options for newly created masters)
- Default System Properties in the Kubernetes Master Provisioning global configuration (default system properties for newly created masters)
- Global Java Options in the Kubernetes Master Provisioning global configuration (enforced options for all provisioned masters)
Note: Java Options may contain System Properties, they are prefixed with -D
. System Properties cannot contain Java Arguments such as -XshowSettings:vm
or -XX:*
Master Java Options
Go to Operations Center Dashboard and click on Configure
on the Managed Master you want to add the Java argument.
Once here, you can add your Java arguments under Provisioning > Java Options
(separated with blank spaces, not line breaks).
Master System Properties
Go to Operations Center Dashboard and click on Configure
on the Managed Master you want to add the Java argument.
Once here, you can add your System Properties under Provisioning > System Properties
(separated with line breaks, not blank spaces). For example:
hudson.slaves.NodeProvisioner.initialDelay=0
hudson.DNSMultiCast.disabled=true
Master Default Java Options
Master Default Java Options are the default Java Options added to a Managed Master configuration when it is created. They are configurable in Operations Center.
(Note: Changes made to the Default Java Options are not reflected in the configuration of existing Managed Master)
Configure the Master Default Java Options
To configure those Default Java Options, go under Manage Jenkins > Configure System > Kubernetes Master Provisioning [Advanced] > Default Java Options.
Enforce the Master Default Java Options
To enforce those Default Java Options, add the environment variable MASTER_JAVA_OPTIONS
to the Operations Center StatefulSet. In that case the options will not be configurable from the UI.
With Helm
This is currently not supported via Helm.
With .yaml modifications
In the cloudbees-core.yml
locate the cjoc
StatefulSet and add the argument to an environment variable named MASTER_GLOBAL_JAVA_OPTIONS
, i.e:
...
spec:
containers:
- env:
- name: MASTER_JAVA_OPTIONS
value: >-
-Dhudson.slaves.NodeProvisioner.initialDelay=0
-Dhudson.DNSMultiCast.disabled=true
...
Then apply the update configuration - for example kubectl apply -f cloudbees-core.yml
.
Master Default System Properties
Master Default System Properties are the default System Properties added to a Managed Master configuration when it is created. They are configurable in Operations Center.
To configure those Default System Properties Options, go under Manage Jenkins > Configure System > Kubernetes Master Provisioning [Advanced] > Default System Properties.
(Note: Changes made to the Default System Properties are not reflected in the configuration of existing Managed Master)
Master Global Java Options
Master Global Java Options are Java options that are enforcibly added to every Managed Master deployment and not configurable from the UI. Those Java Options are automatically appended to the Managed Master’s JAVA_OPTS
environment variable during provisioning. They are enforced to all managed masters and not configurable from the UI.
(Note: Changes made to the Global Java Options are reflected to every Managed Master when re-provisioned)
Configure the Master Global Java Options
To configure those Global Java Options, go under Manage Jenkins > Configure System > Kubernetes Master Provisioning [Advanced] > Global Java Options.
Enforce the Master Global Java Options
To enforce those Global Java Options, add the environment variable MASTER_GLOBAL_JAVA_OPTIONS
to the Operations Center StatefulSet. In that case the options will not be configurable from the UI.
With Helm
You need to add the Java arguments to the Master.JavaOpts
attribute (e.g., --set Master.JavaOpts
). For example:
Master:
JavaOpts: >-
-Dhudson.slaves.NodeProvisioner.initialDelay=0
-Dhudson.DNSMultiCast.disabled=true
...
Then apply the update configuration - for example helm upgrade cloudbees-core cloudbees/cloudbees-core -f values.yaml --version 3.15.0
.
With .yaml modifications
In the cloudbees-core.yml
locate the cjoc
StatefulSet and add the argument to an environment variable named MASTER_GLOBAL_JAVA_OPTIONS
, i.e:
...
spec:
containers:
- env:
- name: MASTER_GLOBAL_JAVA_OPTIONS
value: >-
-Dhudson.slaves.NodeProvisioner.initialDelay=0
-Dhudson.DNSMultiCast.disabled=true
...
Then apply the update configuration - for example kubectl apply -f cloudbees-core.yml
.
0 Comments