Table of Contents
Understanding DeploymentConfigs vs Deployments in OpenShift
OpenShift supports two main controllers for managing application rollout and lifecycle:
- OpenShift-specific
DeploymentConfig - Upstream Kubernetes
Deployment
They solve the same problem—managing how pods are created, updated, and rolled back—but with different capabilities and integration points. In OpenShift you will often encounter both, especially in existing clusters and templates.
This chapter focuses on:
- Conceptual differences
- When to use which
- Core fields and behavior
- Hooks, triggers, and strategies specific to
DeploymentConfig - Practical examples and migration guidelines
Conceptual Overview
Shared purpose
Both DeploymentConfig and Deployment:
- Maintain a desired number of pod replicas
- Manage updates to your application version (new images, new configuration)
- Support rolling updates and rollbacks
- Work with
ReplicaSet/ReplicationController-like mechanisms under the hood
They are controllers that own lower-level replication resources and ensure the desired state is maintained.
Key differences at a glance
- Native to where
Deploymentis a standard Kubernetes resource (apps/v1) and is portable.DeploymentConfigis an OpenShift extension (apps.openshift.io/v1).- Triggers
Deploymenttypically reacts to spec changes or CI/CD tools.DeploymentConfighas built-in triggers (image change, config change, manual) and integrates tightly with OpenShift image streams and S2I.- Update strategies
- Both support rolling-style updates, but
DeploymentConfiguses: Rolling,Recreate,Customstrategies- Pre/post lifecycle hooks
Deploymentuses standardized Kubernetes strategies:RollingUpdateRecreate- Ecosystem compatibility
Deploymentintegrates seamlessly with upstream Kubernetes features, Operators, Helm charts, and GitOps tools.DeploymentConfigis often used by older OpenShift templates and S2I workflows but is not portable to vanilla Kubernetes.
In modern OpenShift clusters, Deployment is the preferred default for new applications unless you specifically need DeploymentConfig features such as image change triggers or custom hooks.
DeploymentConfigs in OpenShift
Resource overview
API group and kind:
apiVersion: apps.openshift.io/v1kind: DeploymentConfig
A DeploymentConfig definition usually includes:
spec.replicas– desired replica countspec.selector– label selectors for managed podsspec.template– pod templatespec.strategy– how updates are performedspec.triggers– what causes new rolloutsstatus– current rollout state (observed generation, latestVersion, etc.)
The creation of new pods is typically indirect: DeploymentConfig creates a ReplicationController to manage actual pods.
Triggers
Triggers are one of the main distinctive features of DeploymentConfig. They determine when a new deployment is created.
Common trigger types:
- ConfigChange
- Activated when the
DeploymentConfigspec (e.g., environment vars, pod template) changes. - When
configChangeis present, any change to the pod template will start a new deployment automatically. - ImageChange
- Activated when an
ImageStreamTagreferenced in the pod template is updated (new image version). - Ties deployments directly to OpenShift ImageStreams, enabling automatic rollouts when new images are built/pushed.
- Manual
- No automatic trigger; rollouts are started explicitly by the user or CI/CD tool.
Example trigger section:
spec:
triggers:
- type: "ConfigChange"
- type: "ImageChange"
imageChangeParams:
automatic: true
containerNames:
- myapp
from:
kind: ImageStreamTag
name: myapp:latestKey details:
automatic: truemeans the rollout happens as soon as the image tag changes.- You can restrict auto-rollouts to specific containers in the pod.
- You can combine
ConfigChangeandImageChangetriggers, or disable them and trigger deployments manually (e.g. viaoc rollout).
Strategies
DeploymentConfig supports three strategies under spec.strategy.type:
- Rolling (default for most apps)
- Recreate
- Custom
Rolling strategy
Performs a rolling update: gradually replace old pods with new ones while keeping the application available.
Key parameters:
spec:
strategy:
type: Rolling
rollingParams:
maxUnavailable: 25%
maxSurge: 25%
intervalSeconds: 1
timeoutSeconds: 600
updatePeriodSeconds: 1maxUnavailable– maximum number (or percentage) of pods that can be unavailable during the update.maxSurge– how many extra pods can be created temporarily.intervalSeconds,updatePeriodSeconds,timeoutSeconds– control pacing and timeouts.
Recreate strategy
Stops all old pods before starting new ones. Useful for:
- Stateful workloads that cannot have multiple versions running simultaneously
- Apps with strict shared resource constraints (e.g. exclusive file locks)
Example:
spec:
strategy:
type: RecreateCustom strategy
Allows running a custom deployment process in a container you provide. The custom container is responsible for creating/updating pods.
High level structure:
spec:
strategy:
type: Custom
customParams:
image: myorg/custom-deployer:latest
command:
- /usr/local/bin/deploy
environment:
- name: DEPLOY_ENV
value: productionUse cases:
- Very specialized deployment logic not covered by rolling/recreate (e.g., orchestrating complex DB schema migrations in legacy systems)
- Environments where existing scripts/tools must be reused inside clusters
This is powerful but also more complex; most applications should use Rolling or Recreate instead.
Lifecycle Hooks
Hooks are another distinctive capability of DeploymentConfig. They run user-defined actions at specific points in the deployment lifecycle.
Hook types (defined under spec.strategy.rollingParams or recreateParams):
pre– run before a new deployment is scaled up (or before old pods are scaled down, depending on strategy)mid– during the transition (less commonly used)post– after the new deployment is successful
Each hook can perform different actions:
ExecNewPod– start a one-off pod running a command- (Deprecated older forms exist;
ExecNewPodis the core pattern)
Example pre-hook with Rolling strategy:
spec:
strategy:
type: Rolling
rollingParams:
pre:
failurePolicy: Abort
execNewPod:
command:
- /opt/app/pre-migrate.sh
containerName: myapp
env:
- name: MIGRATION_STEP
value: "pre"Key options:
failurePolicy:Abort,Retry, orIgnoreAbortstops the deployment on hook failure.Retryre-runs the hook.Ignorecontinues deployment even if the hook fails.
Typical hook use cases:
- Database migrations before rolling out new code
- Cache warm-up
- Health checks or smoke tests beyond the standard readiness probes
Managing DeploymentConfigs in practice
Common operations (using the oc CLI):
- Inspect:
oc get dcoc describe dc <name>- Trigger rollout manually:
oc rollout latest dc/<name>oc rollout restart dc/<name>(forces a new deployment with same spec)- Pause/Resume (to avoid auto-rollouts):
oc rollout pause dc/<name>oc rollout resume dc/<name>- Roll back:
oc rollout history dc/<name>oc rollout undo dc/<name> --to-revision=<n>
A typical workflow in older OpenShift setups:
- Build image via S2I or pipeline into an ImageStream.
ImageChangetrigger detects newImageStreamTag.DeploymentConfigautomatically starts a new rollout.- Hooks (if any) run before/after the rollout.
oc rolloutused for monitoring, pausing, or rollback.
Kubernetes Deployments in OpenShift
While DeploymentConfig is OpenShift-specific, Deployment is the standard Kubernetes resource and is used heavily in contemporary OpenShift environments.
Resource overview
apiVersion: apps/v1kind: Deployment
Key fields:
spec.replicasspec.selectorspec.templatespec.strategyspec.revisionHistoryLimitspec.progressDeadlineSeconds
Under the hood, a Deployment manages ReplicaSets, which then own the pods.
Strategies
Deployment supports:
- RollingUpdate (default)
- Recreate
Example RollingUpdate:
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
Behavior is broadly similar to DeploymentConfig’s Rolling strategy, but the configuration and semantics are Kubernetes-standard.
Triggers and updates
Deployment does not have explicit trigger objects like DeploymentConfig. A new rollout happens whenever:
- The pod template (
spec.template) changes (image, env vars, labels, etc.). - You update
spec.replicasor other relevant fields.
Typical patterns:
- CI/CD tools (e.g. Tekton, Argo CD, Jenkins) patch the Deployment with a new image tag.
- GitOps tools apply a new YAML with updated spec.
- Manual changes via
oc set imageoroc edit deployment.
Examples:
- Update image:
oc set image deployment/myapp myapp=myregistry/myapp:v2- Force a new rollout without changing the spec:
oc rollout restart deployment/myappAdvanced options
Some features commonly used with Deployments:
- Probes and health checks (readiness/liveness) integrated into the pod spec
- Pod update ordering via
maxSurge,maxUnavailable - Progress deadline (
spec.progressDeadlineSeconds) to detect stuck deployments and mark them as failed
Since these are standard Kubernetes features, third-party tools (Helm, Operators, GitOps controllers) expect and target Deployment objects by default.
When to Use DeploymentConfig vs Deployment
Choose Deployment (recommended for most new apps)
Prefer Deployment when:
- You want Kubernetes portability (the same manifests should work on non-OpenShift clusters).
- You plan to use Helm charts, many Operators, or GitOps tools that generate Deployments.
- Your pipeline or GitOps system manages image tags and rollouts explicitly.
- You’re building new applications on recent OpenShift versions.
Typical modern pattern:
- Pipeline builds/pushes image to a registry.
- Pipeline (or GitOps) updates the
Deploymentspec (imagefield) in Git or via API. - Kubernetes
Deploymentmanages the rollout.
Choose DeploymentConfig (special cases)
Prefer DeploymentConfig when:
- You rely heavily on OpenShift ImageStreams and want automatic image change triggers.
- You need pre/mid/post hooks tightly bound to the deployment lifecycle.
- You are maintaining legacy applications or existing OpenShift templates that already use DeploymentConfigs.
- You want Custom strategy deployment flows.
In many organizations, DeploymentConfig remains common where older OpenShift patterns (S2I with image change triggers) are entrenched.
YAML Comparison
Sample DeploymentConfig
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: myapp
spec:
replicas: 3
selector:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: image-registry.openshift-image-registry.svc:5000/myproj/myapp:latest
ports:
- containerPort: 8080
strategy:
type: Rolling
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
from:
kind: ImageStreamTag
name: myapp:latest
containerNames:
- myappEquivalent Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myregistry.example.com/myproj/myapp:latest
ports:
- containerPort: 8080
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%Notice:
- No
triggerssection inDeployment. - Uses
selector.matchLabelsinstead of plainselectormap. - Uses standard image reference (registry URL), not ImageStreams.
Migration Considerations
When moving from DeploymentConfig to Deployment:
- Image handling
- Replace ImageStream-based
ImageChangetriggers with: - Pipeline-driven image tag updates, or
- GitOps-managed manifests.
- Triggers
- There is no direct equivalent of
ImageChange/ConfigChangetriggers. - Move trigger logic into your CI/CD or GitOps workflow.
- Hooks
- Replace
pre/posthooks with: - Separate Jobs or CronJobs that run migrations or pre-deploy tasks.
- Pipeline stages running tasks before updating the Deployment.
- Custom strategies
- For highly specialized logic, consider:
- Jobs that orchestrate updates,
- Or rethinking the deployment into simpler rolling/recreate patterns.
In many cases, migration simplifies the resource but requires more explicit CI/CD logic.
Practical Guidelines
- For new, cloud-native applications on OpenShift:
- Use Kubernetes
Deploymentby default. - Let pipelines or GitOps manage versioning and rollouts.
- For existing OpenShift workloads using S2I and ImageStreams:
- Keep
DeploymentConfigif automatic image triggers and hooks are central to your workflow. - Plan a gradual migration if you move to GitOps or want cross-platform portability.
- For HPC or specialized workloads (covered elsewhere in the course):
- Deployment choice may interact with job orchestration patterns; align with those chapters’ recommendations.
Understanding the trade-offs between DeploymentConfig and Deployment allows you to:
- Read and maintain existing OpenShift applications effectively
- Design new workloads that align with modern practices
- Integrate deployment control with CI/CD and GitOps in a deliberate way