title: Running kubectl command from jenkins container
body: <p>I installed minikube on a VirtualBox(ubuntu) to simulate a deploy environment and used Jenkins pipeline.
  On my jenkins container i also installed kubectl command to control minikube.</p>
  
  <p>So i create the following stage: </p>
  
  <pre><code>stage("k8s command test") {                        
          withCredentials([usernamePassword(credentialsId: 'cbcba826-ef01-4b18-856f-e6dc4eb27c1f', usernameVariable: 'my-user', passwordVariable: 'PASSWORD')]) {
              sh """
                  kubectl config view
                  kubectl create -f /home/my-user/file-svc.yml
              """
          }
      }
  </code></pre>
  
  <p>First thing my cluster seems to be empty in output i have :</p>
  
  <pre><code>+ kubectl config view
  apiVersion: v1
  clusters: []
  contexts: []
  current-context: ""
  kind: Config
  preferences: {}
  users: []
  </code></pre>
  
  <p>if i check .kube/config i have the following config : </p>
  
  <pre><code>apiVersion: v1
  clusters:
  - cluster:
      certificate-authority: /home/my-user/.minikube/ca.crt
      server: https://127.0.0.1:8443
    name: minikube
  contexts:
  - context:
      cluster: minikube
      user: minikube
    name: minikube
  current-context: minikube
  kind: Config
  preferences: {}
  users:
  - name: minikube
    user:
      as-user-extra: {}
      client-certificate: /home/my-user/.minikube/client.crt
      client-key: /home/my-user/.minikube/client.key
  </code></pre>
  
  <p>As i'm new on kubernetes i need help to understand how to make possible the communication between jenkins and minikube.</p>
  
  <p>consequently kubectl create -f /home/my-user/file-svc.yml raised an error about authentication.
  I read many article kubectl need certificate to be connected to the API server how can i do that in jenkins </p>