Refactor the Helm chart (#300)
This commit is contained in:
		
							parent
							
								
									970449f04f
								
							
						
					
					
						commit
						52fd4f7f7b
					
				|  | @ -2,5 +2,5 @@ apiVersion: v1 | |||
| appVersion: "0.3.3" | ||||
| description: Kubernetes native operator which fully manages Jenkins on Kubernetes | ||||
| name: jenkins-operator | ||||
| version: 0.0.8 | ||||
| version: 0.1.0 | ||||
| icon: https://raw.githubusercontent.com/jenkinsci/kubernetes-operator/master/assets/jenkins-operator-icon.png | ||||
|  |  | |||
|  | @ -0,0 +1,17 @@ | |||
| {{ if .Values.jenkins.backup.pvc.enabled }} | ||||
| apiVersion: v1 | ||||
| kind: PersistentVolumeClaim | ||||
| metadata: | ||||
|   name: jenkins-backup | ||||
|   namespace: {{ .Values.jenkins.namespace }} | ||||
|   labels: | ||||
|     app: jenkins-operator | ||||
|     jenkins-cr: {{ .Values.jenkins.name }} | ||||
| spec: | ||||
|   storageClassName: {{ .Values.jenkins.backup.pvc.className }} | ||||
|   accessModes: | ||||
|     - ReadWriteOnce | ||||
|   resources: | ||||
|     requests: | ||||
|       storage: {{ .Values.jenkins.backup.pvc.size }} | ||||
| {{ end }} | ||||
|  | @ -0,0 +1,20 @@ | |||
| {{ if .Values.jenkins.configuration.configurationAsCode.content }} | ||||
| apiVersion: v1 | ||||
| kind: ConfigMap | ||||
| metadata: | ||||
|   name: jenkins-{{ .Values.jenkins.name }}-casc | ||||
|   namespace: {{ .Values.jenkins.namespace }} | ||||
| {{- with .Values.jenkins.configuration.configurationAsCode.content }} | ||||
| data: {{ toYaml . | nindent 2 }} | ||||
| {{- end }} | ||||
| {{ end }} | ||||
| {{ if .Values.jenkins.configuration.groovyScripts.content }} | ||||
| apiVersion: v1 | ||||
| kind: ConfigMap | ||||
| metadata: | ||||
|   name: jenkins-{{ .Values.jenkins.name }}-gs | ||||
|   namespace: {{ .Values.jenkins.namespace }} | ||||
| {{- with .Values.jenkins.configuration.groovyScripts.content }} | ||||
| data: {{ toYaml . | nindent 2 }} | ||||
| {{- end }} | ||||
| {{ end }} | ||||
|  | @ -1,8 +0,0 @@ | |||
| {{ if .Values.jenkins.enabled }} | ||||
| apiVersion: {{ .Values.jenkins.apiVersion }} | ||||
| kind: Jenkins | ||||
| metadata: | ||||
|   name: {{ .Values.jenkins.name }} | ||||
| spec: | ||||
|   {{- toYaml .Values.jenkins.spec | nindent 4 }} | ||||
| {{- end }} | ||||
|  | @ -0,0 +1,109 @@ | |||
| {{ if .Values.jenkins.enabled }} | ||||
| apiVersion: {{ .Values.jenkins.apiVersion }} | ||||
| kind: Jenkins | ||||
| metadata: | ||||
|   name: {{ .Values.jenkins.name }} | ||||
|   namespace: {{ .Values.jenkins.namespace }} | ||||
| spec: | ||||
|   {{- if .Values.jenkins.configuration.configurationAsCode.content }} | ||||
|   configurationAsCode: | ||||
|     configurations: | ||||
|     - name: jenkins-{{ .Values.jenkins.name }}-casc | ||||
|     secret: | ||||
|       {{- if .Values.jenkins.configuration.secretRefName }} | ||||
|       name: {{ .Values.jenkins.configuration.secretRefName }} | ||||
|       {{ else if .Values.jenkins.configuration.secretData }} | ||||
|       name: jenkins-{{ .Values.jenkins.name }} | ||||
|       {{- end }} | ||||
|   {{- end }} | ||||
|   {{- if .Values.jenkins.configuration.groovyScripts.content }} | ||||
|   groovyScripts: | ||||
|     configurations: | ||||
|     - name: jenkins-{{ .Values.jenkins.name }}-gs | ||||
|     secret: | ||||
|       {{- if .Values.jenkins.configuration.secretRefName }} | ||||
|       name: {{ .Values.jenkins.configuration.secretRefName }} | ||||
|       {{ else if .Values.jenkins.configuration.secretData }} | ||||
|       name: jenkins-{{ .Values.jenkins.name }} | ||||
|       {{- end }} | ||||
|   {{- end }} | ||||
|   {{- if .Values.jenkins.backup.enabled }} | ||||
|   backup: | ||||
|     containerName: {{ .Values.jenkins.backup.containerName }} | ||||
|     action: | ||||
|       exec: | ||||
|         {{- with .Values.jenkins.backup.backupCommand }} | ||||
|         command: {{ toYaml . | nindent 8 }} | ||||
|         {{- end }} | ||||
|     interval: {{ .Values.jenkins.backup.interval }} | ||||
|     makeBackupBeforePodDeletion: {{ .Values.jenkins.backup.makeBackupBeforePodDeletion }} | ||||
|   restore: | ||||
|     containerName: {{ .Values.jenkins.backup.containerName }} | ||||
|     action: | ||||
|       exec: | ||||
|         {{- with .Values.jenkins.backup.restoreCommand }} | ||||
|         command: {{ toYaml . | nindent 8 }} | ||||
|         {{- end }} | ||||
|     {{- if .Values.jenkins.backup.recoveryOnce }} | ||||
|     recoveryOnce: {{ .Values.jenkins.backup.recoveryOnce }} | ||||
|     {{- end }} | ||||
|   {{- end }} | ||||
|   {{- with .Values.jenkins.notifications }} | ||||
|   notifications: {{ toYaml . | nindent 4 }} | ||||
|   {{- end }} | ||||
|   master: | ||||
|     {{- with .Values.jenkins.basePlugins }} | ||||
|     basePlugins: {{ toYaml . | nindent 4 }} | ||||
|     {{- end }} | ||||
|     {{- with .Values.jenkins.plugins }} | ||||
|     plugins: {{ toYaml . | nindent 4 }} | ||||
|     {{- end }} | ||||
|     disableCSRFProtection: {{ .Values.jenkins.disableCSRFProtection }} | ||||
|     containers: | ||||
|       - name:  {{ .Values.jenkins.name }}-master | ||||
|         image: {{ .Values.jenkins.image }} | ||||
|         imagePullPolicy: {{ .Values.jenkins.imagePullPolicy }} | ||||
|         {{- with .Values.jenkins.imagePullSecrets }} | ||||
|         imagePullSecrets: {{ toYaml . | nindent 10 }} | ||||
|         {{- end }} | ||||
|         livenessProbe: | ||||
|           failureThreshold: 12 | ||||
|           httpGet: | ||||
|             path: /login | ||||
|             port: http | ||||
|             scheme: HTTP | ||||
|           initialDelaySeconds: 80 | ||||
|           periodSeconds: 10 | ||||
|           successThreshold: 1 | ||||
|           timeoutSeconds: 5 | ||||
|         readinessProbe: | ||||
|           failureThreshold: 3 | ||||
|           httpGet: | ||||
|             path: /login | ||||
|             port: http | ||||
|             scheme: HTTP | ||||
|           initialDelaySeconds: 30 | ||||
|           periodSeconds: 10 | ||||
|           successThreshold: 1 | ||||
|           timeoutSeconds: 1 | ||||
|         {{- with .Values.jenkins.resources }} | ||||
|         resources: {{ toYaml . | nindent 10 }} | ||||
|         {{- end }} | ||||
|       {{- if .Values.jenkins.backup.enabled }} | ||||
|       - name: {{ .Values.jenkins.backup.containerName }} | ||||
|         image: {{ .Values.jenkins.backup.image }} | ||||
|         imagePullPolicy: IfNotPresent | ||||
|         {{- with .Values.jenkins.backup.env }} | ||||
|         env: {{- toYaml . | nindent 8 }} | ||||
|         {{- end }} | ||||
|         {{- with .Values.jenkins.backup.volumeMounts }} | ||||
|         volumeMounts: {{- toYaml . | nindent 8 }} | ||||
|         {{- end }} | ||||
|       {{- end }} | ||||
|     {{- with .Values.jenkins.volumes }} | ||||
|     volumes: {{- toYaml . | nindent 4 }} | ||||
|     {{- end }} | ||||
|   {{- with .Values.jenkins.seedJobs }} | ||||
|   seedJobs: {{- toYaml . | nindent 4 }} | ||||
|   {{- end }} | ||||
| {{- end }} | ||||
|  | @ -5,7 +5,7 @@ metadata: | |||
|   labels: | ||||
| {{ include "jenkins-operator.labels" . | indent 4 }} | ||||
| spec: | ||||
|   replicas: {{ .Values.replicaCount }} | ||||
|   replicas: {{ .Values.operator.replicaCount }} | ||||
|   selector: | ||||
|     matchLabels: | ||||
|       app.kubernetes.io/name: {{ include "jenkins-operator.name" . }} | ||||
|  | @ -17,14 +17,14 @@ spec: | |||
|         app.kubernetes.io/instance: {{ .Release.Name }} | ||||
|     spec: | ||||
|       serviceAccountName: jenkins-operator | ||||
|     {{- with .Values.imagePullSecrets }} | ||||
|     {{- with .Values.operator.imagePullSecrets }} | ||||
|       imagePullSecrets: | ||||
|         {{- toYaml . | nindent 8 }} | ||||
|     {{- end }} | ||||
|       containers: | ||||
|         - name: {{ .Chart.Name }} | ||||
|           image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||||
|           imagePullPolicy: {{ .Values.image.pullPolicy }} | ||||
|           image: {{ .Values.operator.image }} | ||||
|           imagePullPolicy: {{ .Values.operator.imagePullPolicy }} | ||||
|           ports: | ||||
|             - name: http | ||||
|               containerPort: 80 | ||||
|  | @ -44,16 +44,16 @@ spec: | |||
|             - name: OPERATOR_NAME | ||||
|               value: "jenkins-operator" | ||||
|           resources: | ||||
|             {{- toYaml .Values.resources | nindent 12 }} | ||||
|       {{- with .Values.nodeSelector }} | ||||
|             {{- toYaml .Values.operator.resources | nindent 12 }} | ||||
|       {{- with .Values.operator.nodeSelector }} | ||||
|       nodeSelector: | ||||
|         {{- toYaml . | nindent 8 }} | ||||
|       {{- end }} | ||||
|     {{- with .Values.affinity }} | ||||
|     {{- with .Values.operator.affinity }} | ||||
|       affinity: | ||||
|         {{- toYaml . | nindent 8 }} | ||||
|     {{- end }} | ||||
|     {{- with .Values.tolerations }} | ||||
|     {{- with .Values.operator.tolerations }} | ||||
|       tolerations: | ||||
|         {{- toYaml . | nindent 8 }} | ||||
|     {{- end }} | ||||
|  | @ -0,0 +1,11 @@ | |||
| {{ if and (eq .Values.jenkins.configuration.secretRefName "") (.Values.jenkins.configuration.secretData) }} | ||||
| apiVersion: v1 | ||||
| kind: Secret | ||||
| type: Opaque | ||||
| metadata: | ||||
|   name: jenkins-{{ .Values.jenkins.name }} | ||||
|   namespace: {{ .Values.jenkins.namespace }} | ||||
| {{- with .Values.jenkins.configuration.secretData }} | ||||
| data: {{ toYaml . | nindent 2 }} | ||||
| {{- end }} | ||||
| {{ end }} | ||||
|  | @ -1,70 +1,209 @@ | |||
| # Default values for jenkins-operator. | ||||
| # This is a YAML-formatted file. | ||||
| # Declare variables to be passed into your templates. | ||||
| 
 | ||||
| replicaCount: 1 | ||||
| 
 | ||||
| image: | ||||
|   repository: virtuslab/jenkins-operator | ||||
|   tag: v0.3.3 | ||||
|   pullPolicy: IfNotPresent | ||||
| 
 | ||||
| imagePullSecrets: [] | ||||
| nameOverride: "" | ||||
| fullnameOverride: "" | ||||
| # Jenkins Operator Helm chart | ||||
| 
 | ||||
| # Jenkins instance configuration | ||||
| jenkins: | ||||
|   # enabled can enable or disable the Jenkins instance | ||||
|   # Set to false if you have configured CR already and/or you want to deploy an operator only | ||||
|   enabled: true | ||||
| 
 | ||||
|   # apiVersion is the version of the CR manifest | ||||
|   # The recommended and default value is "jenkins.io/v1alpha2" | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/migration-guide-v1alpha1-to-v1alpha2/ for more migration guide | ||||
|   apiVersion: jenkins.io/v1alpha2 | ||||
|   name: example | ||||
|   spec: | ||||
|     master: | ||||
|       containers: | ||||
|         - name: jenkins-master | ||||
|           image: jenkins/jenkins:lts | ||||
|           imagePullPolicy: Always | ||||
|           livenessProbe: | ||||
|             failureThreshold: 12 | ||||
|             httpGet: | ||||
|               path: /login | ||||
|               port: http | ||||
|               scheme: HTTP | ||||
|             initialDelaySeconds: 80 | ||||
|             periodSeconds: 10 | ||||
|             successThreshold: 1 | ||||
|             timeoutSeconds: 5 | ||||
|           readinessProbe: | ||||
|             failureThreshold: 3 | ||||
|             httpGet: | ||||
|               path: /login | ||||
|               port: http | ||||
|               scheme: HTTP | ||||
|             initialDelaySeconds: 30 | ||||
|             periodSeconds: 10 | ||||
|             successThreshold: 1 | ||||
|             timeoutSeconds: 1 | ||||
|           resources: | ||||
|             limits: | ||||
|               cpu: 1500m | ||||
|               memory: 3Gi | ||||
|             requests: | ||||
|               cpu: "1" | ||||
|               memory: 500Mi | ||||
| 
 | ||||
| resources: {} | ||||
|   # We usually recommend not to specify default resources and to leave this as a conscious | ||||
|   # choice for the user. This also increases chances charts run on environments with little | ||||
|   # resources, such as Minikube. If you do want to specify resources, uncomment the following | ||||
|   # lines, adjust them as necessary, and remove the curly braces after 'resources:'. | ||||
|   # limits: | ||||
|   #   cpu: 100m | ||||
|   #   memory: 128Mi | ||||
|   # requests: | ||||
|   #   cpu: 100m | ||||
|   #   memory: 128Mi | ||||
|   # name of resource | ||||
|   # The pod name will be jenkins-<name> (name will be set as suffix) | ||||
|   name: jenkins | ||||
| 
 | ||||
| nodeSelector: {} | ||||
|   # namespace is the namespace where the resources will be deployed | ||||
|   # It's not recommended to use default namespace | ||||
|   # Create new namespace for jenkins (called e.g. jenkins) | ||||
|   namespace: default | ||||
| 
 | ||||
| tolerations: [] | ||||
|   # image is the name (and tag) of the Jenkins instance | ||||
|   # Default: jenkins/jenkins:lts | ||||
|   # It's recommended to use LTS (tag: "lts") version | ||||
|   image: jenkins/jenkins:lts | ||||
| 
 | ||||
| affinity: {} | ||||
|   # imagePullPolicy defines policy for pulling images | ||||
|   imagePullPolicy: Always | ||||
| 
 | ||||
|   # disableCSRFProtection can enable or disable operator built-in CSRF protection | ||||
|   # Set it to true if you are using OpenShift Jenkins Plugin | ||||
|   # See https://github.com/jenkinsci/kubernetes-operator/pull/193 for more info | ||||
|   disableCSRFProtection: false | ||||
| 
 | ||||
|   # imagePullSecrets is used if you want to pull images from private repository | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/#pulling-docker-images-from-private-repositories for more info | ||||
|   imagePullSecrets: [] | ||||
| 
 | ||||
|   # notifications is feature that notify user about Jenkins reconcilation status | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/notifications/ for more info | ||||
|   notifications: [] | ||||
| 
 | ||||
|   # basePlugins are plugins installed and required by the operator | ||||
|   # Shouldn't contain plugins defined by user | ||||
|   # You can change their versions here | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/#install-plugins for more details | ||||
|   # | ||||
|   # Example: | ||||
|   # | ||||
|   # basePlugins: | ||||
|   # - name: kubernetes | ||||
|   #   version: 1.18.3 | ||||
|   # - name: workflow-job | ||||
|   #   version: "2.34" | ||||
|   # - name: workflow-aggregator | ||||
|   #   version: "2.6" | ||||
|   # - name: git | ||||
|   #   version: 3.12.0 | ||||
|   # - name: job-dsl | ||||
|   #   version: "1.76" | ||||
|   # - name: configuration-as-code | ||||
|   #   version: "1.29" | ||||
|   # - name: configuration-as-code-support | ||||
|   #   version: "1.19" | ||||
|   # - name: kubernetes-credentials-provider | ||||
|   #   version: 0.12.1 | ||||
|   basePlugins: [] | ||||
| 
 | ||||
|   # plugins are plugins required by the user | ||||
|   # You can define plugins here | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/#install-plugins for more details | ||||
|   # | ||||
|   # Example: | ||||
|   # | ||||
|   # plugins: | ||||
|   # - name: simple-theme-plugin | ||||
|   #   version: 0.5.1 | ||||
|   plugins: [] | ||||
| 
 | ||||
|   # seedJobs is placeholder for jenkins seed jobs | ||||
|   # For seed job creation tutorial, check https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/#prepare-job-definitions-and-pipelines | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuration/#configure-seed-jobs for additional info | ||||
|   # Example: | ||||
|   # | ||||
|   # seedJobs: | ||||
|   #  - id: jenkins-operator | ||||
|   #    targets: "cicd/jobs/*.jenkins" | ||||
|   #    description: "Jenkins Operator repository" | ||||
|   #    repositoryBranch: master | ||||
|   #    repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git | ||||
|   seedJobs: [] | ||||
| 
 | ||||
|   # Resource limit/request for Jenkins | ||||
|   # See https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ for details | ||||
|   resources: | ||||
|     limits: | ||||
|       cpu: 1500m | ||||
|       memory: 3Gi | ||||
|     requests: | ||||
|       cpu: 1 | ||||
|       memory: 500Mi | ||||
| 
 | ||||
|   # volumes used by Jenkins | ||||
|   # By default, we are only using backup | ||||
|   volumes: | ||||
|     - name: backup # PVC volume where backups will be stored | ||||
|       persistentVolumeClaim: | ||||
|         claimName: jenkins-backup | ||||
| 
 | ||||
|   # backup is section for configuring operator's backup feature | ||||
|   # By default backup feature is enabled and pre-configured | ||||
|   # This section simplifies the configuration described here: https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configure-backup-and-restore/ | ||||
|   # For customization tips see https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/custom-backup-and-restore/ | ||||
|   backup: | ||||
|     # enabled is enable/disable switch for backup feature | ||||
|     # By default the feature is enabled | ||||
|     enabled: true | ||||
| 
 | ||||
|     # image used by backup feature | ||||
|     # By default using prebuilt backup PVC image by VirtusLab | ||||
|     image: virtuslab/jenkins-operator-backup-pvc:v0.0.8 | ||||
| 
 | ||||
|     # containerName is backup container name | ||||
|     containerName: backup | ||||
| 
 | ||||
|     # interval defines how often make backup in seconds | ||||
|     interval: 30 | ||||
| 
 | ||||
|     # makeBackupBeforePodDeletion when enabled will make backup before pod deletion | ||||
|     makeBackupBeforePodDeletion: true | ||||
| 
 | ||||
|     # backupCommand is backup container command | ||||
|     backupCommand: | ||||
|       - /home/user/bin/backup.sh | ||||
| 
 | ||||
|     # restoreCommand is backup restore command | ||||
|     restoreCommand: | ||||
|       - /home/user/bin/restore.sh | ||||
| 
 | ||||
|     # pvc is Persistent Volume Claim Kubernetes resource | ||||
|     pvc: | ||||
|       # enabled is enable/disable switch for PVC | ||||
|       enabled: true | ||||
| 
 | ||||
|       # size is size of PVC | ||||
|       size: 5Gi | ||||
| 
 | ||||
|       # className is storageClassName for PVC | ||||
|       # See https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1 for more details | ||||
|       className: "" | ||||
| 
 | ||||
|     # env contains container environment variables | ||||
|     # PVC backup provider handles these variables: | ||||
|     # BACKUP_DIR - path for storing backup files (default: "/backup") | ||||
|     # JENKINS_HOME - path to jenkins home (default: "/jenkins-home") | ||||
|     # BACKUP_COUNT - define how much recent backups will be kept | ||||
|     env: | ||||
|       - name: BACKUP_DIR | ||||
|         value: /backup | ||||
|       - name: JENKINS_HOME | ||||
|         value: /jenkins-home | ||||
|       - name: BACKUP_COUNT | ||||
|         value: "3" # keep only the 3 most recent backups | ||||
| 
 | ||||
|     # volumeMounts holds the mount points for volumes | ||||
|     volumeMounts: | ||||
|       - name: jenkins-home | ||||
|         mountPath: /jenkins-home # Jenkins home volume | ||||
|       - mountPath: /backup # backup volume | ||||
|         name: backup | ||||
| 
 | ||||
|   # configuration is section where we can configure Jenkins instance | ||||
|   # See https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/customization/ for details | ||||
|   configuration: | ||||
|     configurationAsCode: | ||||
|       content: {} | ||||
|     groovyScripts: | ||||
|       content: {} | ||||
| 
 | ||||
|     # secretRefName of existing secret (previously created) | ||||
|     secretRefName: "" | ||||
| 
 | ||||
|     # secretData creates new secret if secretRefName is empty and fills with data provided in secretData | ||||
|     secretData: {} | ||||
| 
 | ||||
| # operator is section for configuring operator deployment | ||||
| operator: | ||||
|   replicaCount: 1 | ||||
| 
 | ||||
|   # image is the name (and tag) of the Jenkins Operator image | ||||
|   image: virtuslab/jenkins-operator:v0.3.3 | ||||
| 
 | ||||
|   # imagePullPolicy defines policy for pulling images | ||||
|   imagePullPolicy: IfNotPresent | ||||
| 
 | ||||
|   # imagePullSecrets is used if you want to pull images from private repository | ||||
|   imagePullSecrets: [] | ||||
| 
 | ||||
|   # nameOverride overrides the app name | ||||
|   nameOverride: "" | ||||
| 
 | ||||
|   # fullnameOverride overrides the deployment name | ||||
|   fullnameOverride: "" | ||||
| 
 | ||||
|   resources: {} | ||||
|   nodeSelector: {} | ||||
|   tolerations: [] | ||||
|   affinity: {} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue