The Kubectl 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.3.1.2022052053
Revised on May 20, 2022
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)
-
Note: 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
to open the Plugin Manager. -
Find the EC-Kubectl-1.3.1.2022052053 row.
-
Click Configure to open the Configurations page.
-
Click Create Configuration as per the description of parameters below.
Configuration procedure parameters
Parameter | Description |
---|---|
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 |
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, for example --namespace=your-custom-namespace or --log-dir=/var/log/customdir. 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
Parameter | Description |
---|---|
Configuration Name |
Previously defined configuration for the plugin |
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
Parameter | Description |
---|---|
Configuration Name |
Previously defined configuration for the plugin |
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
Parameter | Description |
---|---|
Configuration Name |
Previously defined configuration for the plugin |
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
Parameter | Description |
---|---|
Configuration Name |
Previously defined configuration for the plugin |
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. |
Microservice deployment
Plugin allows deploying YAML Deployments into Kubernetes clusters. Clusters should be part of an Environment and have 'Kubernetes (via Kubectl)' in the cluster definition.
Microservice deployment uses 'apply' command to support both fresh and upgrade deployments. Deployment parameter 'Additional options' can be used to provide list of flags and options for the deployment command.
Parameters will be added to the command in following order, which means options that are prepended later can override values set in previous options.
-
Configuration 'Additional Options for Kubectl'
-
Cluster definition 'Namespace' parameter
-
Cluster definition 'Kubeconfig context' parameter
-
Deployment 'Additional options'
After invoking 'apply' command, the plugin procedure invokes set of commands to retrieve the deployment details:
-
For each Deployment object: 'get deployment <deploymentName> -o=json'
Each Deployment JSON are parsed in order to get list of containers that were deployed. These containers are reported to the Environment Inventory.
In case when plugin fails to find any Deployments in YAML files, no containers will be reported to the inventory.
Release notes
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.