<p>I have created a kubernetes cluster and deployed jenkins by following file </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
 name: jenkins-ci
spec:
 replicas: 1
 template:
  metadata:
   labels:
    run: jenkins-ci
  spec:
    containers:
    - name: jenkins-ci
      image: jenkins:2.32.2 
      ports:
      - containerPort: 8080
</code></pre>

<p>and service by </p>

<pre><code>apiVersion: v1
kind: Service
metadata: 
  name: jenkins-cli-lb
spec: 
  type: NodePort
  ports:
    # the port that this service should serve on
    - port: 8080
      nodePort: 30000
  # label keys and values that must match in order to receive traffic for this service
  selector: 
    run: jenkins-ci
</code></pre>

<p>Now i can access jenkins UI in my browser without any problems. My issue I came into situation in which need to restart jenkins service manually??</p>

<p>Just <code>kubectl delete pods -l run=jenkins-ci</code> - Will delete all pods with this label (your jenkins containers).
Since they are under Deployment, it will re-create the containers. Network routing will be adjusted automatically (again because of the label selector).</p>

<p>See <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/kubectl/cheatsheet/</a></p>
