Skip to content

Allows you to setup kubectl to access Kubernetes clusters from your Jenkins jobs.

License

Notifications You must be signed in to change notification settings

creepyghost/kubernetes-cli-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Cli Plugin

build-status

Allows you to configure kubectl in your job to interact with Kubernetes clusters. Any tool built on top of kubectl can then be used from your pipelines, e.g. kubernetes-deploy to perform deployments.

Initially extracted and rewritten from the Kubernetes Plugin.

Supported credentials

The following types of credentials are supported and can be used to authenticate against Kubernetes clusters:

Quick usage guide

Pipeline usage

The kubernetes-cli plugin provides the function withKubeConfig() for Jenkins Pipeline support. You can go to the Snippet Generator page under Pipeline Syntax section in Jenkins, select withKubeConfig: Setup Kubernetes CLI from the Sample Step dropdown, and it will provide you configuration interface for the plugin. After filling the entries and click Generate Pipeline Script button, you will get the sample scripts which can be used in your Pipeline definition.

The arguments to the withKubeConfig step are:

  • credentialsId - the Jenkins identifier of the credentials to use.
  • caCertificate - an optional base64-encoded certificate to check the Kubernetes api server's against. If you don't specify one, the CA verification will be skipped.
  • serverUrl - the url of the api server

Example:

node {
  stage('List pods') {
    withKubeConfig([credentialsId: '<credential-id>', caCertificate: '<ca-certificate>', serverUrl: '<api-server-address>']) {
      sh 'kubectl get pods'
    }
  }
}

From the web interface

In Jenkins > job name > Configure > Build Environment

webui

Brief description of the named fields:

  • credentialsId - the Jenkins identifier of the credentials to use.
  • caCertificate - an optional base64-encoded certificate to check the Kubernetes api server's against
  • serverUrl - the url of the api server

Reporting an issue

Please file bug reports directly on the Jenkins issue tracker

Building and Testing

To build the extension, run:

mvn clean package

and upload target/kubernetes-cli.hpi to your Jenkins installation.

To run the tests:

mvn clean test

About

Allows you to setup kubectl to access Kubernetes clusters from your Jenkins jobs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 97.5%
  • Groovy 1.7%
  • HTML 0.8%