<p>I use kubernetes-cd plugin in Jenkins (<a href="https://plugins.jenkins.io/kubernetes-cd/" rel="nofollow noreferrer">https://plugins.jenkins.io/kubernetes-cd/</a>) to deploy my application successfully.</p>

<p><a href="https://i.stack.imgur.com/Kh8dC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kh8dC.png" alt="enter image description here"></a></p>

<p>But, I got a problem, when I re-run the job again, the jenkins doesn't update my pod (doesn't delete and create new pod again), so my changes of code aren't affected. And after I delete the pod manual using kubectl commands in kubernetes cluster and re-run the job, it make changes</p>

<p>Below is my yaml file. Do you know how to fix this ?</p>

<pre><code>---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: tds-upload
  name: tds-upload
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tds-upload
  template:
    metadata:
      labels:
        app: tds-upload
    spec:
      containers:
      - image: dev-master:5000/tds-upload:1.0.0
        imagePullPolicy: Always
        name: tds-upload

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: tds-upload
  name: tds-upload
spec:
  ports:
  - nodePort: 31313
    port: 8889
    protocol: TCP
    targetPort: 8889
  selector:
    app: tds-upload
  type: NodePort
</code></pre>

taibc
<p>There are different ways to make Kubernetes deploy new changes.</p>

<ol>
<li><code>kubectl rollout restart deployment myapp</code></li>
</ol>

<p>This is the current way to trigger a rolling update and leave the old replica sets in place for other operations provided by kubectl rollout like rollbacks</p>

<ol start="2">
<li><code>kubectl patch deployment my-deployment -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"build\":\"$CI_COMMIT_SHORT_SHA\"}}}}}}"</code></li>
</ol>

<p>Where you can use any name and any value for the label as long as it changes with each build.</p>

<p>You can use the <a href="https://github.com/jenkinsci/kubernetes-cli-plugin" rel="nofollow noreferrer">kubectl cli plugin</a> of Jenkins to execute above commands. </p>
