<p>I'm intending to have a CD Pipeline with Jenkins which takes my application, publishes a docker image to my private docker repository. I think I know how to do that. </p>

<p>What I'm unsure about it the Kubernetes part. I want to take that image and deploy it to my private Kubernetes cluster (currently 1 Master &amp; 1 Slave). </p>

<p>Question: Does that Jenkins Slave which has kubectl and docker installed need to be part of the Kubernetes cluster in order to trigger a deployment? How can I trigger that deployment?</p>

<p>Assuming that you have the following deployment in your cluster:</p>

<pre><code>apiVersion: apps/v1beta1 # for versions before 1.6.0 use 
extensions/v1beta1
kind: Deployment
metadata:
   name: foobar-deployment
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: foobar-app
    spec:
      containers:
      - name: foobar
        image: foobar-image:v1
        ports:
        - containerPort: 80
</code></pre>

<p>You would have to somehow have Jenkins tell your Kubernetes master the following command:    </p>

<pre><code>kubectl set image deployment/foobar-deployment foobar=foobar-image:version
</code></pre>

<p>where <code>version</code> is the new verion you just created with Jenkins. This will automatically trigger a redeploy with this version.</p>

<p>As long as you have access to your Kubernetes master that has your cluster on it (via ssh or similar), you can just pass the above command. Don't forget to keep track of <code>version</code> when you pass this command.</p>
