oc-set-deployment-hook man page

oc set deployment-hook — Update a deployment hook on a deployment config


oc set deployment-hook [Options]


Set or remove a deployment hook on a deployment config

Deployment configs allow hooks to execute at different points in the lifecycle of the deployment, depending on the deployment strategy.

For deployments with a Recreate strategy, a Pre, Mid, and Post hook can be specified. The Pre hook will execute before the deployment starts. The Mid hook will execute once the previous deployment has been scaled down to 0, but before the new one ramps up. The Post hook will execute once the deployment has completed.

For deployments with a Rolling strategy, a Pre and Post hook can be specified. The Pre hook will execute before the deployment starts and the Post hook will execute once the deployment has completed.

For each hook, a new pod will be started using one of the containers in the deployment's pod template with a specific command to execute. Additional environment variables may be specified for the hook, as well as which volumes from the pod template will be mounted on the hook pod.

Each hook can have its own cancellation policy. One of: abort, retry, or ignore. Not all cancellation policies can be set on all hooks. For example, a Post hook on a rolling strategy does not support the abort policy, because at that point the deployment has already happened.


Select all deployment configs in the namespace
-c, --container=""
The name of the container in the selected deployment config to use for the deployment hook
-e, --environment=[]
Environment variables to use in the deployment hook pod
The failure policy for the deployment hook. Valid values are: abort,retry,ignore
-f, --filename=[]
Filename, directory, or URL to file to use to edit the resource.
Set or remove a mid deployment hook
When using the default output, don't print headers.
-o, --output=""
Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [ ⟨http://golang.org/pkg/text/template/#pk…⟩] and jsonpath template [ ⟨http://releases.k8s.io/release-1.3/docs…⟩].
Output the formatted object with the given group version (for ex: 'extensions/v1beta1').
Set or remove a post deployment hook
Set or remove a pre deployment hook
If true, remove the specified deployment hook(s).
-l, --selector=""
Selector (label query) to filter deployment configs
-a, --show-all=true
When printing, show all resources (false means hide terminated pods.)
When printing, show all labels as the last column (default hide labels column)
If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [ ⟨http://golang.org/pkg/text/template/#pk…⟩].
-v, --volumes=[]
Volumes from the pod template to use in the deployment hook pod

Options Inherited from Parent Commands

DEPRECATED: The API version to use when talking to the server

Username to impersonate for the operation.

Path to a cert. file for the certificate authority.

Path to a client certificate file for TLS.

Path to a client key file for TLS.

The name of the kubeconfig cluster to use

Path to the config file to use for CLI requests.

The name of the kubeconfig context to use

The Google Cloud Platform Service Account JSON Key to use for authentication.

If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.

Maximum number of seconds between log flushes

Require server version to match client version

-n, --namespace=""
If present, the namespace scope for this CLI request.

The address and port of the Kubernetes API server

Bearer token for authentication to the API server.

The name of the kubeconfig user to use


# Clear pre and post hooks on a deployment config
oc set deployment-hook dc/myapp --remove --pre --post

# Set the pre deployment hook to execute a db migration command for an application
# using the data volume from the application
oc set deployment-hook dc/myapp --pre -v data -- /var/lib/migrate-db.sh

# Set a mid deployment hook along with additional environment variables
oc set deployment-hook dc/myapp --mid -v data -e VAR1=value1 -e VAR2=value2 -- /var/lib/prepare-deploy.sh

See Also



June 2016, Ported from the Kubernetes man-doc generator

Referenced By


Explore man page connections for oc-set-deployment-hook(1).

Openshift Openshift CLI User Manuals June 2016