1
votes

I have an experimental pipeline using: Jenkins, minikube, and docker for windows. Both docker and Jenkins are started with windows startup, then I start minikube using

minekube start

In the pipeline, I have the command bat "kubectl apply -f deployment.yaml" I get from Jenkins

Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

However, when I run the same command in power shell, it runs correctly. From power shell also when I run command kubectl config get-contexts I get

CURRENT   NAME                 CLUSTER          AUTHINFO         NAMESPACE
          docker-desktop       docker-desktop   docker-desktop
          docker-for-desktop   docker-desktop   docker-desktop
*         minikube             minikube         minikube

and when I run kubectl config view , from power shell, I get

apiVersion: v1 clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://kubernetes.docker.internal:6443   name: docker-desktop
- cluster:
    certificate-authority: C:\Users\shady1\.minikube\ca.crt
    **server: https://127.0.0.1:32768**   name: minikube contexts:
- context:
    cluster: docker-desktop
    user: docker-desktop   name: docker-desktop
- context:
    cluster: docker-desktop
    user: docker-desktop   name: docker-for-desktop
- context:
    cluster: minikube
    user: minikube   name: minikube current-context: minikube kind: Config preferences: {} users:
- name: docker-desktop   user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
- name: minikube   user:
    client-certificate: C:\Users\shady1\.minikube\profiles\minikube\client.crt
    client-key: C:\Users\shady1\.minikube\profiles\minikube\client.key

and when I run kubectl config view , from Jenkins pipeline, I get

apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null

Any hints, please?

1

1 Answers

2
votes

adding environment variable KUBECONFIG=C:\Users\shady1.kube\config solved the issue