<p>I've recently used google Kubernetes engine to deploy my magento project and i successfully deployed it. and my next step was in each git push my jenkins pipeline will start building and update the project in my kubernetes cluster.
i've been looking for tutorials but i got no documentation about how to run kubectl in jenkins with my GKE credentials.
if anyone is familiar with this kind of task and have any reference please help me.</p>

nessHaf
<p>Actually you're asking for this question</p>
<blockquote>
<p>how to run kubectl in jenkins with my GKE credentials</p>
</blockquote>
<p>In a research of how you can manage it I found this <a href="https://blog.bewgle.com/2020/04/13/setting-up-ci-cd-for-gke-with-jenkins/" rel="nofollow noreferrer">tutorial</a> about Setting up CI/CD for GKE with Jenkins which contains the steps in order to build an update the project. You can also take a look for whole tutorial, might help you with your project.<br>
But we're going to check the part where it says <strong>Jenkins Job Build</strong>; you'll find the authentication method and getting the credentials for cluster:</p>
<blockquote>
<p>#To activate creds for the first time, can also be done in Jenkins machine directly and get credentials for kubectl</p>
<pre><code>gcloud auth activate-service-account account_name --key-file [KEY_FILE]
</code></pre>
<p>#Get credentials for cluster</p>
<pre><code>gcloud container clusters get-credentials &lt;cluster-name&gt; --zone &lt;zone-name&gt; --project &lt;project-name&gt;
</code></pre>
</blockquote>
<p>And also, deploying it to the project:</p>
<blockquote>
<p>#To create new deployment</p>
<pre><code>kubectl create deployment &lt;deployment-name&gt; --image=gcr.io/&lt;project-name&gt;/nginx:${version}
</code></pre>
<p>#For rolling update</p>
<pre><code>kubectl set image deployment/&lt;app_name&gt; nginx=gcr.io/&lt;project-name&gt;/&lt;appname&gt;/nginx:${version} --record
</code></pre>
</blockquote>
