Run a kubectl script

Octopus.KubernetesRunScript exported 2026-07-22 by Octopus Deploy belongs to ‘Kubernetes’ category.

Run a script within an environment configured using the Kubernetes target.

Parameters

When this step is included in a project’s deployment process, the parameters below can be set.

Script source

Octopus.Action.Script.ScriptSource (required)

The source of the script to run. Can be inline, from a package, or from a Git repository.

Allowed values: Inline, Package, GitRepository

Default: Inline

Script syntax

Octopus.Action.Script.Syntax

The syntax of the script being run. Required when the script source is Inline.

Allowed values: PowerShell, Bash

Script body

Octopus.Action.Script.ScriptBody

The inline script body to execute.

Script file name

Octopus.Action.Script.ScriptFileName

The path to the script file to execute when the source is a package or Git repository.

Script parameters

Octopus.Action.Script.ScriptParameters

Parameters to pass to the script file.

Namespace

Octopus.Action.KubernetesContainers.Namespace

The Kubernetes namespace for the script execution.

Optional features

Enable features by adding their IDs to Octopus.Action.EnabledFeatures (a comma-separated list).

Substitute Variables in Templates Octopus.Features.SubstituteInFiles

Transforms files using the Octopus #{Variable} substitution syntax. Enabled by default for package deployments.

Octopus.Action.SubstituteInFiles.TargetFiles

Octopus.Action.SubstituteInFiles.TargetFiles

Newline-separated list of file names to transform (relative to package). Wildcards supported.

Octopus.Action.SubstituteInFiles.OutputEncoding

Octopus.Action.SubstituteInFiles.OutputEncoding

Encoding name for the output file (e.g. utf-8). Optional.

Structured Configuration Variables Octopus.Features.JsonConfigurationVariables

Replace settings in JSON, YAML, XML, and Java Properties files with Octopus variables. Enabled by default for package deployments.

Octopus.Action.Package.JsonConfigurationVariablesTargets

Octopus.Action.Package.JsonConfigurationVariablesTargets

Newline-separated list of target files (e.g. appsettings.json). Wildcards supported.

.NET Configuration Transforms Octopus.Features.ConfigurationTransforms

Runs configuration file transforms. Enabled by default for package deployments.

Octopus.Action.Package.AutomaticallyRunConfigurationTransformationFiles

Octopus.Action.Package.AutomaticallyRunConfigurationTransformationFiles

Run default XML transforms (True/False).

Octopus.Action.Package.AdditionalXmlConfigurationTransforms

Octopus.Action.Package.AdditionalXmlConfigurationTransforms

Comma- or newline-separated list of additional transform rules (e.g. Web.Release.config => Web.config).

.NET Configuration Variables Octopus.Features.ConfigurationVariables

Replace appSettings and connectionStrings in .config files. Enabled by default for package deployments.

Octopus.Action.Package.AutomaticallyUpdateAppSettingsAndConnectionStrings

Octopus.Action.Package.AutomaticallyUpdateAppSettingsAndConnectionStrings

Replace appSettings and connectionStrings in .config files (True/False).

PowerShell Edition Octopus.Features.SelectPowerShellEditionForWindows

Specify the edition of PowerShell used during deployments on Windows.

Octopus.Action.PowerShell.Edition

Octopus.Action.PowerShell.Edition

PowerShell edition on Windows (Desktop or Core).

Allowed values: Desktop, Core

Step configuration using OCL

Example in Octopus Configuration Language (OCL):

step "kubernetes-script" {
    name = "Kubernetes Script"
    properties = {
        Octopus.Action.TargetRoles = "k8s-cluster"
    }

    action {
        action_type = "Octopus.KubernetesRunScript"
        properties = {
            Octopus.Action.KubernetesContainers.Namespace = "default"
            Octopus.Action.RunOnServer = "false"
            Octopus.Action.Script.ScriptBody = "kubectl get pods"
            Octopus.Action.Script.ScriptSource = "Inline"
            Octopus.Action.Script.Syntax = "PowerShell"
        }
    }
}

Page updated on Wednesday, July 22, 2026