<p>I'm trying to run Jenkins in Kubernetes but the version of Jenkins is outdated. It says I need atleast version 2.138.4 for the Kubernetes plugin.</p>

<p>Im using <a href="https://hub.docker.com/r/jenkins/jenkins/" rel="nofollow noreferrer">this</a> jenkins image from Docker hub ("jenkins/jenkins:lts"). But when I try to run this in Kubernetes it says the version is 2.60.3. I previously used a really old version of Jenkins (2.60.3) but I updated my Dockerfile to use the latest image. After that I build the image again and threw it to Kubernetes. I even delete my Kubernetes Deployment and Service before deploying them again.
I'm currently working in a development environment using Minikube.</p>

<p>Dockerfile:</p>

<pre><code>FROM jenkins/jenkins:lts

ENV JENKINS_USER admin
ENV JENKINS_PASS admin

# Skip initial setup
ENV JAVA_OPTS -Djenkins.install.runSetupWizard=false


COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/install-plugins.sh &lt; /usr/share/jenkins/plugins.txt
USER root
RUN apt-get update \
  &amp;&amp; apt-get install -qqy apt-transport-https ca-certificates curl gnupg2 software-properties-common 
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/debian \
  $(lsb_release -cs) \
  stable"
RUN apt-get update  -qq \
  &amp;&amp; apt-get install docker-ce -y
RUN usermod -aG docker jenkins
RUN apt-get clean
RUN curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose &amp;&amp; chmod +x /usr/local/bin/docker-compose
USER jenkins 
</code></pre>

<p>The Kubernetes deployment:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      containers:
        - name: jenkins
          image: mikemanders/my-jenkins-image:1.0
          env:
            - name: JAVA_OPTS
              value: -Djenkins.install.runSetupWizard=false
          ports:
            - name: http-port
              containerPort: 8080
            - name: jnlp-port
              containerPort: 50000
          volumeMounts:
            - name: jenkins-home
              mountPath: /var/jenkins_home
      volumes:
        - name: jenkins-home
          emptyDir: {}

</code></pre>

<p>And the Kubernetes Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: jenkins
spec:
  type: NodePort
  selector:
    app: jenkins
  ports:
    - port: 8080
      targetPort: 8080

</code></pre>

<p>I think my Kubernetes configuration are good, so I'm guessing it has something to do with Docker?</p>

<p>What am I missing/doing wrong here?</p>

<h2>TL;DR</h2>

<p>To <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment" rel="nofollow noreferrer">update a deployment</a>, you need new <code>Docker</code> image based on the new <code>Jenkins</code> release:</p>

<pre><code>docker build -t mikemanders/my-jenkins-image:1.1 .
docker push mikemanders/my-jenkins-image
kubectl set image deployment/jenkins mikemanders/my-jenkins-image=1.1 --record
</code></pre>

<h2><code>Kubernetes</code> deploys <code>images</code> not <code>dockerfiles</code></h2>

<p>As per <a href="https://kubernetes.io/docs/concepts/containers/images/" rel="nofollow noreferrer">Images man</a></p>

<blockquote>
  <p>You create your Docker image and push it to a registry before referring to it in a Kubernetes pod.</p>
  
  <p>The <code>image</code> property of a container supports the same syntax as the <code>docker</code> command does, including private registries and tags.</p>
</blockquote>

<p>So, you need an image to deploy.</p>

<h2>Update your image</h2>

<p>To update your image in registry, use <code>docker build -t</code> and <code>docker push</code>:</p>

<pre><code>docker build -t mikemanders/my-jenkins-image:1.1
docker push mikemanders/my-jenkins-image
</code></pre>

<p>It will rebuild the image with updated <code>jenkins/jeinkis:lts</code>. Then image will be uploaded to the <a href="https://kubernetes.io/docs/concepts/containers/images/#using-a-private-registry" rel="nofollow noreferrer">container registry</a>.</p>

<p>The catch is that you are updating the image version (e.g. <code>1.0</code>-><code>1.1</code>) before updating the cluster.</p>
