Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-55544

kubernetes-plugin creates blank kubeconfig

    Details

    • Similar Issues:

      Description

      I setup a kubernetes credentials with raw content:

      When I use it referring only with the credentials-id as follows:

      steps {
       withKubeConfig([credentialsId: 'kubernetes-mkp-int' ,
       ]) {
       sh 'kubectl get pods'
       sh 'helm get mkp-int --tiller-namespace mkp-int'
       }
       }

       

       

      It fails:

       

      {[Pipeline] withKubeConfig$ kubectl config set-cluster k8s --server=null --insecure-skip-tls-verify=true Cluster "k8s" set.
      [Pipeline] // withKubeConfig[Pipeline] }
      [Pipeline] // withEnv[Pipeline] }
      [Pipeline] // node
      [Pipeline] }[Pipeline] // stage[Pipeline] }
      [Pipeline] // withEnv[Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node[Pipeline] End of PipelineERROR: Unsupported Credentials type com.microsoft.jenkins.kubernetes.credentials.KubeconfigCredentials
      Finished: FAILURE

       

       

      In the workspace, a kubeconfig file has been created but it has nothing in common with my credentials defined.

       

      cat .kube6838469646141525001config
      apiVersion: v1
      clusters:
      - cluster:
      insecure-skip-tls-verify: true
      server: "null"
      name: k8s
      contexts: []
      current-context: ""
      kind: Config
      preferences: {}
      users: []

       

      I have one kubernetes credentials added and I have been tested that changing the 

      I'm doing something wrong or it's a bug?

       

        Attachments

          Activity

          Hide
          max_laverse Max Laverse added a comment -

          Hi Ruben Fernandez,
          What type of credential do you use ?
          The plugins detects a credential as being a raw Kube configuration if it's a FileCredential (I'll fix the doc once this issue is solved)
          https://github.com/jenkinsci/kubernetes-cli-plugin/blob/master/src/main/java/org/jenkinsci/plugins/kubernetes/cli/kubeconfig/KubeConfigWriter.java#L82-L83

          Show
          max_laverse Max Laverse added a comment - Hi Ruben Fernandez , What type of credential do you use ? The plugins detects a credential as being a raw Kube configuration if it's a FileCredential (I'll fix the doc once this issue is solved) https://github.com/jenkinsci/kubernetes-cli-plugin/blob/master/src/main/java/org/jenkinsci/plugins/kubernetes/cli/kubeconfig/KubeConfigWriter.java#L82-L83
          Hide
          rubick Ruben Fernandez added a comment -

          The credentials kind is "Kubernetes configuration (kubeconfig)" with FileCredential works fine.

          I find confused how to use a kubeconfig credentials in general. I was following this doc https://wiki.jenkins.io/display/JENKINS/Kubernetes+Cli+Plugin that used its own credentials type.

           

          Nevertheless, thanks for clarify that I need to use File Credentials.

           

           

          Show
          rubick Ruben Fernandez added a comment - The credentials kind is "Kubernetes configuration (kubeconfig)" with FileCredential works fine. I find confused how to use a kubeconfig credentials in general. I was following this doc https://wiki.jenkins.io/display/JENKINS/Kubernetes+Cli+Plugin  that used its own credentials type.   Nevertheless, thanks for clarify that I need to use File Credentials.    
          Hide
          max_laverse Max Laverse added a comment -

          Apparently this credential type comes from https://github.com/jenkinsci/kubernetes-cd-plugin.

          What did you mean with "I find confused how to use a kubeconfig credentials in general. I was following this doc https://wiki.jenkins.io/display/JENKINS/Kubernetes+Cli+Plugin that used its own credentials type." ?

          It was from another page right ? Because I only listed the supported plugins here, and credentials from kubernetes-cd-plugin are not part of it. But I might have put a broken link somewhere, just checking

          Show
          max_laverse Max Laverse added a comment - Apparently this credential type comes from https://github.com/jenkinsci/kubernetes-cd-plugin . What did you mean with "I find confused how to use a kubeconfig credentials in general. I was following this doc https://wiki.jenkins.io/display/JENKINS/Kubernetes+Cli+Plugin that used its own credentials type." ? It was from another page right ? Because I only listed the supported plugins here, and credentials from kubernetes-cd-plugin are not part of it. But I might have put a broken link somewhere, just checking
          Hide
          rubick Ruben Fernandez added a comment -

          I think I saw quickly this image
          https://github.com/jenkinsci/kubernetes-cli-plugin/blob/master/img/webui.png and I associate to credentials of kubernetes-cd-plugin. My fault, reading again the doc all is clear.

          Show
          rubick Ruben Fernandez added a comment - I think I saw quickly this image https://github.com/jenkinsci/kubernetes-cli-plugin/blob/master/img/webui.png and I associate to credentials of kubernetes-cd-plugin. My fault, reading again the doc all is clear.
          Hide
          max_laverse Max Laverse added a comment -

          ok great, thanks

          Show
          max_laverse Max Laverse added a comment - ok great, thanks

            People

            • Assignee:
              max_laverse Max Laverse
              Reporter:
              rubick Ruben Fernandez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: