Kubectl

6 minute readExtensibilityDeveloper productivity

This plugin integrates with the command-line tool, kubectl, to deploy and manage applications on Kubernetes. It provides procedures to manage Kubernetes objects using an imperative approach where objects can be created, updated, or deleted, using kubectl commands in conjunction with a YAML configuration file.

Plugin version 1.2.0.2021033110

Revised on September 17, 2020

Supported Versions

The plugin has been tested with the following versions:

  • 1.10 (patch versions 6, 7, 9, 11)

  • 1.11 (patch versions 2,3,4,5)

Kubernetes versions earlier to the above were tested briefly, considering that the general recommendation has been to move to the above versions, due to security vulnerability issues.

Plugin Configurations

Plugin configurations are sets of parameters that apply across some or all of the plugin procedures. They reduce repetition of common values, create predefined parameter sets for end users, and securely store credentials where needed. Each configuration is given a unique name that is entered in designated parameters on procedures that use them.

Creating Plugin Configurations

To create plugin configurations in CloudBees CD, do these steps:

  • Go to Administration >Plugins to open the Plugin Manager.

  • Find the EC-Kubectl-1.2.0.2021033110 row.

  • Click Configure to open the Configurations page.

  • Click Create Configuration as per the description of parameters below.

Configuration Procedure Parameters

ParameterDescription

Configuration

Required. Unique name for the plugin configuration.

Description

Description for the plugin configuration.

Kubectl Path

Required. Absolute path to kubectl. For example /var/kubectl

Kubeconfig Source

Required. Source of the Kubeconfig content required by Kubectl. If content comes from a file that Kubectl looks by default (as per google documentation) choose kubeconfigDefault. If content comes from what the user types in the Kubeconfig Content text area choose kubeconfigContent. If content comes from a specific file that user types in Kubeconfig Path text box choose kubeconfigPath.

Kubeconfig Path

Used only if kubeconfigSource is 'kubeconfigPath' (should be empty otherwise). Absolute path to Kubeconfig file. For example /var/kconfig.config

Kubeconfig Content

Used only if kubeconfigSource is 'kubeconfigContent' (should be empty otherwise). In the label textbox type any string to identify the content for example mylabel. In the content text area type the content used by Kubectl.

Kubeconfig Context

Context used by Kubectl to run against the cluster.

Kubeconfig Cluster

Name of the Kubernetes cluster against which Kubectl should run.

Kubeconfig User

Name of Kubeconfig user.

Additional Options for Kubectl

Additional Options for Kubectl separated by new lines, e.g. --log-dir or --log-flush-frequency. Additional options can also be provided at the procedure level. However no redundancy check would be performed, if an option is defined in both places.

Log Level

Log level to use for logging output. Possible values: DEBUG, INFO, WARN, ERROR

Plugin Procedures

Create Or Update Objects

Use this Procedure to Create or Update Kubernetes objects using Kubectl commands apply, create and replace based on a specification (either a YAML/JSON file or content provided in a text area).The update action chosen by the user will determine which Kubectl command is used.

Create Or Update Objects Parameters

ParameterDescription

Configuration Name

Required. Provide the name of the EC-Kubectl configuration to be used.

Update Action

Required. Should be one of the following commands: apply - To either create object if does not exist or update if it exists; create - To create object only if does not exist; replace - To replace object only if it exists.

Specification Source

Required. Choose filePath if specification comes from a file in the File Path textbox. Choose fileContent if specification comes from what is entered for the Content Parameter.

File Path

Required if Specification Source is filePath. Absolute Path to file with YAML or JSON specification. For example /var/myfile.yml

Content

Required if Specification Source is fileContent. Content for specification in either YAML or JSON specification. YAML can contain several sections, separated by ---.

Additional Options for Kubectl

Additional Options for Kubectl separated by new lines, e.g. --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration level. However no redundancy check would be performed, if an option is defined in both places.

Additional Options for Kubectl Command

Additional options for kubectl command separated by new lines, e.g. for apply command: --recursive or --validate.

Result Property Path

If provided, command output, error output and exit value will be stored in properties whose names are kubectlCommandOutput, kubectlCommandErrorOutput and kubectlCommandExitValue respectively.

Delete Objects

Use this procedure to Delete Kubernetes objects based on a specification (either a YAML/JSON file or content provided in a text area).

Delete Objects Parameters

ParameterDescription

Configuration Name

Required. Provide the name of the EC-Kubectl configuration to be used.

Specification Source

