Kubernetes REST plugin

The Kubernetes REST plugin provides steps to create, update, and delete Kubernetes resources, copy files from or to a pod, and run a command in a pod.

Overview

The Kubernetes REST plugin interacts with a Kubernetes cloud environment through the REST client.

The plugin uses a configuration file, sometimes called the kubeconfig file, in which you define your Kubernetes cluster settings.

The plugin offers similar functionality to that of the Kubernetes CLI plugin, but with a restricted scope. For details, see the Kubernetes CLI plugin.

The following table describes the Kubernetes REST plugin's steps.

Step Description
Copy Files Copies a file or directory to or from a pod. See Step: Copy Files.
Create Resources Creates one or more resources of the deployment, stateful set, service, namespace, daemon set, node, or persistent volume types based on a YAML or JSON file. See Step: Create Resources.
Delete Resources Removes a resource of the deployment, stateful set, service, namespace, daemon set, node, or persistent volume types. See Step: Delete Resources.
Run Command Runs a command in a single-container pod. See Step: Run Command.
Patch Resources Updates a resource of the deployment, stateful set, service, namespace, daemon set, node, or persistent volume types. See Step: Patch Resources.

Back to top

Before you begin

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

Before you can use the plugin:

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

  2. Create the kubeconfig file that specifies your Kubernetes cluster settings.

  3. Download the Deployment Automation plugin bundle, extract the Kubernetes REST 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 REST 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: Copy Files

The Copy Files step copies a file or directory to or from a pod. By default, a file or directory is copied from a pod. To copy to a pod, select the Copy to Pod option.

The following table describes step-specific properties.

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

Enter the path to the kubeconfig file. The following property is used by default:

${p:resource/KubernetesConfig}

For details on how to create resource properties, see Add or edit resource properties.

Namespace

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

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

Pod Name

Copy from pod: Enter the name of the Kubernetes pod from which to copy files.

Copy to pod: Enter the name of the Kubernetes pod to which to copy files.

Container

If the pod runs multiple containers:

Copy from pod: Enter the name of the container from which to copy files.

Copy to pod: Enter the name of the container to which to copy files.

If you don't specify a container for a multicontainer pod, the step fails.

Copy to Pod

(Optional) Select this option to copy a file or directory to a pod. You can copy only one file or directory.

Keep this option cleared to copy a file or directory from a pod.

Source Path

Copy from pod: Enter the path to the file or directory to be copied.

Copy to pod: Enter the path to the file or directory to which you want to copy.

For a Kubernetes location, provide an absolute path.

Destination Path

Copy from pod: Enter the path to the file or directory to which you want to copy.

Copy to pod: Enter the path to the file or directory to be copied.

For a Kubernetes location, provide an absolute path.

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.
Kube Config File

Enter the path to the kubeconfig file. The following property is used by default:

${p:resource/KubernetesConfig}

For details on how to create resource properties, see Add or edit resource properties.

Namespace

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

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

File Name

Enter the URL or path to the file you want to use for creating resources, for example:

https://k8s.io/examples/controllers/nginx-deployment.yaml

You can create the following resource types:

  • Deployment

  • Stateful Set

  • Service

  • Namespace

  • Daemon Set

  • Node

  • Persistent Volume

The supported file formats are YAML and JSON.

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

Back to top

Step: Delete Resources

The Delete Resources step deletes a Kubernetes resource based on the resource type.

The following table describes step-specific properties.

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

Enter the path to the kubeconfig file. The following property is used by default:

${p:resource/KubernetesConfig}

For details on how to create resource properties, see Add or edit resource properties.

Namespace

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

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

Resource Type

Select the type of a resource to delete:

  • Deployment

  • Stateful Set

  • Service

  • Namespace

  • Daemon Set

  • Node

  • Persistent Volume

Resource Enter the name of the resource to delete. You can delete only one resource.

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 single-container 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.
Kube Config File

Enter the path to the kubeconfig file. The following property is used by default:

${p:resource/KubernetesConfig}

For details on how to create resource properties, see Add or edit resource properties.

Namespace

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

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

Pod

Enter the name of the pod in which to run the command. Use a pod that runs a single container. If there are multiple containers in a pod, the step fails.

Command Enter a command to run in the pod.

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

Back to top

Step: Patch Resources

The Patch Resources step updates the fields of a resource in a Kubernetes cluster using a strategic merge or a JSON patch.

The following table describes step-specific properties.

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

Enter the path to the kubeconfig file. The following property is used by default:

${p:resource/KubernetesConfig}

For details on how to create resource properties, see Add or edit resource properties.

Namespace

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

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

Patch Format

Select the format for updating resources:

  • JSON patch

  • Strategic merge

Resource Type

Select the type of a resource to update:

  • Deployment

  • Stateful Set

  • Service

  • Namespace

  • Daemon Set

  • Node

  • Persistent Volume

Resource Enter the name of the resource to update. You can patch only one resource.
File Name

Enter the path to the file you want to use for patching resources.

Strategic merge supports YAML and JSON file formats, and JSON patch supports JSON format.

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

Back to top

Common properties

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

Property Description
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. Secure properties are stored encrypted, and their values are displayed obscured in the Deployment Automation user interface.

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

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

Debug Logs Select this option to log debug information during the run.

Back to top

See also: