### Example Bash Command for Helm Install Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/COMPLETION_REPORT.txt Demonstrates how to install the Jenkins Helm chart using a custom values file. Ensure you have Helm and a Kubernetes cluster configured. ```bash helm install my-jenkins jenkins/jenkins -f values.yaml ``` -------------------------------- ### Install Jenkins with Production Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Install the Jenkins Helm chart using the production-specific values file. ```bash helm install jenkins jenkins/jenkins \ -f values-production.yaml \ -n jenkins \ --create-namespace ``` -------------------------------- ### Minimal Jenkins Installation Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/README.md Installs the Jenkins chart with default settings. Ensure you have Helm installed and configured. ```bash helm repo add jenkins https://charts.jenkins.io helm install jenkins jenkins/jenkins -n jenkins --create-namespace ``` -------------------------------- ### Jenkins Helm Chart Installation Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/CHART_OVERVIEW.md Basic commands to add the Jenkins Helm chart repository and install the chart. ```bash helm repo add jenkins https://charts.jenkins.io helm install [RELEASE_NAME] jenkins/jenkins ``` -------------------------------- ### Install Jenkins Plugins Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/configuration.md Specify plugins to install during Jenkins controller setup. You can list specific versions or use plugin aliases. ```yaml controller: installPlugins: - "kubernetes:4423.vb_59f230b_ce53" - "workflow-aggregator:608.v67378e9d3db_1" - "git:5.10.1" - "configuration-as-code:2089.v970a_0b_a_8cc6d" - "pipeline-model-definition:2.2152.v84e48e6e0e6a_" additionalPlugins: - "github-branch-source:1670.v1c2a_1a_86d1ce" - "slack:682.v01586bae28b_5" ``` -------------------------------- ### Install Jenkins from OCI Registry (Helm 3.7+) Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Install the Jenkins chart directly from the OCI registry, specifying a version, namespace, and creating the namespace if it doesn't exist. ```bash helm install jenkins oci://ghcr.io/jenkinsci/helm-charts/jenkins \ --version 5.9.32 \ -n jenkins \ --create-namespace ``` -------------------------------- ### StatefulSet Metadata Example Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/template-functions.md Demonstrates how to use `include` functions for generating StatefulSet metadata, including fullname, namespace, and labels. ```yaml apiVersion: apps/v1 kind: StatefulSet metadata: name: {{ include "jenkins.fullname" . }} namespace: {{ include "jenkins.namespace" . }} labels: {{ include "jenkins.labels" . | nindent 4 }} spec: serviceName: {{ include "jenkins.fullname" . }} replicas: {{ .Values.controller.replicas }} ... ``` -------------------------------- ### Install Jenkins Chart Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Install the Jenkins chart using Helm. Replace [RELEASE_NAME] with your desired release name and append any necessary flags for customization. ```console helm install [RELEASE_NAME] jenkins/jenkins [flags] ``` -------------------------------- ### Minimal Jenkins Helm Chart Installation Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Perform a basic installation of the Jenkins Helm chart with default settings. This includes a StatefulSet, Service, ConfigMaps, Secret, and PVC. ```bash helm install jenkins jenkins/jenkins \ -n jenkins \ --create-namespace ``` -------------------------------- ### View Installed Plugins Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md List the plugins installed in the Jenkins home directory on the controller pod. This helps confirm if a plugin has been successfully deployed. ```bash kubectl exec -it pod/jenkins-controller-0 -- \ bash -c "ls /var/jenkins_home/plugins/" ``` -------------------------------- ### Install Helm Unittest Plugin Source: https://github.com/jenkinsci/helm-charts/blob/main/CONTRIBUTING.md Install the helm-unittest plugin, which is used for running unit tests on Helm charts. Ensure you specify the desired version. ```bash $ helm plugin install https://github.com/helm-unittest/helm-unittest --version 1.0.3 ``` -------------------------------- ### Recommended Development Plugin Installation Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md This configuration is suitable for development environments, enabling the installation of the latest plugin versions on every restart. It allows Helm values to overwrite existing plugins and image-bundled plugins. ```yaml controller: installLatestPlugins: true installLatestSpecifiedPlugins: false initializeOnce: false overwritePlugins: true overwritePluginsFromImage: true ``` -------------------------------- ### Example YAML Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/COMPLETION_REPORT.txt Illustrates a typical values.yaml file for configuring Jenkins Helm charts, including settings for plugins, initialization scripts, and resource limits. ```yaml controller: # -- Jenkins Controller Configuration -- # -- Jenkins Version -- image: repository: jenkins/jenkins tag: lts-jdk11 # -- Resource Limits -- resources: requests: cpu: "500m" memory: "1Gi" limits: cpu: "1" memory: "2Gi" plugins: # -- Plugin Management -- # -- Install default plugins -- installPlugins: - "workflow-aggregator:latest" - "pipeline-model-definition:latest" - "blueocean:latest" # -- Version Pinning -- # Example of exact version pinning pinnedVersions: - "workflow-aggregator:2.5" initScripts: # -- Groovy Initialization Scripts -- # Example: Configure a global security realm - |- import jenkins.model.Jenkins import hudson.security.HudsonPrivateSecurityRealm def instance = Jenkins.getInstance() def securityRealm = new HudsonPrivateSecurityRealm(false, false, null) securityRealm.createAccount("admin", "password") instance.setSecurityRealm(securityRealm) instance.save() scriptApproval: # -- Script Approval Configuration -- approvedScripts: - "org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" dependency: # -- Dependency Management -- resolveDependencies: true ``` -------------------------------- ### Jenkins Helm Chart Installation with Custom Values File Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Install the Jenkins chart using a custom values file to override default configurations. ```bash helm install jenkins jenkins/jenkins \ -f values.yaml \ -n jenkins \ --create-namespace ``` -------------------------------- ### Secret: additional-secrets example Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/kubernetes-resources.md Example of a custom secret containing client ID and secret, mounted as environment variables. ```yaml data: client_id: client_secret: ``` -------------------------------- ### Local Development Setup with Tilt Source: https://github.com/jenkinsci/helm-charts/blob/main/CONTRIBUTING.md Use this command to set up your local development environment for a specific chart using Tilt. Ensure you have a local Kubernetes cluster running. ```console CHART=jenkins cd charts/$CHART tilt up # Open a service tunnel into the cluster with minikube minikube service chart-$CHART # Login with username admin and password asdf ``` -------------------------------- ### Jenkins Helm Chart Installation with Inline Values Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Install the Jenkins chart and override specific configuration values directly on the command line using the --set flag. ```bash helm install jenkins jenkins/jenkins \ --set controller.serviceType=LoadBalancer \ --set controller.jenkinsUrl="https://jenkins.example.com" \ --set persistence.size=50Gi \ -n jenkins \ --create-namespace ``` -------------------------------- ### Install Jenkins with Multiple Values Files Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Deploy Jenkins using a base configuration file and override it with multiple specific configuration files. The `--create-namespace` flag will create the namespace if it does not exist. ```bash helm install jenkins jenkins/jenkins \ -f values-base.yaml \ -f values-overrides.yaml \ -f values-secrets.yaml \ -n jenkins \ --create-namespace ``` -------------------------------- ### Recommended Production Plugin Installation Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md This configuration prioritizes stability and avoids automatic updates for plugins in a production environment. It ensures plugins are only installed on the first deployment and Helm values do not overwrite existing plugins or image-bundled plugins. ```yaml controller: installLatestPlugins: false installLatestSpecifiedPlugins: false initializeOnce: true overwritePlugins: false overwritePluginsFromImage: false ``` -------------------------------- ### Check Plugin Installation Status Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Monitor Jenkins controller logs to see which plugins are being installed or skipped. Use this to verify the installation process. ```bash kubectl logs -f pod/jenkins-controller-0 | grep -E "(Installing plugin|Skipping plugin)" ``` -------------------------------- ### Configure Basic Ingress Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Enable and configure ingress resources for exposing Jenkins. This basic setup defines the host and enables ingress, with paths defaulting to all. ```yaml controller: ingress: enabled: true paths: [] apiVersion: "extensions/v1beta1" hostName: jenkins.example.com ``` -------------------------------- ### Install Jenkins Chart via OCI Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Install the Jenkins chart using its OCI image. This method is available from version 5.6.0 onwards. Replace [RELEASE_NAME] with your desired release name and append any necessary flags. ```console helm install [RELEASE_NAME] oci://ghcr.io/jenkinsci/helm-charts/jenkins [flags] ``` -------------------------------- ### Example Kubernetes Manifest for Jenkins Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/COMPLETION_REPORT.txt A sample Kubernetes manifest defining a Jenkins controller deployment. This shows how the Helm chart translates to Kubernetes resources. ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: jenkins-controller spec: replicas: 1 selector: matchLabels: app: jenkins template: metadata: labels: app: jenkins spec: containers: - name: jenkins image: jenkins/jenkins:lts-jdk11 ports: - containerPort: 8080 ``` -------------------------------- ### Mix Pinned and Latest Plugins Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Combine exact version pinning with the installation of the latest versions for other plugins. Ensure `installLatestPlugins` and `installLatestSpecifiedPlugins` are set appropriately. ```yaml controller: installPlugins: - "kubernetes:4423.vb_59f230b_ce53" # Pinned - "git" # Latest installLatestPlugins: true installLatestSpecifiedPlugins: true ``` -------------------------------- ### Example Groovy Initialization Script Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/COMPLETION_REPORT.txt A Groovy script to configure Jenkins with a private security realm and create an initial admin user. This is useful for setting up Jenkins security upon initial deployment. ```groovy import jenkins.model.Jenkins import hudson.security.HudsonPrivateSecurityRealm def instance = Jenkins.getInstance() def securityRealm = new HudsonPrivateSecurityRealm(false, false, null) securityRealm.createAccount("admin", "password") instance.setSecurityRealm(securityRealm) instance.save() ``` -------------------------------- ### Install Latest Plugins (Development Only) Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Configure Jenkins to install the latest available versions of specified plugins. This is suitable for development environments only due to potential instability. ```yaml controller: installPlugins: - "kubernetes" - "git" installLatestPlugins: true ``` -------------------------------- ### Install Plugins using Jenkins Plugin CLI in Dockerfile Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Use the `jenkins-plugin-cli` command within a Dockerfile to install plugins. This method is suitable for creating custom Jenkins images with specific plugin sets. ```dockerfile FROM jenkins/jenkins:2.555.3-jdk21 RUN jenkins-plugin-cli --plugins \ kubernetes:4423.vb_59f230b_ce53 \ workflow-aggregator:608.v67378e9d3db_1 \ git:5.10.1 \ configuration-as-code:2089.v970a_0b_a_8cc6d \ pipeline-model-definition:2.2152.v84e48e6e0e6a_ \ github-branch-source:1670.v1c2a_1a_86d1ce \ slack:682.v01586bae28b_5 ``` -------------------------------- ### Increase Init Container Resources Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Configure increased resource requests and limits for the init container in your Helm values to resolve plugin installation timeouts. ```yaml controller: initContainerResources: requests: cpu: "500m" memory: "512Mi" limits: cpu: "2000m" memory: "2048Mi" ``` -------------------------------- ### Verify Jenkins Configuration Resources Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Commands to inspect Jenkins configuration, including the JCasC ConfigMap, the number of installed plugins, and the admin secret. ```bash # Check JCasC configuration kubectl get configmap -n jenkins jenkins-jcasc-config -o yaml # Check installed plugins kubectl exec -n jenkins jenkins-controller-0 -- \ bash -c "ls -la /var/jenkins_home/plugins/ | wc -l" # Check admin secret kubectl get secret -n jenkins jenkins-admin -o yaml ``` -------------------------------- ### Configure Remote Kubernetes Cluster Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/agent-configuration.md Example of how to define an additional remote Kubernetes cloud for agent provisioning. Ensure the 'kubernetesURL' and 'namespace' are correctly set for your remote cluster. ```yaml additionalClouds: remote-cloud: kubernetesURL: "https://api.remote-k8s.example.com" namespace: "jenkins-agents" agent: podName: remote-agent customJenkinsLabels: - remote ``` -------------------------------- ### Configure Pipeline Libraries with JCasC Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/jcasc-configuration.md Define global pipeline libraries for Jenkins. This example configures a shared library from a GitHub repository, specifying its name, version, and retrieval method. Ensure GitHub credentials are set up. ```yaml controller: JCasC: configScripts: pipeline-libraries: | unclassified: globalLibraries: libraries: - name: "shared-library" version: "main" allowVersionOverride: true defaultVersion: "main" implicit: false cachingConfiguration: excludedChangelog: false retriever: modernSCM: scm: github: repoOwner: "mycompany" repository: "jenkins-shared-library" credentialsId: "github-credentials" apiUri: "https://api.github.com" ``` -------------------------------- ### Namespace and URL Configuration for Agents Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/agent-configuration.md Set the namespace, Jenkins URL, tunnel, and connection methods for agent pods. This example shows how to specify a custom namespace and override Jenkins connection details. ```yaml agent: namespace: "jenkins-agents" jenkinsUrl: "http://jenkins.default.svc.cluster.local:8080" jenkinsTunnel: "jenkins-agent.default.svc.cluster.local:50000" directConnection: false websocket: false serviceAccount: "jenkins-agent" ``` -------------------------------- ### Declare Plugins in values.yaml Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Specify plugins to install directly in your Helm values.yaml file. This method allows for precise control over which plugins and versions are deployed. ```yaml controller: installPlugins: - "kubernetes:4423.vb_59f230b_ce53" - "workflow-aggregator:608.v67378e9d3db_1" - "git:5.10.1" - "configuration-as-code:2089.v970a_0b_a_8cc6d" - "pipeline-model-definition:2.2152.v84e48e6e0e6a_" - "github-branch-source:1670.v1c2a_1a_86d1ce" - "slack:682.v01586bae28b_5" additionalPlugins: - "matrix-auth:3.1.5" - "email-ext:2.94" ``` -------------------------------- ### Adding a Custom ConfigMap Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/kubernetes-resources.md Example of defining a custom ConfigMap resource to be included in the Kubernetes manifest via the `extraObjects` parameter. This demonstrates the basic structure for adding custom Kubernetes objects. ```yaml extraObjects: - apiVersion: v1 kind: ConfigMap metadata: name: custom-config data: custom-key: custom-value ``` -------------------------------- ### Configure Network and Cluster Settings in Helm Chart Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/configuration.md Use this configuration to specify the Kubernetes API URL, cluster DNS zone, and enable network policies. This example demonstrates setting up network policy for internal and external agents. ```yaml kubernetesURL: "https://api.kubernetes.example.com" clusterZone: "k8s.example.local" networkPolicy: enabled: true internalAgents: allowed: true podLabels: jenkins-agent: "true" externalAgents: ipCIDR: "10.0.0.0/8" ``` -------------------------------- ### Configure Jenkins System Message with JCasC Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Use this snippet to set a custom welcome message for your Jenkins instance via JCasC. Ensure the configuration-as-code plugin is installed. ```yaml controller: JCasC: configScripts: welcome-message: | jenkins: systemMessage: Welcome to our CI\nCD server. ``` -------------------------------- ### Configure Jenkins Agent Pods Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/configuration.md Configure agent pod settings including image repository and tag, resource requests and limits, and Kubernetes connection timeouts. This example shows how to customize agent image and resource allocation. ```yaml agent: enabled: true image: repository: "jenkins/inbound-agent" tag: "3383.vc8881d4b_0e76-1" resources: requests: cpu: "1000m" memory: "1024Mi" limits: cpu: "2000m" memory: "2048Mi" kubernetesConnectTimeout: 10 maxRequestsPerHostStr: "64" containerCap: 20 ``` -------------------------------- ### Get Plugin Versions with jenkins-plugin-cli Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Use the jenkins-plugin-cli to list available plugin updates. This command requires a specific Jenkins version to run. ```bash docker run --rm jenkins/jenkins:2.555.3-jdk21 \ jenkins-plugin-cli --available-updates ``` -------------------------------- ### Apply Jenkins Labels in Kubernetes Manifest Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/template-functions.md Example of how to include the generated Jenkins labels within the metadata section of a Kubernetes manifest. Custom labels can also be added. ```yaml # In a Kubernetes manifest: metadata: labels: {{ include "jenkins.labels" . | nindent 4 }} custom-label: "custom-value" # Output: metadata: labels: app.kubernetes.io/name: jenkins app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: prod-release app.kubernetes.io/component: jenkins-controller helm.sh/chart: jenkins-5.9.32 custom-label: custom-value ``` -------------------------------- ### Example JCasC Configuration for Security Realm Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/COMPLETION_REPORT.txt Configures Jenkins Java Configuration as Code (JCasC) to set up a security realm. This snippet is typically placed within a JCasC configuration file. ```yaml jenkins: securityRealm: '@class': hudson.security.HudsonPrivateSecurityRealm allowNonAdminLogin: false disableSignup: false enableCaptcha: false # Example user creation (use with caution in production) users: - username: "admin" password: "password" groups: "" ``` -------------------------------- ### Get Full Jenkins Resource Name Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/template-functions.md Generates the fully qualified application name for resource naming. It uses `fullnameOverride` if provided, otherwise combines `Release.Name` and chart name, avoiding duplication and truncating to 63 characters. ```go-html-template {{- define "jenkins.fullname" -}} {{- if .Values.fullnameOverride -}} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} {{- else -}} {{- $name := default .Chart.Name .Values.nameOverride -}} {{- if contains $name .Release.Name -}} {{- .Release.Name | trunc 63 | trimSuffix "-" -}} {{- else -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- end -}} {{- end -}} ``` -------------------------------- ### Run Helm Chart Unit Tests Source: https://github.com/jenkinsci/helm-charts/blob/main/CONTRIBUTING.md Execute unit tests for a specific Helm chart using the installed unittest plugin. The --strict flag ensures all tests must pass. ```bash $ helm unittest --strict -f 'unittests/*.yaml' charts/jenkins ``` -------------------------------- ### Configure Job Creation with JCasC Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/jcasc-configuration.md Use this configuration to define seed jobs that automatically create other pipeline jobs from a source code repository. This example sets up a 'seed-job' that pulls job configurations from a Git repository. ```yaml controller: JCasC: configScripts: seed-jobs: | jobs: - script: > pipelineJob('seed-job') { description('Automatically creates pipeline jobs from SCM') definition { cpsScm { scm { git { remote { url('https://github.com/mycompany/job-dsl.git') credentials('github-credentials') } branches('*/main') } } scriptPath('Jenkinsfile') } } } ``` -------------------------------- ### Configure LDAP Settings with JCasC Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md This example demonstrates how to configure LDAP authentication settings for Jenkins using JCasC. It includes details for server, root DN, and manager password, utilizing a secret for the password. ```yaml controller: JCasC: configScripts: ldap-settings: | jenkins: securityRealm: ldap: configurations: - server: ldap.acme.com rootDN: dc=acme,dc=uk managerPasswordSecret: ${LDAP_PASSWORD} groupMembershipStrategy: fromUserRecord: attributeName: "memberOf" ``` -------------------------------- ### Custom JVM and Jenkins Options Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Configure custom JVM options and Jenkins startup options using `javaOpts` and `jenkinsOpts`. ```yaml controller: javaOpts: "-Xms2g -Xmx4g -XX:+UseG1GC -XX:+ParallelRefProcEnabled" jenkinsOpts: "--sessionTimeout=1440 --sessionEvictionPolicy=none" ``` -------------------------------- ### Check Pod Startup Logs Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Retrieve logs from the previous instance of a pod to diagnose startup problems. ```bash # Check startup logs kubectl logs -n jenkins jenkins-controller-0 --previous ``` -------------------------------- ### Create ConfigMap for External Init Scripts Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Prepare init scripts by placing them in a directory and creating a Kubernetes ConfigMap. This allows for managing larger or multiple scripts externally. ```bash kubectl create configmap jenkins-init-scripts \ --from-file=scripts/ ``` -------------------------------- ### Disable Plugin Installation in values.yaml Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Set `controller.installPlugins` to `false` to disable automatic plugin installation via the Helm chart. This is useful when providing a custom Docker image with pre-installed plugins. ```yaml controller: installPlugins: false ``` -------------------------------- ### Init Container Resource and Environment Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/plugins-and-initialization.md Define resource requests and limits for the init container, and set environment variables for it. ```yaml controller: initContainerResources: requests: cpu: "100m" memory: "256Mi" limits: cpu: "1000m" memory: "1024Mi" initContainerEnv: - name: HTTP_PROXY value: "http://proxy.example.com:8080" - name: HTTPS_PROXY value: "http://proxy.example.com:8080" - name: NO_PROXY value: "localhost,127.0.0.1,.svc.cluster.local" ``` -------------------------------- ### Jenkins Controller Startup and Liveness Probes Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/kubernetes-resources.md Configures startup and liveness probes for the Jenkins controller pod to monitor its health and availability via HTTP requests to the login endpoint. ```yaml startupProbe: httpGet: path: "{{ .Values.controller.jenkinsUriPrefix }}/login" port: 8080 failureThreshold: 12 periodSeconds: 10 livenessProbe: httpGet: path: "{{ .Values.controller.jenkinsUriPrefix }}/login" port: 8080 failureThreshold: 5 periodSeconds: 10 initialDelaySeconds: 0 (if probes.livenessProbe.initialDelaySeconds set) ``` -------------------------------- ### Get Jenkins Admin Password Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/NOTES.txt Retrieve the admin password for Jenkins by executing this command. This is necessary for the initial login. ```bash kubectl exec --namespace {{ template "jenkins.namespace" . }} -it svc/{{ template "jenkins.fullname" . }} -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo ``` -------------------------------- ### Get Jenkins Chart Name Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/template-functions.md Returns the chart name, with an optional override. Truncates to 63 characters and removes trailing hyphens. ```go-html-template {{- define "jenkins.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} {{- end -}} ``` -------------------------------- ### Get Jenkins Namespace Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/template-functions.md Returns the target namespace for Jenkins resources. Uses 'namespaceOverride' if provided, otherwise uses the Helm release namespace. ```go {{- define "jenkins.namespace" -}} {{- if .Values.namespaceOverride -}} {{- .Values.namespaceOverride -}} {{- else -}} {{- .Release.Namespace -}} {{- end -}} {{- end -}} ``` ```yaml # Deploy to release namespace "jenkins": {{ include "jenkins.namespace" . }} # Output: jenkins # With override: namespaceOverride: "ci-cd" {{ include "jenkins.namespace" . }} # Output: ci-cd ``` -------------------------------- ### Get Jenkins Service Endpoint Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Retrieve the service endpoint for the Jenkins controller. If using a LoadBalancer, this command also fetches the external IP. ```bash kubectl get svc -n jenkins jenkins-controller ``` ```bash kubectl get svc -n jenkins jenkins-controller \ -o jsonpath='{.status.loadBalancer.ingress[0].ip}' ``` -------------------------------- ### Check Init Container Logs Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Access logs specifically from the init container of a pod to troubleshoot initialization failures. ```bash # Check init container logs kubectl logs -n jenkins jenkins-controller-0 -c init ``` -------------------------------- ### Check Pod Events Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Use this command to inspect events related to a specific pod, which can reveal reasons for startup failures. ```bash # Check pod events kubectl describe pod -n jenkins jenkins-controller-0 ``` -------------------------------- ### Jenkins Helm Chart Configuration by Complexity Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/INDEX.md This outlines Jenkins Helm chart configuration parameters grouped by complexity level, from beginner to advanced. Use these settings to tailor your Jenkins deployment for different environments and needs. ```text **Beginner (Minimal Setup)** - controller.replicas - controller.admin.username/password - controller.serviceType - persistence.enabled/size - agent.enabled **Intermediate (Production Ready)** - All beginner settings - controller.ingress configuration - controller.JCasC basic security realm - controller.installPlugins - rbac.create - Network policies **Advanced (Enterprise)** - All intermediate settings - Advanced JCasC configuration (custom scripts, external URLs) - Multiple pod templates with custom YAML - HTTPS keystore configuration - Monitoring and alerting - Multi-cloud setup - Custom init scripts - Advanced scheduling constraints ``` -------------------------------- ### Upgrade Jenkins Chart Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Upgrade an existing Jenkins chart installation using Helm 3. Replace [RELEASE_NAME] with your release name and include any flags for the upgrade. ```console helm upgrade [RELEASE_NAME] jenkins/jenkins [flags] ``` -------------------------------- ### Get Jenkins URL (ClusterIP) Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/NOTES.txt When using ClusterIP, Jenkins is typically accessed via port-forwarding. This snippet shows the local URL and the command to set up port-forwarding. ```bash {{- if .Values.controller.httpsKeyStore.enable -}} {{- $url = print "https://127.0.0.1:" .Values.controller.servicePort $prefix -}} {{- else -}} {{- $url = print "http://127.0.0.1:" .Values.controller.servicePort $prefix -}} {{- end }} echo {{ $url }} kubectl --namespace {{ template "jenkins.namespace" . }} port-forward svc/{{template "jenkins.fullname" . }} {{ .Values.controller.servicePort }}:{{ .Values.controller.servicePort }} ``` -------------------------------- ### Check Available Storage Classes Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md List all available storage classes in your Kubernetes cluster to ensure a suitable one is configured for PVCs. ```bash # Check available storage classes kubectl get storageclass ``` -------------------------------- ### ConfigMap: jenkins-controller-config plugins.txt Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/kubernetes-resources.md Defines the list of plugins and their versions for the Jenkins controller. ```yaml plugins.txt: |- # Plugin list with versions kubernetes:VERSION workflow-aggregator:VERSION ... ``` -------------------------------- ### Build Custom Jenkins Image with Plugins Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Use this Dockerfile to create a custom Jenkins image with specified plugins pre-installed. Ensure to use non-floating tags for reproducible builds. ```Dockerfile FROM jenkins/jenkins:lts RUN jenkins-plugin-cli --plugins kubernetes workflow-aggregator git configuration-as-code ``` -------------------------------- ### Get Jenkins URL (LoadBalancer) Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/NOTES.txt For LoadBalancer service type, this command retrieves the external IP address of the LoadBalancer to construct the Jenkins URL. It also accounts for HTTP/HTTPS. ```bash export SERVICE_IP=$(kubectl get svc --namespace {{ template "jenkins.namespace" . }} {{ template "jenkins.fullname" . }} --template "{{ \"{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}\" }}") {{- if .Values.controller.httpsKeyStore.enable -}} {{- $url = print "https://$SERVICE_IP:" .Values.controller.servicePort $prefix -}} {{- else -}} {{- $url = print "http://$SERVICE_IP:" .Values.controller.servicePort $prefix -}} {{- end }} echo {{ $url }} ``` -------------------------------- ### Configure Agent Pod Lifecycle Settings Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/agent-configuration.md Control agent pod lifecycle with settings for idle time, connection timeouts, TTY allocation, and security context. ```yaml agent: idleMinutes: 5 connectTimeout: 120 restrictedPssSecurityContext: true ``` -------------------------------- ### Split Jenkins Config as Code Scripts Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Break down large Jenkins Config as Code scripts into multiple YAML files for better maintainability. Provide each file during Helm installation. ```yaml jenkins: controller: jenkinsUrlProtocol: https installPlugins: false ... ``` ```yaml jenkins: controller: JCasC: configScripts: jenkinsCasc: | jenkins: disableRememberMe: false mode: NORMAL ... ``` ```yaml jenkins: controller: JCasC: configScripts: unclassifiedCasc: | unclassified: ... ``` -------------------------------- ### Configure Pod Template Inheritance Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/agent-configuration.md Define a base pod template with default configurations and then create new templates that inherit from the base, specifying custom containers and labels. ```yaml agent: podTemplates: base: - name: base-template label: base containers: - name: jnlp image: jenkins/inbound-agent:latest maven: - name: maven inheritFrom: base-template label: maven-agent containers: - name: maven image: maven:3.8-openjdk-11 ``` -------------------------------- ### Get Jenkins URL (NodePort) Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/NOTES.txt When using NodePort service type, these commands help determine the Jenkins URL by finding the NodePort and Node IP. It supports both HTTP and HTTPS. ```bash export NODE_PORT=$(kubectl get --namespace {{ template "jenkins.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "jenkins.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ template "jenkins.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}") {{- if .Values.controller.httpsKeyStore.enable -}} {{- $url = print "https://$NODE_IP:$NODE_PORT" $prefix -}} {{- else -}} {{- $url = print "http://$NODE_IP:$NODE_PORT" $prefix -}} {{- end }} echo {{ $url }} ``` -------------------------------- ### Configure Jenkins HTTPS Keystore Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Enable HTTPS for Jenkins by configuring the keystore. Ensure httpPort and targetPort are different when httpsKeyStore.enable is true. Do not set controller.httpsKeyStore.httpPort to -1. ```yaml controller: httpsKeyStore: enable: true jenkinsHttpsJksSecretName: "" httpPort: 8081 path: "/var/jenkins_keystore" fileName: "keystore.jks" password: "changeit" jenkinsKeyStoreBase64Encoded: "" ``` -------------------------------- ### Default JCasC Authorization Strategy Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/jcasc-configuration.md Sets the default authorization strategy to 'Logged-in users can do anything' with anonymous read access disabled. This is a common starting point for security. ```yaml controller: JCasC: authorizationStrategy: |- loggedInUsersCanDoAnything: allowAnonymousRead: false ``` -------------------------------- ### Add and Update Jenkins Helm Repository Source: https://github.com/jenkinsci/helm-charts/blob/main/README.md Use these commands to add the Jenkins Helm chart repository and update your local Helm repository cache. Ensure Helm is installed and configured. ```bash helm repo add jenkins https://charts.jenkins.io helm repo update ``` -------------------------------- ### Configure Ingress with Annotations and Secondary Ingress Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Configure ingress with specific annotations for class and hostnames, and set up a secondary ingress for specific paths like webhooks. This allows for distinct external access configurations. ```yaml controller: ingress: enabled: true apiVersion: "extensions/v1beta1" hostName: "jenkins.internal.example.com" annotations: kubernetes.io/ingress.class: "internal" secondaryingress: enabled: true apiVersion: "extensions/v1beta1" hostName: "jenkins-scm.example.com" annotations: kubernetes.io/ingress.class: "public" paths: - /github-webhook ``` -------------------------------- ### Configure Jenkins Controller Resources Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/configuration.md Set the number of controller replicas and define CPU and memory requests and limits for both the main container and the init container. ```yaml controller: replicas: 1 resources: requests: cpu: "100m" memory: "512Mi" limits: cpu: "4000m" memory: "8192Mi" ``` -------------------------------- ### Configure Proxy Settings for Init Container and Jenkins Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Set environment variables for the init container, Jenkins container, and JVM to enable communication through a corporate proxy. This is crucial for downloading plugins and dependencies when behind a proxy. ```yaml controller: initContainerEnv: - name: http_proxy value: "http://192.168.64.1:3128" - name: https_proxy value: "http://192.168.64.1:3128" - name: no_proxy value: "" - name: JAVA_OPTS value: "-Dhttps.proxyHost=proxy_host_name_without_protocol -Dhttps.proxyPort=3128" containerEnv: - name: http_proxy value: "http://192.168.64.1:3128" - name: https_proxy value: "http://192.168.64.1:3128" javaOpts: >- -Dhttp.proxyHost=192.168.64.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=192.168.64.1 -Dhttps.proxyPort=3128 ``` -------------------------------- ### High-Availability Jenkins Helm Chart Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Configuration for a high-availability Jenkins setup using the Helm chart. Emphasizes external storage and load balancing, with Pod Disruption Budget enabled. ```yaml # values-ha.yaml controller: replicas: 1 # Max 1 for StatefulSet, use external LB for HA resources: requests: cpu: "2000m" memory: "4096Mi" limits: cpu: "4000m" memory: "8192Mi" serviceType: LoadBalancer podDisruptionBudget: enabled: true maxUnavailable: "0" persistence: enabled: true existingClaim: "jenkins-shared-storage" storageClass: "network-storage" size: "200Gi" networkPolicy: enabled: true internalAgents: allowed: true podLabels: jenkins-agent: "true" ``` -------------------------------- ### Access Jenkins Admin Password and Port Forward Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/README.md Retrieves the Jenkins admin password and sets up port forwarding to access the Jenkins UI locally. This is useful for initial setup and testing. ```bash # Get admin password kubectl get secret jenkins-admin -n jenkins \ -o jsonpath='{.data.jenkins-admin-password}' | base64 -d # Port forward to access kubectl port-forward -n jenkins jenkins-controller-0 8080:8080 # Access: http://localhost:8080 ``` -------------------------------- ### ConfigMap: jenkins-jcasc-config jenkins.yaml Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/kubernetes-resources.md Sets the default Jenkins configuration, including authorization, security realm, and clouds. ```yaml data: # Default configuration jenkins.yaml: | jenkins: authorizationStrategy: ... securityRealm: ... clouds: ... ``` -------------------------------- ### List Available Jenkins Helm Chart Versions Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Search the Jenkins Helm repository to find available chart versions. ```bash helm search repo jenkins/jenkins --versions ``` -------------------------------- ### Basic Agent Pod Template Configuration Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/agent-configuration.md Defines the fundamental settings for an agent pod template, including its name and Jenkins labels for selection. Ensure 'agent.enabled' is true to activate the default agent cloud. ```yaml agent: enabled: true podName: "default-agent" customJenkinsLabels: - "linux" - "docker" - "fast" ``` -------------------------------- ### Configure Agent Resource Requests and Limits Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/api-reference/agent-configuration.md Set CPU, memory, and ephemeral storage requests and limits for the agent pod. Ensure values are valid Kubernetes resource strings. ```yaml agent: resources: requests: cpu: "1000m" memory: "1024Mi" ephemeralStorage: "10Gi" limits: cpu: "2000m" memory: "2048Mi" ephemeralStorage: "20Gi" ``` -------------------------------- ### Show Jenkins Chart Values Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Display all configurable options for the Jenkins chart with detailed comments using Helm 3. This is useful for understanding customization possibilities. ```console helm show values jenkins/jenkins ``` -------------------------------- ### Apply Values File Changes Source: https://github.com/jenkinsci/helm-charts/blob/main/_autodocs/installation-and-deployment.md Edit your `values.yaml` file to make configuration changes, then apply them using `helm upgrade`. This method is suitable for most configuration updates. ```bash # Update values.yaml vim values.yaml # Apply updates helm upgrade jenkins jenkins/jenkins \ -f values.yaml \ -n jenkins ``` -------------------------------- ### Enable Network Policy for Jenkins Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Install the Helm chart with network policy enabled by setting `networkPolicy.enabled` to `true`. Fine-grained controls for internal and external agent connections can be configured using `controller.networkPolicy.internalAgents` and `controller.networkPolicy.externalAgents`. ```yaml networkPolicy: enabled: true ``` -------------------------------- ### Determine Jenkins URL (Ingress) Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/templates/NOTES.txt This snippet shows how to construct the Jenkins URL when Ingress is configured. It handles both HTTP and HTTPS based on TLS settings. ```go-template {{- $prefix := .Values.controller.jenkinsUriPrefix | default "" -}} {{- $url := "" -}} {{- if .Values.controller.ingress.hostName -}} {{- if .Values.controller.ingress.tls -}} {{- $url = print "https://" .Values.controller.ingress.hostName $prefix -}} {{- else -}} {{- $url = print "http://" .Values.controller.ingress.hostName $prefix -}} {{- end }} {{- end }} ``` -------------------------------- ### Configure Jenkins Security Realm and Authorization Source: https://github.com/jenkinsci/helm-charts/blob/main/charts/jenkins/README.md Example configuration for Jenkins Controller using Jenkins Configuration as Code (JCasC) to set up a local security realm with a single admin user and disable anonymous read access. ```yaml controller: JCasC: securityRealm: |- local: allowsSignup: false enableCaptcha: false users: - id: "${chart-admin-username}" name: "Jenkins Admin" password: "${chart-admin-password}" authorizationStrategy: |- loggedInUsersCanDoAnything: allowAnonymousRead: false ```