<p>I have an azure release pipeline on my self hosted computer. I can run kubectl command on my local machine.</p>
<p><a href="https://i.stack.imgur.com/kSRL3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kSRL3.png" alt="enter image description here" /></a></p>
<p>when it runs the <code>kubectl apply</code> step of release, it throws exception.</p>
<pre><code>2023-03-07T05:57:28.6055463Z ==============================================================================
2023-03-07T05:57:28.6056482Z Task         : Kubectl
2023-03-07T05:57:28.6057456Z Description  : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands
2023-03-07T05:57:28.6058070Z Version      : 0.216.0
2023-03-07T05:57:28.6058624Z Author       : Microsoft Corporation
2023-03-07T05:57:28.6059197Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/kubernetes
2023-03-07T05:57:28.6060090Z ==============================================================================
2023-03-07T05:57:29.4681708Z [command]C:\ProgramData\chocolatey\bin\kubectl.exe --kubeconfig C:\agent-demos\_work\_temp\kubectlTask\1678168649409\config apply -n default -f C:\agent-demos\_work\r1\a\_app-web-ui\k8s-deployment.yml
2023-03-07T05:57:29.6838186Z Unable to connect to the server: getting credentials: exec: executable gke-gcloud-auth-plugin.exe not found
2023-03-07T05:57:29.6839030Z 
2023-03-07T05:57:29.6839663Z It looks like you are trying to use a client-go credential plugin that is not installed.
2023-03-07T05:57:29.6840006Z 
2023-03-07T05:57:29.6840458Z To learn more about this feature, consult the documentation available at:
2023-03-07T05:57:29.6841141Z       https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins
2023-03-07T05:57:29.6841504Z 
2023-03-07T05:57:29.6842121Z Install gke-gcloud-auth-plugin for use with kubectl by following https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
2023-03-07T05:57:29.7040543Z ##[error]The process 'C:\ProgramData\chocolatey\bin\kubectl.exe' failed with exit code 1
</code></pre>
<p>I have installed <code>gke-gcloud-auth-plugin</code> but did not work.</p>
<p>I run the command on local machine:</p>
<pre><code>gcloud container clusters get-credentials CLUSTER_NAME
</code></pre>
<p>and it returned:</p>
<pre><code>Fetching cluster endpoint and auth data.
kubeconfig entry generated for gisarts.
</code></pre>
<p>I applied the <a href="https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke" rel="nofollow noreferrer">kubectl auth changes</a>, but did not work.</p>
<p>How can I fix this? Is self hosted agent runs as local system user?</p>

barteloma
<p>If you installed kubectl or gcloud cli by windows user '<code>someuser</code>', Azure self hosted agent shoud use this user. So open the services in windows os. And find the agent service named '<code>Azure Pipelines Agent (organization.project)</code>' and double click it. Opened window has a tab named <code>Log On</code> and select This Account radio button to type <code>someuser</code> and <code>password</code>. This allows azure agent to do your build and deployments.</p>
