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

Setup Kubernetes CLI (kubectl) error: "FATAL: Failed to run kubectl version 1"

XMLWordPrintable

    • kubernetes 1.23.3

      In latest release (1.23.0) I'm getting the below error while trying to use the "Setup Kubernetes CLI (kubectl)" in a job where field "Certificate of authority" is empty and field "Credentials" is populated from type "Username and password":

      [...]
      Building in workspace /var/jenkins_home/workspace/backups
      $ kubectl version
      FATAL: Failed to run kubectl version 1
      java.io.IOException: Failed to run kubectl version 1
      at org.csanchez.jenkins.plugins.kubernetes.KubectlBuildWrapper.setUp(KubectlBuildWrapper.java:94)
      at jenkins.tasks.SimpleBuildWrapper.setUp(SimpleBuildWrapper.java:146)
      at hudson.model.Build$BuildExecution.doRun(Build.java:157)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
      at hudson.model.Run.execute(Run.java:1853)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:427)
      Finished: FAILURE

      The previous version (1.22.5) works fine and after downgrading all jobs started to work again.
      This happened in two independent Jenkins boxes running the latest LTS Jenkins ver. 2.204.1.

       

      After further investigation, the issue seems to be related to kubernetes config file setup. Although I didn't specify a certificate, the property insecure-skip-tls-verify is set to false, plus the current-context is not set. Sample generated file below: 

      $ cat .kube2280516965942825275config
      ---
      clusters:
      - cluster:
       insecure-skip-tls-verify: false
       server: "https://api.k8s-cluster.dummy.com"
       name: "k8s"
      contexts:
      - context:
       cluster: "k8s"
       user: "cluster-admin"
       name: "k8s"
      users:
      - name: "cluster-admin"
       user:
       as-user-extra: {}
       password: "XXXXXXXXXXXXX"
       username: "jenkins"

       

            vlatombe Vincent Latombe
            salavessa João Salavessa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: