Kubernetes CLI plugin

The Kubernetes CLI plugin enables you to manage resources in a Kubernetes cloud environment through the Kubernetes command-line tool, kubectl.

For a Deployment Automation integration with Kubernetes that doesn't require kubectl, see the Kubernetes REST plugin.

Overview

The Kubernetes CLI plugin provides a set of steps for managing Kubernetes resources. The plugin integrates with a Kubernetes cloud environment through the kubectl command-line tool.

The following table describes the plugin's steps.

Step Description
Apply Configuration Applies a configuration to one or more Kubernetes resources from a JSON or YAML file. See Step: Apply Configuration.
Create Resources Creates one or more Kubernetes resources from a JSON or YAML file. See Step: Create Resources.
Delete Resources Deletes Kubernetes resources by file name, resource type and name, or resource type and label. See Step: Delete Resources.
Expose Resources Exposes a resource, such as deployment, replication controller, service, or pod, as a new Kubernetes service. See Step: Expose Resources.
Roll Out Deployment Manages the rollout of a deployment using rollout subcommands. See Step: Roll Out Deployment.
Run Command Runs a command in a pod's container. See Step: Run Command.
Run Image on Pod Creates and runs a specified image in a pod. See Step: Run Image on Pod.
Scale Resource Changes the size of a resource, such as deployment, replica set, stateful set, or replication controller. See Step: Scale Resource.
Set Container Image Updates one or more container images of resources. See Step: Set Container Image.
Update Label Updates labels of one or more resources. See Step: Update Label.

Back to top

Before you begin

To use the Kubernetes CLI plugin, complete the prerequisite tasks described in this section.

Before you can use the plugin:

  1. Verify that your have sufficient permissions for your Deployment Automation agent, and your user role allows you to manage plugins. For details, see Server roles and system security.

  2. Install and set up the Kubernetes command-line tool kubectl on the Deployment Automation agent.

  3. Download the Deployment Automation plugin bundle, extract the Kubernetes CLI plugin zip file from the bundle, and load the file into Deployment Automation. For details, see Load and upgrade plugins.

To use the plugin steps, open your component or global process and navigate to Cloud > Kubernetes in the Tools pane.

For details about creating processes, see Create and design component processes and Create and design global processes.

Back to top

Step: Apply Configuration

The Apply Configuration step applies a configuration to one or more Kubernetes resources from a file.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
File Name

Enter the URL or path to the file or directory you want to use for configuring resources.

The supported file formats are JSON and YAML.

Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Create Resources

The Create Resources step creates one or more Kubernetes resources from a YAML or JSON file.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
File Name

Enter the URL or path to the file or directory you want to use for creating resources.

The supported file formats are JSON and YAML.

Save Config (Optional) Select this option to save the resource's current configuration if you need to update it in the future.
Record Command (Optional) Select this option to record current kubectl command in the resource annotation.
Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Delete Resources

The Delete Resources step deletes Kubernetes resources based on filters such as file name, resource type and name, or resource type and label.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Deletion Type

Select a filter for deleting resources:

Resource Types and Names. Delete resources based on their type and name.

Resource Types and Labels. Delete resources based on their type and label.

File. Delete resources specified in a file.

All Resources of Type. Delete all resources of a specified type.

Resources

Specify resources to delete. Use the format depending on the selected Deletion Type:

  • Resource Types and Names. Enter a comma-separated list of resource types followed by a space-separated list of resource names, for example:

    pod,service podName serviceName

  • Resource Types and Labels. Enter a comma-separated list of resource types followed by name=value pairs for each label and its value, for example:

    pods,services color=blue

  • File. Enter the URL or path to the file or directory identifying resources to delete. The supported file formats are JSON and YAML.

  • All Resources of Type. Enter a comma-separated list of resource types, for example:

    pods,services

Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Expose Resources

The Expose Resources step exposes a resource as a new Kubernetes service.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Resource Type

Select the type of resources to expose:

Deployment. Expose deployments.

Replication Controller. Expose replication controllers.

Service. Expose services.

Pod. Expose pods.

File. Expose resources specified in a file.

Resource

Specify the resources to expose. Enter resource names separated by a comma.

For the File resource type, enter the URL or path to the file or directory identifying resources.

The supported file formats are JSON and YAML.

Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Roll Out Deployment

The Roll Out Deployment step manages the rollout of a Kubernetes resource using rollout subcommands.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Command

Select the rollout command:

  • Pause Resource. Mark the resource as paused.
  • Resume Resource. Resume a paused resource.
  • Watch Status Until It's Done. Watch the status of the rollout until the rollout is finished.
  • Undo Last Rollout. Roll back to a previous rollout.
  • View Rollout History. Display the history of rollout revisions.
Resource Type

Select the type of resources to roll out:

• Deployment

• Daemon Set

• Stateful Set

Resource Specify the resources to roll out. Enter resource names separated by a comma.
Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Run Command

