[stable/jenkins] add master.JCasC.defaultConfig (#16929)

* add master.JCasC.defaultConfig and configure location

- JCasC configuration is stored in template `jenkins.casc.defaults`
  so that it can be used in `config.yaml` and `jcasc-config.yaml`
  depending on if configAutoReload is enabled or not

- Jenkins Location (URL) is configured to provide a startin point
  for the config

Signed-off-by: Torsten Walter <mail@torstenwalter.de>

* improve JCasC default configuration

JCasC default configuration includes:
  - Jenkins url
  - disableRememberMe: false
  - mode: NORMAL
  - numExecutors: {{ .Values.master.numExecutors }}
  - projectNamingStrategy: "standard"

Signed-off-by: Torsten Walter <mail@torstenwalter.de>

* JCasC kubernetes config

Signed-off-by: Torsten Walter <mail@torstenwalter.de>

* JCasC: crumbIssue and security.apiToken

Signed-off-by: Torsten Walter <mail@torstenwalter.de>
This commit is contained in:
Torsten Walter
2019-09-15 00:12:38 -07:00
committed by Kubernetes Prow Robot
parent 5e151c2665
commit 0abb43f319
7 changed files with 192 additions and 3 deletions
+75
View File
@@ -6,6 +6,81 @@ numbering uses [semantic versioning](http://semver.org).
NOTE: The change log until version 1.5.7 is auto generated based on git commits. Those include a reference to the git commit to be able to get more details.
## 1.7.0
[Jenkins Configuration as Code Plugin](https://github.com/jenkinsci/configuration-as-code-plugin) default configuration can now be enabled via `master.JCasC.defaultConfig`.
JCasC default configuration includes:
- Jenkins url
- Admin email `master.jenkinsAdminEmail`
- crumbIssuer
- disableRememberMe: false
- mode: NORMAL
- numExecutors: {{ .Values.master.numExecutors }}
- projectNamingStrategy: "standard"
- kubernetes plugin
- containerCapStr via `agent.containerCap`
- jenkinsTunnel
- jenkinsUrl
- maxRequestsPerHostStr: "32"
- name: "kubernetes"
- namespace
- serverUrl: "https://kubernetes.default"
- template
- containers
- alwaysPullImage: `agent.alwaysPullImage`
- args
- command
- envVars
- image: `agent.image:agent.imageTag`
- name: `.agent.sideContainerName`
- privileged: `.agent.privileged`
- resourceLimitCpu: `agent.resources.limits.cpu`
- resourceLimitMemory: `agent.resources.limits.memory`
- resourceRequestCpu: `agent.resources.requests.cpu`
- resourceRequestMemory: `agent.resources.requests.memory`
- ttyEnabled: `agent.TTYEnabled`
- workingDir: "/home/jenkins"
- idleMinutes: `agent.idleMinutes`
- instanceCap: 2147483647
- imagePullSecrets:
- name: `.agent.imagePullSecretName`
- label
- name
- nodeUsageMode: "NORMAL"
- podRetention: `agent.podRetention`
- serviceAccount
- showRawYaml: true
- slaveConnectTimeoutStr: "100"
- yaml: `agent.yamlTemplate`
- yamlMergeStrategy: "override"
- security:
- apiToken:
- creationOfLegacyTokenEnabled: false
- tokenGenerationOnCreationEnabled: false
- usageStatisticsEnabled: true
Example `values.yaml` which enables JCasC, it's default config and configAutoReload:
```
master:
JCasC:
enabled: true
defaultConfig: true
sidecars:
configAutoReload:
enabled: true
```
add master.JCasC.defaultConfig and configure location
- JCasC configuration is stored in template `jenkins.casc.defaults`
so that it can be used in `config.yaml` and `jcasc-config.yaml`
depending on if configAutoReload is enabled or not
- Jenkins Location (URL) is configured to provide a startin point
for the config
## 1.6.1
Print error message when `master.sidecars.configAutoReload.enabled` is `true`, but the admin user can't be found to configure the SSH key.
+1 -1
View File
@@ -1,7 +1,7 @@
apiVersion: v1
name: jenkins
home: https://jenkins.io/
version: 1.6.1
version: 1.7.0
appVersion: lts
description: Open source continuous integration server. It supports multiple SCM tools
including CVS, Subversion and Git. It can execute Apache Ant and Apache Maven-based
+2 -1
View File
@@ -131,7 +131,8 @@ The following tables list the configurable parameters of the Jenkins chart and t
| `master.route.path` | Route path | Not set |
| `master.jenkinsUrlProtocol` | Set protocol for JenkinsLocationConfiguration.xml | Set to `https` if `Master.ingress.tls`, `http` otherwise |
| `master.JCasC.enabled` | Wheter Jenkins Configuration as Code is enabled or not | `false` |
| `master.JCasC.configScripts` | List of Jenkins Config as Code scripts | False |
| `master.JCasC.defaultConfig` | Enables default Jenkins configuration via configuration as code plugin | `false` |
| `master.JCasC.configScripts` | List of Jenkins Config as Code scripts | |
| `master.enableXmlConfig` | enables configuration done via XML files | `false` |
| `master.sidecars.configAutoReload` | Jenkins Config as Code auto-reload settings | |
| `master.sidecars.configAutoReload.enabled` | Jenkins Config as Code auto-reload settings (Attention: rbac needs to be enabled otherwise the sidecar can't read the config map) | `false` |
+90
View File
@@ -67,6 +67,96 @@ Returns the Jenkins URL
{{- end}}
{{- end -}}
{{/*
Returns configuration as code default config
*/}}
{{- define "jenkins.casc.defaults" -}}
jenkins:
disableRememberMe: false
mode: NORMAL
numExecutors: {{ .Values.master.numExecutors }}
projectNamingStrategy: "standard"
markupFormatter:
{{- if .Values.master.enableRawHtmlMarkupFormatter }}
rawHtml:
disableSyntaxHighlighting: true
{{- else }}
"plainText"
{{- end }}
clouds:
- kubernetes:
containerCapStr: "{{ .Values.agent.containerCap }}"
{{- if .Values.master.slaveKubernetesNamespace }}
jenkinsTunnel: "{{ template "jenkins.fullname" . }}-agent.{{ template "jenkins.namespace" . }}:{{ .Values.master.slaveListenerPort }}"
jenkinsUrl: "http://{{ template "jenkins.fullname" . }}.{{ template "jenkins.namespace" . }}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}"
{{- else }}
jenkinsTunnel: "{{ template "jenkins.fullname" . }}-agent:{{ .Values.master.slaveListenerPort }}"
jenkinsUrl: "http://{{ template "jenkins.fullname" . }}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}"
{{- end }}
maxRequestsPerHostStr: "32"
name: "kubernetes"
namespace: "{{ template "jenkins.master.slaveKubernetesNamespace" . }}"
serverUrl: "https://kubernetes.default"
{{- if .Values.agent.enabled }}
templates:
- containers:
- alwaysPullImage: {{ .Values.agent.alwaysPullImage }}
{{- if .Values.agent.args }}
args: "{{ .Values.agent.args }}"
{{- else }}
args: "^${computer.jnlpmac} ^${computer.name}"
{{- end }}
command: {{ .Values.agent.command }}
envVars:
- containerEnvVar:
key: "JENKINS_URL"
value: "http://{{ template "jenkins.fullname" . }}.{{ template "jenkins.namespace" . }}.svc.{{.Values.clusterZone}}:{{.Values.master.servicePort}}{{ default "" .Values.master.jenkinsUriPrefix }}"
{{- if .Values.agent.imageTag }}
image: "{{ .Values.agent.image }}:{{ .Values.agent.imageTag }}"
{{- else }}
image: "{{ .Values.agent.image }}:{{ .Values.agent.tag }}"
{{- end }}
name: "{{ .Values.agent.sideContainerName }}"
privileged: "{{- if .Values.agent.privileged }}true{{- else }}false{{- end }}"
resourceLimitCpu: {{.Values.agent.resources.limits.cpu}}
resourceLimitMemory: {{.Values.agent.resources.limits.memory}}
resourceRequestCpu: {{.Values.agent.resources.requests.cpu}}
resourceRequestMemory: {{.Values.agent.resources.requests.memory}}
ttyEnabled: {{ .Values.agent.TTYEnabled }}
workingDir: "/home/jenkins"
idleMinutes: {{ .Values.agent.idleMinutes }}
instanceCap: 2147483647
{{- if .Values.agent.imagePullSecretName }}
imagePullSecrets:
- name: {{ .Values.agent.imagePullSecretName }}
{{- end }}
label: "{{ .Release.Name }}-{{ .Values.agent.componentName }} {{ .Values.agent.customJenkinsLabels | join " " }}"
name: "{{ .Values.agent.podName }}"
nodeUsageMode: "NORMAL"
podRetention: {{ .Values.agent.podRetention }}
showRawYaml: true
serviceAccount: "{{ include "jenkins.serviceAccountAgentName" . }}"
slaveConnectTimeoutStr: "100"
yaml: |-
{{ tpl .Values.agent.yamlTemplate . | nindent 10 | trim }}
yamlMergeStrategy: "override"
{{- end }}
{{- if .Values.master.csrf.defaultCrumbIssuer.enabled }}
crumbIssuer:
standard:
excludeClientIPFromCrumb: {{ if .Values.master.csrf.defaultCrumbIssuer.proxyCompatability }}true{{ else }}false{{- end }}
{{- end }}
security:
apiToken:
creationOfLegacyTokenEnabled: false
tokenGenerationOnCreationEnabled: false
usageStatisticsEnabled: true
unclassified:
location:
adminAddress: {{ default "" .Values.master.jenkinsAdminEmail }}
url: {{ template "jenkins.url" . }}
{{- end -}}
{{- define "jenkins.kubernetes-version" -}}
{{- if .Values.master.installPlugins -}}
{{- range .Values.master.installPlugins -}}
+4
View File
@@ -313,6 +313,10 @@ data:
}
{{- else }}
# Only add config to this script if we aren't auto-reloading otherwise the pod will restart upon each config change:
{{- if .Values.master.JCasC.defaultConfig }}
jcasc-default-config.yaml: |-
{{- include "jenkins.casc.defaults" . |nindent 4}}
{{- end }}
{{- range $key, $val := .Values.master.JCasC.configScripts }}
{{ $key }}.yaml: |-
{{ tpl $val $| indent 4 }}
@@ -18,4 +18,22 @@ data:
{{ $key }}.yaml: |-
{{ tpl $val $| indent 4 }}
{{- end }}
{{- if .Values.master.JCasC.defaultConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "jenkins.fullname" $root }}-jenkins-jcasc-config
namespace: {{ template "jenkins.namespace" $root }}
labels:
"app.kubernetes.io/name": {{ template "jenkins.name" $root}}
"helm.sh/chart": {{ $.Chart.Name }}-{{ $.Chart.Version }}
"app.kubernetes.io/managed-by": "{{ $.Release.Service }}"
"app.kubernetes.io/instance": "{{ $.Release.Name }}"
"app.kubernetes.io/component": "{{ $.Values.master.componentName }}"
{{ template "jenkins.fullname" $root }}-jenkins-config: "true"
data:
jcasc-default-config.yaml: |-
{{- include "jenkins.casc.defaults" . |nindent 4 }}
{{- end}}
{{- end }}
+2 -1
View File
@@ -200,6 +200,7 @@ master:
# etc. Best reference is https://<jenkins_url>/configuration-as-code/reference. The example below creates a welcome message:
JCasC:
enabled: false
defaultConfig: false
pluginVersion: "1.27"
# it's only used when plugin version is <=1.18 for later version the
# configuration as code support plugin is no longer needed
@@ -409,7 +410,7 @@ agent:
# Raw yaml template for the Pod. For example this allows usage of toleration for agent pods.
# https://github.com/jenkinsci/kubernetes-plugin#using-yaml-to-define-pod-templates
# https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
yamlTemplate:
yamlTemplate: ""
# yamlTemplate: |-
# apiVersion: v1
# kind: Pod