Skip to main content

Add Kubernetes Command Flags

Overview

In Kubernetes, commands are made up of two main components:

Command types: These represent the core actions you can perform on your cluster resources, such as get, apply, delete, patch, and logs. Each type maps to a specific operational intent—retrieving, modifying, or managing resources.

Command flags: These are optional parameters that allow you to customize the behavior of each command. For example, flags like --namespace, -o, --force, or --watch let you specify the target namespace, output format, execution mode, and more.

Together, command types and flags give you powerful control over how you interact with your Kubernetes workloads using kubectl.

Where you can add command flags in different k8s steps

Navigate to the executions tab of the deploy stage and select the k8s step you want to add. In the advanced tab of the step details, you can add the required command in the command flag dropdown.

Each k8s step supports a particular command type based on the type of execution the step performs.

k8s command types and its command flags

kubectl apply

Description:
The kubectl apply command is used to create or update resources in a Kubernetes cluster from a configuration file (usually in YAML or JSON format). It is commonly used for deploying applications or updating configurations for existing resources.

FlagDescription
-fFile or directory with manifests
--recordRecord the command in resource annotation
--dry-run=client/serverPreview changes without applying
--pruneDelete objects not in the configuration file
--force-conflictsForce apply changes during conflicts

You can use this command in:

For more information on kubectl apply command, refer Kubernetes Documentation

kubectl delete

Description:
The kubectl delete command is used to remove resources (e.g., pods, services, deployments) from the Kubernetes cluster. It helps to clean up or remove unnecessary resources.

FlagDescription
-fManifest file
--grace-periodTime to wait before forcefully terminating
--forceForce deletion
--waitWait for resource deletion to complete

You can use this command in the following step:

For more information on kubectl delete command, refer Kubernetes Documentation

kubectl rollout

Description:
The kubectl rollout command is used to manage the rollout process of deployments. It’s used to view or manage the status of an application’s deployment or perform rollbacks to previous versions.

FlagDescription
--revisionSpecify revision to rollback
--watchWatch status updates

This command can be added in the following step:

For more information on kubectl rollout command, refer Kubernetes Documentation

kubectl patch

Description:
The kubectl patch command allows you to modify an existing Kubernetes resource. It applies changes to a specific part of a resource’s configuration (using either JSON or a strategic merge patch).

FlagDescription
--patchThe actual patch to apply (as a JSON string)
--patch-typeOne of: strategic, merge, json
-n, --namespaceNamespace of the target resource
--typeAlias for --patch-type
--dry-run=client/serverPreview changes without applying
-oOutput format (json, yaml, etc.)

You can use this command in the following step:

For more information on kubectl patch command, refer Kubernetes Documentation