diff --git a/docs/docs/developer-guide/index.html b/docs/docs/developer-guide/index.html index 4de2275e..4702f39a 100644 --- a/docs/docs/developer-guide/index.html +++ b/docs/docs/developer-guide/index.html @@ -26,7 +26,7 @@ " /> - + @@ -1365,7 +1365,7 @@ make deploy-webhook -
Last modified October 20, 2021 +
Last modified January 12, 2023
@@ -1408,4 +1408,4 @@ make deploy-webhook - + \ No newline at end of file diff --git a/docs/docs/developer-guide/index.xml b/docs/docs/developer-guide/index.xml index 39ed98f2..6a31644c 100644 --- a/docs/docs/developer-guide/index.xml +++ b/docs/docs/developer-guide/index.xml @@ -4,7 +4,7 @@ https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ Recent Hugo news from gohugo.io Hugo -- gohugo.io - Wed, 20 Oct 2021 00:00:00 +0000 + Thu, 12 Jan 2023 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/img/hugo.png GoHugo.io diff --git a/docs/docs/getting-started/index.html b/docs/docs/getting-started/index.html index 5d82b367..ca947b9f 100644 --- a/docs/docs/getting-started/index.html +++ b/docs/docs/getting-started/index.html @@ -968,6 +968,8 @@ + + @@ -995,8 +997,6 @@ - -
v0.4.x diff --git a/docs/docs/getting-started/latest/index.html b/docs/docs/getting-started/latest/index.html index f8f2f340..95610a25 100644 --- a/docs/docs/getting-started/latest/index.html +++ b/docs/docs/getting-started/latest/index.html @@ -962,6 +962,8 @@ + + @@ -989,8 +991,6 @@ - -
Customizing Jenkins @@ -1033,6 +1033,8 @@ + +
Configuring backup and restore @@ -1047,8 +1049,6 @@ - -
Separate namespaces for Jenkins and Operator diff --git a/docs/docs/getting-started/v0.1.x/configuration/index.html b/docs/docs/getting-started/v0.1.x/configuration/index.html index c43d09f6..a457d098 100644 --- a/docs/docs/getting-started/v0.1.x/configuration/index.html +++ b/docs/docs/getting-started/v0.1.x/configuration/index.html @@ -25,13 +25,13 @@ " /> - - + + - - + + @@ -1176,7 +1176,7 @@ The /usr/bin/tini -s -- /usr/local/bin/jenkins.sh command runs the - /var/jenkins/scripts/init.sh && <custom-code-here> && /usr/bin/tini -s -- /usr/local/bin/jenkins.sh
-
Last modified August 5, 2019 +
Last modified January 12, 2023
@@ -1220,4 +1220,4 @@ The /usr/bin/tini -s -- /usr/local/bin/jenkins.sh command runs the - + \ No newline at end of file diff --git a/docs/docs/getting-started/v0.1.x/index.html b/docs/docs/getting-started/v0.1.x/index.html index 334c7096..cd30e015 100644 --- a/docs/docs/getting-started/v0.1.x/index.html +++ b/docs/docs/getting-started/v0.1.x/index.html @@ -964,20 +964,6 @@ - - - - - - - - - - - - - -
Configuration @@ -997,6 +983,20 @@ + + + + + + + + + + + + + + diff --git a/docs/docs/getting-started/v0.1.x/index.xml b/docs/docs/getting-started/v0.1.x/index.xml index 8cc247e6..c38eb00d 100644 --- a/docs/docs/getting-started/v0.1.x/index.xml +++ b/docs/docs/getting-started/v0.1.x/index.xml @@ -97,7 +97,7 @@ kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <s Docs: Configuration https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ - Mon, 05 Aug 2019 00:00:00 +0000 + Thu, 12 Jan 2023 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ @@ -2319,4 +2319,4 @@ or use the default deployment manifest:</p> - + \ No newline at end of file diff --git a/docs/docs/getting-started/v0.3.x/index.html b/docs/docs/getting-started/v0.3.x/index.html index 846c5606..50e3d1e5 100644 --- a/docs/docs/getting-started/v0.3.x/index.html +++ b/docs/docs/getting-started/v0.3.x/index.html @@ -975,6 +975,8 @@ + +
@@ -1000,8 +1002,6 @@ - -
Customization diff --git a/docs/docs/getting-started/v0.4.x/index.html b/docs/docs/getting-started/v0.4.x/index.html index 06cf9231..95d2c8a6 100644 --- a/docs/docs/getting-started/v0.4.x/index.html +++ b/docs/docs/getting-started/v0.4.x/index.html @@ -973,6 +973,8 @@ + +
@@ -998,8 +1000,6 @@ - -
Customization diff --git a/docs/docs/getting-started/v0.5.x/index.html b/docs/docs/getting-started/v0.5.x/index.html index bcb7e566..5c4a7ab0 100644 --- a/docs/docs/getting-started/v0.5.x/index.html +++ b/docs/docs/getting-started/v0.5.x/index.html @@ -968,6 +968,8 @@ + +
Configuration @@ -993,8 +995,6 @@ - -
diff --git a/docs/docs/getting-started/v0.6.x/index.html b/docs/docs/getting-started/v0.6.x/index.html index 1067ac38..0086662c 100644 --- a/docs/docs/getting-started/v0.6.x/index.html +++ b/docs/docs/getting-started/v0.6.x/index.html @@ -964,6 +964,8 @@ + + @@ -991,8 +993,6 @@ - -
Customizing Jenkins @@ -1035,6 +1035,8 @@ + +
Configuring backup and restore @@ -1049,8 +1051,6 @@ - -
Separate namespaces for Jenkins and Operator diff --git a/docs/docs/index.html b/docs/docs/index.html index aadb65fb..e7d168e2 100644 --- a/docs/docs/index.html +++ b/docs/docs/index.html @@ -936,6 +936,8 @@ + +
@@ -959,8 +961,6 @@ - -
Security @@ -999,10 +999,6 @@ - - - -
Developer Guide @@ -1019,6 +1015,10 @@ + + + +
FAQ diff --git a/docs/docs/index.xml b/docs/docs/index.xml index 9cdcd18a..a74775a8 100644 --- a/docs/docs/index.xml +++ b/docs/docs/index.xml @@ -2293,6 +2293,243 @@ kubectl get secret jenkins-operator-credentials-&lt;cr_name&gt; -o <s + + Docs: Configuration + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ + Thu, 12 Jan 2023 00:00:00 +0000 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ + + + + + +<p>Jenkins operator uses <a href="https://github.com/jenkinsci/job-dsl-plugin">job-dsl</a> and <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/">kubernetes-credentials-provider</a> plugins for configuring jobs +and deploy keys.</p> + +<h2 id="prepare-job-definitions-and-pipelines">Prepare job definitions and pipelines</h2> + +<p>First you have to prepare pipelines and job definition in your GitHub repository using the following structure:</p> +<pre><code>cicd/ +├── jobs +│   └── build.jenkins +└── pipelines + └── build.jenkins</code></pre> +<p><strong>cicd/jobs/build.jenkins</strong> it&rsquo;s a job definition:</p> +<pre><code>#!/usr/bin/env groovy + +pipelineJob('build-jenkins-operator') { + displayName('Build jenkins-operator') + + definition { + cpsScm { + scm { + git { + remote { + url('https://github.com/jenkinsci/kubernetes-operator.git') + credentials('jenkins-operator') + } + branches('*/master') + } + } + scriptPath('cicd/pipelines/build.jenkins') + } + } +}</code></pre> +<p><strong>cicd/pipelines/build.jenkins</strong> is an actual Jenkins pipeline:</p> +<pre><code>#!/usr/bin/env groovy + +def label = "build-jenkins-operator-${UUID.randomUUID().toString()}" +def home = "/home/jenkins" +def workspace = "${home}/workspace/build-jenkins-operator" +def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/" + +podTemplate(label: label, + containers: [ + containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:alpine'), + containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), + ], + envVars: [ + envVar(key: 'GOPATH', value: workspace), + ], + ) { + + node(label) { + dir(workdir) { + stage('Init') { + timeout(time: 3, unit: 'MINUTES') { + checkout scm + } + container('go') { + sh 'apk --no-cache --update add make git gcc libc-dev' + } + } + + stage('Dep') { + container('go') { + sh 'make dep' + } + } + + stage('Test') { + container('go') { + sh 'make test' + } + } + + stage('Build') { + container('go') { + sh 'make build' + } + } + } + } +}</code></pre> +<h2 id="configure-seed-jobs">Configure Seed Jobs</h2> + +<p>Jenkins Seed Jobs are configured using <code>Jenkins.spec.seedJobs</code> section from your custom resource manifest:</p> +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre> +<p><strong>Jenkins Operator</strong> will automatically discover and configure all the seed jobs.</p> + +<p>You can verify if deploy keys were successfully configured in the Jenkins <strong>Credentials</strong> tab.</p> + +<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-credentials.png" alt="jenkins" /></p> + +<p>You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.</p> + +<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-seed.png" alt="jenkins" /></p> + +<p>If your GitHub repository is <strong>private</strong> you have to configure SSH or username/password authentication.</p> + +<h3 id="ssh-authentication">SSH authentication</h3> + +<h4 id="generate-ssh-keys">Generate SSH Keys</h4> + +<p>There are two methods of SSH private key generation:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl genrsa -out &lt;filename&gt; <span style="color:#0000cf;font-weight:bold">2048</span></code></pre></div> +<p>or</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ ssh-keygen -t rsa -b <span style="color:#0000cf;font-weight:bold">2048</span> +$ ssh-keygen -p -f &lt;filename&gt; -m pem</code></pre></div> +<p>Then copy content from generated file.</p> + +<h4 id="public-key">Public key</h4> + +<p>If you want to upload your public key to your Git server you need to extract it.</p> + +<p>If key was generated by <code>openssl</code> then you need to type this to extract public key:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl rsa -in &lt;filename&gt; -pubout &gt; &lt;filename&gt;.pub</code></pre></div> +<p>If key was generated by <code>ssh-keygen</code> the public key content is located in <filename>.pub and there is no need to extract public key</p> + +<h4 id="configure-ssh-authentication">Configure SSH authentication</h4> + +<p>Configure a seed job like this:</p> +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-ssh + credentialType: basicSSHUserPrivateKey + credentialID: k8s-ssh + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git</code></pre> +<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> +<pre><code>apiVersion: v1 +kind: Secret +metadata: + name: k8s-ssh +stringData: + privateKey: | + -----BEGIN RSA PRIVATE KEY----- + MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO + oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 + ... + username: github_user_name</code></pre> +<h3 id="username-password-authentication">Username &amp; password authentication</h3> + +<p>Configure a seed job like this:</p> +<pre><code>apiVersion: jenkins.io/v1alpha2 +kind: Jenkins +metadata: + name: example +spec: + seedJobs: + - id: jenkins-operator-user-pass + credentialType: usernamePassword + credentialID: k8s-user-pass + targets: "cicd/jobs/*.jenkins" + description: "Jenkins Operator repository" + repositoryBranch: master + repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre> +<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> +<pre><code>apiVersion: v1 +kind: Secret +metadata: + name: k8s-user-pass +stringData: + username: github_user_name + password: password_or_token</code></pre> +<h2 id="http-proxy-for-downloading-plugins">HTTP Proxy for downloading plugins</h2> + +<p>To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins CR, for e.g.:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CURL_OPTIONS<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-L<span style="color:#f8f8f8;text-decoration:underline"> </span>-x<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;proxy_url&gt;</code></pre></div> +<p>In <code>CURL_OPTIONS</code> var you can set additional arguments to curl command.</p> + +<h2 id="jenkins-login-credentials">Jenkins login credentials</h2> + +<p>The operator automatically generates a Jenkins username and password and stores it in Kubernetes secret named +<code>jenkins-operator-credentials-&lt;cr_name&gt;</code> in the namespace where Jenkins CR has been deployed.</p> + +<p>If you want change it you can override the secret:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Secret<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-credentials-&lt;cr-name<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic">namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"> </span>user<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;base64-encoded-new-username<span style="color:#8f5902;font-style:italic">&gt; +</span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic">password: &lt;base64-encoded-new-password&gt;</span></code></pre></div> +<p>If needed <strong>Jenkins Operator</strong> will restart the Jenkins master pod and then you can login with the new username and password +credentials.</p> + +<h2 id="override-default-jenkins-container-command">Override default Jenkins container command</h2> + +<p>The default command for the Jenkins master container <code>jenkins/jenkins:lts</code> looks like:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>bash<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/var/jenkins/scripts/init.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/bin/tini<span style="color:#f8f8f8;text-decoration:underline"> </span>-s<span style="color:#f8f8f8;text-decoration:underline"> </span>--<span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/local/bin/jenkins.sh</code></pre></div> +<p>The script<code>/var/jenkins/scripts/init.sh</code> is provided by the operator and configures init.groovy.d (creates the Jenkins user) +and installs plugins. +The <code>/usr/bin/tini -s -- /usr/local/bin/jenkins.sh</code> command runs the Jenkins master main process.</p> + +<p>You can overwrite it in the following pattern:</p> +<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>bash<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> +</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/var/jenkins/scripts/init.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;custom-code-here&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/bin/tini<span style="color:#f8f8f8;text-decoration:underline"> </span>-s<span style="color:#f8f8f8;text-decoration:underline"> </span>--<span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/local/bin/jenkins.sh</code></pre></div> + + + Docs: Deploying Jenkins https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploying-jenkins/ @@ -3338,243 +3575,6 @@ stringData: - - Docs: Configuration - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ - Mon, 05 Aug 2019 00:00:00 +0000 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ - - - - - -<p>Jenkins operator uses <a href="https://github.com/jenkinsci/job-dsl-plugin">job-dsl</a> and <a href="https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/">kubernetes-credentials-provider</a> plugins for configuring jobs -and deploy keys.</p> - -<h2 id="prepare-job-definitions-and-pipelines">Prepare job definitions and pipelines</h2> - -<p>First you have to prepare pipelines and job definition in your GitHub repository using the following structure:</p> -<pre><code>cicd/ -├── jobs -│   └── build.jenkins -└── pipelines - └── build.jenkins</code></pre> -<p><strong>cicd/jobs/build.jenkins</strong> it&rsquo;s a job definition:</p> -<pre><code>#!/usr/bin/env groovy - -pipelineJob('build-jenkins-operator') { - displayName('Build jenkins-operator') - - definition { - cpsScm { - scm { - git { - remote { - url('https://github.com/jenkinsci/kubernetes-operator.git') - credentials('jenkins-operator') - } - branches('*/master') - } - } - scriptPath('cicd/pipelines/build.jenkins') - } - } -}</code></pre> -<p><strong>cicd/pipelines/build.jenkins</strong> is an actual Jenkins pipeline:</p> -<pre><code>#!/usr/bin/env groovy - -def label = "build-jenkins-operator-${UUID.randomUUID().toString()}" -def home = "/home/jenkins" -def workspace = "${home}/workspace/build-jenkins-operator" -def workdir = "${workspace}/src/github.com/jenkinsci/kubernetes-operator/" - -podTemplate(label: label, - containers: [ - containerTemplate(name: 'jnlp', image: 'jenkins/inbound-agent:alpine'), - containerTemplate(name: 'go', image: 'golang:1-alpine', command: 'cat', ttyEnabled: true), - ], - envVars: [ - envVar(key: 'GOPATH', value: workspace), - ], - ) { - - node(label) { - dir(workdir) { - stage('Init') { - timeout(time: 3, unit: 'MINUTES') { - checkout scm - } - container('go') { - sh 'apk --no-cache --update add make git gcc libc-dev' - } - } - - stage('Dep') { - container('go') { - sh 'make dep' - } - } - - stage('Test') { - container('go') { - sh 'make test' - } - } - - stage('Build') { - container('go') { - sh 'make build' - } - } - } - } -}</code></pre> -<h2 id="configure-seed-jobs">Configure Seed Jobs</h2> - -<p>Jenkins Seed Jobs are configured using <code>Jenkins.spec.seedJobs</code> section from your custom resource manifest:</p> -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre> -<p><strong>Jenkins Operator</strong> will automatically discover and configure all the seed jobs.</p> - -<p>You can verify if deploy keys were successfully configured in the Jenkins <strong>Credentials</strong> tab.</p> - -<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-credentials.png" alt="jenkins" /></p> - -<p>You can verify if your pipelines were successfully configured in the Jenkins Seed Job console output.</p> - -<p><img src="https://jenkinsci.github.io/kubernetes-operator/kubernetes-operator/img/jenkins-seed.png" alt="jenkins" /></p> - -<p>If your GitHub repository is <strong>private</strong> you have to configure SSH or username/password authentication.</p> - -<h3 id="ssh-authentication">SSH authentication</h3> - -<h4 id="generate-ssh-keys">Generate SSH Keys</h4> - -<p>There are two methods of SSH private key generation:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl genrsa -out &lt;filename&gt; <span style="color:#0000cf;font-weight:bold">2048</span></code></pre></div> -<p>or</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ ssh-keygen -t rsa -b <span style="color:#0000cf;font-weight:bold">2048</span> -$ ssh-keygen -p -f &lt;filename&gt; -m pem</code></pre></div> -<p>Then copy content from generated file.</p> - -<h4 id="public-key">Public key</h4> - -<p>If you want to upload your public key to your Git server you need to extract it.</p> - -<p>If key was generated by <code>openssl</code> then you need to type this to extract public key:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">$ openssl rsa -in &lt;filename&gt; -pubout &gt; &lt;filename&gt;.pub</code></pre></div> -<p>If key was generated by <code>ssh-keygen</code> the public key content is located in <filename>.pub and there is no need to extract public key</p> - -<h4 id="configure-ssh-authentication">Configure SSH authentication</h4> - -<p>Configure a seed job like this:</p> -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator-ssh - credentialType: basicSSHUserPrivateKey - credentialID: k8s-ssh - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: git@github.com:jenkinsci/kubernetes-operator.git</code></pre> -<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> -<pre><code>apiVersion: v1 -kind: Secret -metadata: - name: k8s-ssh -stringData: - privateKey: | - -----BEGIN RSA PRIVATE KEY----- - MIIJKAIBAAKCAgEAxxDpleJjMCN5nusfW/AtBAZhx8UVVlhhhIKXvQ+dFODQIdzO - oDXybs1zVHWOj31zqbbJnsfsVZ9Uf3p9k6xpJ3WFY9b85WasqTDN1xmSd6swD4N8 - ... - username: github_user_name</code></pre> -<h3 id="username-password-authentication">Username &amp; password authentication</h3> - -<p>Configure a seed job like this:</p> -<pre><code>apiVersion: jenkins.io/v1alpha2 -kind: Jenkins -metadata: - name: example -spec: - seedJobs: - - id: jenkins-operator-user-pass - credentialType: usernamePassword - credentialID: k8s-user-pass - targets: "cicd/jobs/*.jenkins" - description: "Jenkins Operator repository" - repositoryBranch: master - repositoryUrl: https://github.com/jenkinsci/kubernetes-operator.git</code></pre> -<p>and create a Kubernetes Secret (name of secret should be the same from <code>credentialID</code> field):</p> -<pre><code>apiVersion: v1 -kind: Secret -metadata: - name: k8s-user-pass -stringData: - username: github_user_name - password: password_or_token</code></pre> -<h2 id="http-proxy-for-downloading-plugins">HTTP Proxy for downloading plugins</h2> - -<p>To use forwarding proxy with an operator to download plugins you need to add the following environment variable to Jenkins CR, for e.g.:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">spec<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>master<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>containers<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-master<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>env<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>CURL_OPTIONS<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>value<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>-L<span style="color:#f8f8f8;text-decoration:underline"> </span>-x<span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;proxy_url&gt;</code></pre></div> -<p>In <code>CURL_OPTIONS</code> var you can set additional arguments to curl command.</p> - -<h2 id="jenkins-login-credentials">Jenkins login credentials</h2> - -<p>The operator automatically generates a Jenkins username and password and stores it in Kubernetes secret named -<code>jenkins-operator-credentials-&lt;cr_name&gt;</code> in the namespace where Jenkins CR has been deployed.</p> - -<p>If you want change it you can override the secret:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">apiVersion<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>v1<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>kind<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>Secret<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>metadata<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>name<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>jenkins-operator-credentials-&lt;cr-name<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic">namespace: &lt;namespace&gt;</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>data<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"> </span>user<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;base64-encoded-new-username<span style="color:#8f5902;font-style:italic">&gt; -</span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic"> </span><span style="color:#8f5902;font-style:italic">password: &lt;base64-encoded-new-password&gt;</span></code></pre></div> -<p>If needed <strong>Jenkins Operator</strong> will restart the Jenkins master pod and then you can login with the new username and password -credentials.</p> - -<h2 id="override-default-jenkins-container-command">Override default Jenkins container command</h2> - -<p>The default command for the Jenkins master container <code>jenkins/jenkins:lts</code> looks like:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>bash<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/var/jenkins/scripts/init.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/bin/tini<span style="color:#f8f8f8;text-decoration:underline"> </span>-s<span style="color:#f8f8f8;text-decoration:underline"> </span>--<span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/local/bin/jenkins.sh</code></pre></div> -<p>The script<code>/var/jenkins/scripts/init.sh</code> is provided by the operator and configures init.groovy.d (creates the Jenkins user) -and installs plugins. -The <code>/usr/bin/tini -s -- /usr/local/bin/jenkins.sh</code> command runs the Jenkins master main process.</p> - -<p>You can overwrite it in the following pattern:</p> -<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-yaml" data-lang="yaml">command<span style="color:#000;font-weight:bold">:</span><span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>bash<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>-c<span style="color:#f8f8f8;text-decoration:underline"> -</span><span style="color:#f8f8f8;text-decoration:underline"></span>-<span style="color:#f8f8f8;text-decoration:underline"> </span>/var/jenkins/scripts/init.sh<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>&lt;custom-code-here&gt;<span style="color:#f8f8f8;text-decoration:underline"> </span><span style="color:#8f5902;font-style:italic">&amp;&amp;</span><span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/bin/tini<span style="color:#f8f8f8;text-decoration:underline"> </span>-s<span style="color:#f8f8f8;text-decoration:underline"> </span>--<span style="color:#f8f8f8;text-decoration:underline"> </span>/usr/local/bin/jenkins.sh</code></pre></div> - - - Docs: Configuration https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.2.x/configuration/ @@ -8817,4 +8817,4 @@ the restart of a Jenkins pod over and over again.</p> - + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 5d4d474b..f108e8a2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -25,7 +25,7 @@ - + diff --git a/docs/index.xml b/docs/index.xml index 7bf32af0..b0f51b95 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -4,7 +4,7 @@ https://jenkinsci.github.io/kubernetes-operator/ Recent Hugo news from gohugo.io Hugo -- gohugo.io - Sun, 08 Jan 2023 00:00:00 +0000 + Thu, 12 Jan 2023 00:00:00 +0000 https://jenkinsci.github.io/kubernetes-operator/img/hugo.png GoHugo.io diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 15b1f403..56629ab6 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -57,6 +57,11 @@ 2019-08-05T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ + 2023-01-12T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/deploying-jenkins/ 2021-12-08T00:00:00+00:00 @@ -92,11 +97,6 @@ 2019-12-20T00:00:00+00:00 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.1.x/configuration/ - 2019-08-05T00:00:00+00:00 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.2.x/configuration/ 2019-08-05T00:00:00+00:00 @@ -167,6 +167,11 @@ 2021-08-19T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ + 2023-01-12T00:00:00+00:00 + + https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/latest/configuring-backup-and-restore/ 2023-01-08T00:00:00+00:00 @@ -177,11 +182,6 @@ 2021-12-08T00:00:00+00:00 - - https://jenkinsci.github.io/kubernetes-operator/docs/developer-guide/ - 2021-10-20T00:00:00+00:00 - - https://jenkinsci.github.io/kubernetes-operator/docs/getting-started/v0.2.x/ 2021-08-19T00:00:00+00:00 @@ -439,7 +439,7 @@ https://jenkinsci.github.io/kubernetes-operator/ - 2023-01-08T00:00:00+00:00 + 2023-01-12T00:00:00+00:00 diff --git a/website/content/en/docs/Developer Guide/_index.md b/website/content/en/docs/Developer Guide/_index.md index 92202f0c..af17b75e 100644 --- a/website/content/en/docs/Developer Guide/_index.md +++ b/website/content/en/docs/Developer Guide/_index.md @@ -2,7 +2,7 @@ title: "Developer Guide" linkTitle: "Developer Guide" weight: 5 -date: 2021-10-20 +date: 2023-01-12 description: > Jenkins Operator for developers --- diff --git a/website/content/en/docs/Getting Started/v0.1.x/configuration.md b/website/content/en/docs/Getting Started/v0.1.x/configuration.md index 3054e2e2..f8f8789d 100644 --- a/website/content/en/docs/Getting Started/v0.1.x/configuration.md +++ b/website/content/en/docs/Getting Started/v0.1.x/configuration.md @@ -2,7 +2,7 @@ title: "Configuration" linkTitle: "Configuration" weight: 2 -date: 2019-08-05 +date: 2023-01-12 description: > How to configure Jenkins with Operator ---