1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/deployments-recreate-strategy.adoc
Max Bridges b5fc467d1f add content types to untagged modules
OSDOCS-16694
2025-10-31 21:02:28 -04:00

52 lines
1.7 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/deployments/deployment-strategies.adoc
:_mod-docs-content-type: CONCEPT
[id="deployments-recreate-strategy_{context}"]
= Recreate strategy
The recreate strategy has basic rollout behavior and supports lifecycle hooks for injecting code into the deployment process.
.Example recreate strategy definition
[source,yaml]
----
kind: Deployment
apiVersion: apps/v1
metadata:
name: hello-openshift
# ...
spec:
# ...
strategy:
type: Recreate
recreateParams: <1>
pre: {} <2>
mid: {}
post: {}
----
<1> `recreateParams` are optional.
<2> `pre`, `mid`, and `post` are lifecycle hooks.
The recreate strategy:
. Executes any `pre` lifecycle hook.
. Scales down the previous deployment to zero.
. Executes any `mid` lifecycle hook.
. Scales up the new deployment.
. Executes any `post` lifecycle hook.
[IMPORTANT]
====
During scale up, if the replica count of the deployment is greater than one, the first replica of the deployment will be validated for readiness before fully scaling up the deployment. If the validation of the first replica fails, the deployment will be considered a failure.
====
*When to use a recreate deployment:*
- When you must run migrations or other data transformations before your new code starts.
- When you do not support having new and old versions of your application code running at the same time.
- When you want to use a RWO volume, which is not supported being shared between multiple replicas.
A recreate deployment incurs downtime because, for a brief period, no instances of your application are running. However, your old code and new code do not run at the same time.