Required. Choose filePath if specification comes from a file in the File Path textbox. Choose fileContent if specification comes from what is entered for the Content Parameter.

File Path

Required if Specification Source is filePath. Absolute Path to file with YAML or JSON specification. For example /var/myfile.yml

Content

Required if Specification Source is fileContent. Content for specification in either YAML or JSON specification. YAML can contain several sections, separated by ---.

Additional Options for Kubectl

Additional Options for Kubectl separated by new lines, e.g. --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration level. However no redundancy check would be performed, if an option is defined in both places.

Additional Options for Kubectl Command

Additional options for kubectl delete command separated by new lines, e.g. --force.

Result Property Path

If provided, command output, error output and exit value will be stored in properties whose names are kubectlCommandOutput, kubectlCommandErrorOutput and kubectlCommandExitValue respectively.

Describe Objects

Use this procedure to Describe Kubernetes objects based on a specification (either a YAML/JSON file or content provided in a text area).

Describe Objects Parameters

ParameterDescription

Configuration Name

Required. Provide the name of the EC-Kubectl configuration to be used.

Specification Source

Required. Choose filePath if specification comes from a file in the File Path textbox. Choose fileContent if specification comes from what is entered for the Content Parameter.

File Path

Required if Specification Source is filePath. Absolute Path to file with YAML or JSON specification. For example /var/myfile.yml

Content

Required if Specification Source is fileContent. Content for specification in either YAML or JSON specification. YAML can contain several sections, separated by ---.

Output Format

stands for --output. Output format. One of: json|yaml|wide|name|custom-columns=…​|custom-columns-file=…​|go-template=…​|go-template-file=…​|jsonpath=…​|jsonpath-file=…​ See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].

Additional Options for Kubectl

Additional Options for Kubectl separated by new lines, e.g. --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration level. However no redundancy check would be performed, if an option is defined in both places.

Additional Options for Kubectl Command

Additional options for kubectl get command separated by new lines, e.g. --ignore-not-found.

Result Property Path

If provided, command output, error output and exit value will be stored in properties whose names are kubectlCommandOutput, kubectlCommandErrorOutput and kubectlCommandExitValue respectively.

Run Custom Command

Use this procedure to run any Kubectl command providing the required parameters.

Run Custom Command Parameters

ParameterDescription

Configuration Name

Required. Provide the name of the EC-Kubectl configuration to be used.

Custom Kubectl Command

Custom kubectl command to run.

Specification Source

Required. Choose noSpecification if no specification needs to be used. Choose filePath if specification comes from a file in the File Path textbox. Choose fileContent if specification comes from what is entered for the Content Parameter

File Path

Required if Specification Source is filePath. Absolute Path to file with YAML or JSON specification. For example /var/myfile.yml

Content

Required if Specification Source is fileContent. Content for specification in either YAML or JSON specification. YAML can contain several sections, separated by ---.

Additional Options for Kubectl

Additional Options for Kubectl separated by new lines, e.g. --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration level. However no redundancy check would be performed, if an option is defined in both places.

Additional Options for Kubectl Command

Additional options for kubectl command separated by new lines, e.g. for get command: all --output=yaml.

Result Property Path

If provided, command output, error output and exit value will be stored in properties whose names are kubectlCommandOutput, kubectlCommandErrorOutput and kubectlCommandExitValue respectively.

Release notes

EC-Kubectl 1.1.4

  • The documentation has been migrated to the main documentation site.

EC-Kubectl 1.1.3

  • Updated logger to slf4j.

EC-Kubectl 1.1.2

  • Renaming to "CloudBees CD".

EC-Kubectl 1.1.1

  • Fixed Gateways compatibility in the Dependency Management procedure.

EC-Kubectl 1.1.0

  • Provisioning of Binary Dependencies (for example Grape jars) in the agent resource, required by this plugin, is now delivered through a newly introduced mechanism called Plugin Dependency Management. Binary dependencies will now be seamlessly delivered to the agent resource from the Flow Server, any time a new version of a plugin is invoked the first time. Flow Repository set up is no longer required for this plugin.

EC-Kubectl 1.0.3

  • Fixed an issue with ec-groovy trying to fetch dependencies from maven instead of using the local cache.

EC-Kubectl 1.0.2

  • Renamed Electric Cloud to CloudBees.

EC-Kubectl 1.0.1

  • Configurations can be created by users with "@" sign in a name.

  • Fixed diplaying of available configurations list within flow UI when configuring procedures.

EC-Kubectl 1.0.0

  • First release.