The Run Command step runs a command in a container.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Pod Name Enter the name of the pod where the container is located, for example, 123456-7890.
Container Name

(Optional) Enter the name of the container in which to run the command.

Leave the field empty to use the pod's first container.

Command

Enter a command to run in the container.

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Run Image on Pod

The Run Image on Pod step creates and runs a specified image in a pod.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Pod Name Create a name for the running pod.
Image Name Enter the name of an image, for example, an image from the Docker registry.
Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

Environment Variables

Enter environment variables to pass to the image. To specify multiple variables, separate entries with a comma, for example:

envar01,envar02

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Scale Resource

The Scale Resource step changes the size of one or more Kubernetes resources.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Resource Type

Select the type of resources to scale:

  • Deployment. Scale deployments.
  • Replica Set. Scale replica sets.
  • Stateful Set. Scale stateful sets.
  • Replication Controller. Scale replication controllers.
  • File. Scale resources specified in a file.
Resource

Specify the resources to scale. Enter resource names separated by a comma.

For the File resource type, enter the URL or path to the file or directory identifying resources for scaling.

The supported file formats are JSON and YAML.

Flags

Specify the flags you want to set when running the scale process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Set Container Image

The Set Container Image step changes one or more container images of resources.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Resource Type

Select the type of resources for which to update container images:

  • Deployment. Use deployments.
  • Replication Controller. Use replication controllers.
  • Daemon Set. Use daemon sets.
  • Pod. Use pods.
  • Job. Use jobs.
  • Replica Set. Use replica sets.
  • File. Use resources specified in a file.
Resource

Specify the resources for which to change container images. Enter resource names separated by a comma.

For the File resource type, enter the URL or path to the file or directory identifying resources.

The supported file formats are JSON and YAML.

Image Versions

Specify the image you want to change and the image to replace it with. Use this syntax:

<current-image:version>=<new-image:version>

If you enter an image without a version, the latest image version is used. To specify multiple images, separate entries with a space.

Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Step: Update Label

The Update Label step updates label values on one or more Kubernetes resources.

The following table describes step-specific properties.

Property Description
Name Enter a name for the step. By default, the system uses the command name.
Resource Type

Select a filter for updating labels on a resource:

  • Pod. Change the labels of pods.
  • File. Change the labels of resources specified in a file.
Resource

(Optional) Specify the resources for which to update labels. Enter resource names separated by a comma.

For the File resource type, enter the URL or path to the file or directory identifying resources for which to update labels.

The supported file formats are JSON and YAML.

Labels

Enter resource labels and their new values.

Ensure that labels and values begin with a letter or number, contain only letters, numbers, hyphens, periods, and underscores, and don't exceed 63 characters each.

Separate each name=value pair with a space, for example:

label01=labelValue01 label02=labelValue02

Overwrite

(Optional) Select this option to overwrite the values of current labels.

If this option is not selected, the label changes are rejected, and the step fails.

Flags

(Optional) Specify the flags to set when running the process.

Enter each flag on a new line, for example:

--recursive=true

For properties that are common to all plugin's steps, see Common properties.

Back to top

Common properties

The following optional properties are common to all Kubernetes CLI plugin steps.

Property Description
URL Enter the path to your Kubernetes server, for example, https://10.2.2.2:8443.
Username Enter your login for accessing the Kubernetes server.
Password Enter your password for accessing the Kubernetes server.
Namespace

Enter the namespace on the Kubernetes server in which to run command.

Leave the field empty to use the default namespace of your Kubernetes environment.

Ignore Failure Select this option if you want the step to always be considered successful.
Working Directory Enter an alternative absolute path to the working directory for the step. To use the default working directory for the process, leave the field empty.
Post Processing Script

Select a custom post-processing script. To run the step's default script, leave the field empty.

To create your custom post-processing script, click Add , and enter script details in the Create Script dialog box.

A post-processing script helps ensure that expected results occur. It runs after a step finishes processing. For details, see Manage post-processing scripts.

Precondition Enter a JavaScript script to define a condition that must exist before the step can run. The condition resolves to true or false.
Use Impersonation Select this option if you want an agent to run the step as a different user. Specify the impersonation details for a Windows or UNIX/Linux agent, as described in Use impersonation to run processes.
Hint Add a comment to the step. To view the comment, point to the step in the design space.
Hidden properties
Output properties secure rules

Specify properties you want to be treated as secure.

Enter each property name on a new line. Use regular expressions to select multiple properties.

Example: To select all properties with names that start with prop, enter this regular expression: prop.*

Secure properties are stored encrypted, and their values are displayed obscured in the Deployment Automation user interface.

kubectl Path Enter the name of the kubectl command if it's in the system path, or provide a full path to run the kubectl command.
Global Flags

Specify the global flags to set when running the kubectl command.

Enter each global flag on a new line, for example:

--insecure-skip-tls-verify

--match-server-version

--log-dir=’/var/logs/’

Debug Logs Select this option to include debug information in logs.

Back to top

See also: