Create Kubectl plugin procedures

4 minute readExtensibilityDeveloper productivity

Plugin procedures can be used in procedure steps, process steps, and pipeline tasks, allowing you to orchestrate third-party tools at the appropriate time in your component, application process, or pipeline.

Depending on your plugin configuration and how you run procedures, the Input parameters  Configuration name field may behave differently in the CloudBees CD/RO UI. For more information, refer to Differences in plugin UI behavior.

Create Or Update Objects

Create or update Kubernetes objects using kubectl commands to apply, create, and replace based on a specification (either a YAML/JSON file or content provided in a text area). The selected update action determines which kubectl command is used.

Input parameters

Table 1. Create Or Update Objects input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Update action

Required. Select the appropriate update action.

  • apply: Creates the object if does not exist or updates the object if it already exists.

  • create: Creates the object if it does not exist.

  • replace: Replaces the object if it exists.

Specification source

Required. Select the specification source.

  • filePath: The file specified in the File path field.

  • fileContent: The text entered in the Content field.

File path

Required if the Specification source is filePath. The absolute path to a file with a YAML or JSON specification. For example, /var/myfile.yml.

Content

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

Additional options for kubectl

Additional options for kubectl, separated by newlines. For example, --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration-level. However, no redundancy check is performed if an option is defined in both places.

Additional options for kubectl command

Additional options for kubectl command separated by newlines. For example, for the apply command, use --recursive or --validate.

Result property path

If specified, the command output, error output, and exit value are stored in properties whose names are kubectlCommandOutput, kubectlCommandErrorOutput, and kubectlCommandExitValue, respectively.

Delete Objects

Deletes Kubernetes objects based on a specification (either a YAML/JSON file or content provided in a text area).

Input parameters

Table 2. Delete Objects input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Specification source

Required. Select the specification source.

  • filePath: The file specified in the File path field.

  • fileContent: The text entered in the Content field.

File path

Required if the Specification source is filePath. The absolute path to a file with a YAML or JSON specification. For example, /var/myfile.yml.

Content

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

Additional options for kubectl

Additional options for kubectl, separated by newlines. For example, --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration-level. However, no redundancy check is performed if an option is defined in both places.

Additional options for kubectl command

Additional options for the kubectl delete command, separated by newlines. For example, --force.

Result property path

If specified, the command output, error output, and exit value are 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).

Input parameters

Table 3. Describe Objects input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Specification source

Required. Select the specification source.

  • filePath: The file specified in the File path field.

  • fileContent: The text entered in the Content field.

File path

Required if the Specification source is filePath. The absolute path to a file with a YAML or JSON specification. For example, /var/myfile.yml.

Content

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

Output format

The output format, which stands for --output. It must be:

  • yaml

  • wide

  • name

  • custom-columns=…​

  • custom-columns-file=…​

  • go-template=…​

  • go-template-file=…​

  • jsonpath=…​

  • jsonpath-file=…​

For more information, refer to custom columns, golang template and jsonpath template.

Additional options for kubectl

Additional options for kubectl, separated by newlines. For example, --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration-level. However, no redundancy check is performed if an option is defined in both places.

Additional options for kubectl command

Additional options for the kubectl get command, separated by newlines. For example, --ignore-not-found.

Result property path

If specified, the command output, error output, and exit value are 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.

Input parameters

Table 4. Run Custom Command input parameters
Parameter Description

Configuration name

Required. The previously defined configuration for the plugin.

Custom kubectl command

Required. The custom kubectl command to run.

Specification source

Required. Select the specification source.

  • noSpecification: No specification needs is used.

  • filePath: The file specified in the File path field.

  • fileContent: The text entered in the Content field.

File path

Required if the Specification source is filePath. The absolute path to a file with a YAML or JSON specification. For example, /var/myfile.yml.

Content

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

Additional options for kubectl

Additional options for kubectl, separated by newlines. For example, --log-dir or --log-flush-frequency. Additional options can also be provided at the configuration-level. However, no redundancy check is performed if an option is defined in both places.

Additional options for kubectl command

Additional options for the kubectl commands, separated by newlines. For example, for the get command, all --output=yaml.

Result property path

If specified, the command output, error output, and exit value are stored in properties whose names are kubectlCommandOutput, kubectlCommandErrorOutput, and kubectlCommandExitValue, respectively.