Why does kubectl work locally but fail in my Windows deployment pipeline?

November 13, 2026 4 answers
Asked by SALTWATER DATABASE

I'm learning Kubernetes and trying to deploy a Java app to my local machine through a CI/CD pipeline. The kubectl commands work when I run them manually, but the pipeline fails while trying to connect to localhost on port 8080. What should I check?

Answers

decaf!during+overtime

Start with the kubeconfig available to the runner. The error suggests kubectl is trying localhost:8080 rather than reaching the cluster you use manually. A self-hosted runner may run under a different Windows account, with a different home directory and no access to your kubeconfig.

In a diagnostic step, check the runner's current user, the KUBECONFIG environment variable, and kubectl config current-context. You can also use kubectl config view to inspect the selected server, but avoid printing credentials or the full contents of a config containing secrets. Point the runner at a kubeconfig it can read, then test kubectl get namespace before attempting the deployment.

no_umbrella_required:

Also check that the config's authentication method works for the runner account. Finding the file alone doesn't guarantee it can authenticate.

Reply to this answer
mIxed_case_manual

Check where the job is actually running. Localhost means the machine running that particular command, not automatically the machine where you tested kubectl. If the runner is elsewhere, localhost points back to that runner.

The runner needs a reachable Kubernetes API endpoint as well as the right credentials. Even on the same Windows machine, check whether the API address in the kubeconfig is accessible from the runner's environment.

Reply to this answer
pardon_my_paintbrush

Don't rely on --validate=false to fix this. It changes validation behavior, but kubectl still needs to reach the API server to apply resources. Get a simple kubectl get namespace working in the pipeline first, then troubleshoot the manifest if apply still fails.

Reply to this answer
circuitous_lunchbreak

I'd also reconsider deleting the namespace on every deployment. Namespace deletion removes its resources and can take time to finish, so an immediate apply can run into a namespace that's still terminating. For a normal update, try applying the manifests without deleting the namespace first.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions