KAHIBARO Bookshelves
Discord Login Register

7.4. DeploymentConfigs and Deployments

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
    • Deployment is a standard Kubernetes resource (apps/v1) and is portable.
    • DeploymentConfig is an OpenShift extension (apps.openshift.io/v1).
  • Triggers
    • Deployment typically reacts to spec changes or CI/CD tools.
    • DeploymentConfig has 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 DeploymentConfig uses:
      • Rolling, Recreate, Custom strategies
      • Pre/post lifecycle hooks
    • Deployment uses standardized Kubernetes strategies:
      • RollingUpdate
      • Recreate
  • Ecosystem compatibility
    • Deployment integrates seamlessly with upstream Kubernetes features, Operators, Helm charts, and GitOps tools.
    • DeploymentConfig is 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/v1
  • kind: DeploymentConfig

A DeploymentConfig definition usually includes:

  • spec.replicas – desired replica count
  • spec.selector – label selectors for managed pods
  • spec.template – pod template
  • spec.strategy – how updates are performed
  • spec.triggers – what causes new rollouts
  • status – 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:

  1. ConfigChange
    • Activated when the DeploymentConfig spec (e.g., environment vars, pod template) changes.
    • When configChange is present, any change to the pod template will start a new deployment automatically.
  2. ImageChange
    • Activated when an ImageStreamTag referenced in the pod template is updated (new image version).
    • Ties deployments directly to OpenShift ImageStreams, enabling automatic rollouts when new images are built/pushed.
  3. 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:latest

Key details:

  • automatic: true means the rollout happens as soon as the image tag changes.
  • You can restrict auto-rollouts to specific containers in the pod.
  • You can combine ConfigChange and ImageChange triggers, or disable them and trigger deployments manually (e.g. via oc rollout).

Strategies

DeploymentConfig supports three strategies under spec.strategy.type:

  1. Rolling (default for most apps)
  2. Recreate
  3. 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: 1
  • maxUnavailable – 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: Recreate
Custom 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: production

Use 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; ExecNewPod is 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, or Ignore
    • Abort stops the deployment on hook failure.
    • Retry re-runs the hook.
    • Ignore continues 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 dc
    • oc 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:

  1. Build image via S2I or pipeline into an ImageStream.
  2. ImageChange trigger detects new ImageStreamTag.
  3. DeploymentConfig automatically starts a new rollout.
  4. Hooks (if any) run before/after the rollout.
  5. oc rollout used 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/v1
  • kind: Deployment

Key fields:

  • spec.replicas
  • spec.selector
  • spec.template
  • spec.strategy
  • spec.revisionHistoryLimit
  • spec.progressDeadlineSeconds

Under the hood, a Deployment manages ReplicaSets, which then own the pods.

Strategies

Deployment supports:

  1. RollingUpdate (default)
  2. 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.replicas or 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 image or oc 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/myapp

Advanced 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 Deployment spec (image field) in Git or via API.
  • Kubernetes Deployment manages 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:
          - myapp

Equivalent 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 triggers section in Deployment.
  • Uses selector.matchLabels instead of plain selector map.
  • Uses standard image reference (registry URL), not ImageStreams.

Migration Considerations

When moving from DeploymentConfig to Deployment:

  • Image handling
    • Replace ImageStream-based ImageChange triggers with:
      • Pipeline-driven image tag updates, or
      • GitOps-managed manifests.
  • Triggers
    • There is no direct equivalent of ImageChange / ConfigChange triggers.
    • Move trigger logic into your CI/CD or GitOps workflow.
  • Hooks
    • Replace pre/post hooks 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 Deployment by default.
    • Let pipelines or GitOps manage versioning and rollouts.
  • For existing OpenShift workloads using S2I and ImageStreams:
    • Keep DeploymentConfig if 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

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!

Where to Move

Move chapter:

  • ☰ 1. Course Overview
    • ☰ 1.1. What is OpenShift
      • ☰ 1.2. Why OpenShift is used in modern IT and cloud environments
        • ☰ 1.3. OpenShift vs Kubernetes
          • ☰ 1.4. Typical OpenShift use cases
            • ☰ 1.5. Structure and goals of the course
            • ☰ 2. Containers and Cloud-Native Fundamentals
              • ☰ 2.1. What is a container
                • ☰ 2.2. Containers vs virtual machines
                  • ☰ 2.3. Introduction to Docker and container images
                    • ☰ 2.4. Container registries
                      • ☰ 2.5. Basics of cloud-native applications
                      • ☰ 3. Kubernetes Fundamentals
                        • ☰ 3.1. What is Kubernetes
                          • ☰ 3.2. Kubernetes architecture
                            • ☰ 3.3. Control plane components
                              • ☰ 3.4. Worker node components
                                • ☰ 3.5. Kubernetes objects and resources
                                  • ☰ 3.6. Declarative configuration model
                                  • ☰ 4. OpenShift Architecture
                                    • ☰ 4.1. Overview of OpenShift architecture
                                      • ☰ 4.2. Control plane in OpenShift
                                        • ☰ 4.3. Nodes and machine roles
                                          • ☰ 4.4. OpenShift Operators
                                            • ☰ 4.5. OpenShift networking model
                                              • ☰ 4.6. OpenShift storage model
                                              • ☰ 5. OpenShift Installation and Deployment Models
                                                • ☰ 5.1. OpenShift deployment options
                                                  • ☰ 5.2. Installer-Provisioned Infrastructure
                                                    • ☰ 5.3. User-Provisioned Infrastructure
                                                      • ☰ 5.4. Managed OpenShift services
                                                        • ☰ 5.5. Single-node OpenShift
                                                          • ☰ 5.6. Cluster lifecycle management
                                                          • ☰ 6. Accessing and Using OpenShift
                                                            • ☰ 6.1. OpenShift web console
                                                              • ☰ 6.2. OpenShift CLI (oc)
                                                                • ☰ 6.3. Authentication and authorization
                                                                  • ☰ 6.4. Projects and namespaces
                                                                    • ☰ 6.5. Resource quotas and limits
                                                                    • ☰ 7. Building and Deploying Applications
                                                                      • ☰ 7.1. Application deployment concepts
                                                                        • ☰ 7.2. Source-to-Image (S2I)
                                                                          • ☰ 7.3. Container-based deployments
                                                                            • ☰ 7.4. DeploymentConfigs and Deployments
                                                                              • ☰ 7.5. Rolling updates and rollbacks
                                                                              • ☰ 8. Networking in OpenShift
                                                                                • ☰ 8.1. Services and service discovery
                                                                                  • ☰ 8.2. Routes and ingress
                                                                                    • ☰ 8.3. Network policies
                                                                                      • ☰ 8.4. Load balancing
                                                                                        • ☰ 8.5. External access to applications
                                                                                        • ☰ 9. Storage in OpenShift
                                                                                          • ☰ 9.1. Persistent storage concepts
                                                                                            • ☰ 9.2. Persistent Volumes
                                                                                              • ☰ 9.3. Persistent Volume Claims
                                                                                                • ☰ 9.4. StorageClasses
                                                                                                  • ☰ 9.5. Dynamic provisioning
                                                                                                    • ☰ 9.6. Stateful applications
                                                                                                    • ☰ 10. Configuration and Secrets Management
                                                                                                      • ☰ 10.1. ConfigMaps
                                                                                                        • ☰ 10.2. Secrets
                                                                                                          • ☰ 10.3. Environment variables
                                                                                                            • ☰ 10.4. Managing sensitive data
                                                                                                              • ☰ 10.5. Best practices for configuration
                                                                                                              • ☰ 11. Scaling and High Availability
                                                                                                                • ☰ 11.1. Horizontal pod autoscaling
                                                                                                                  • ☰ 11.2. Vertical scaling
                                                                                                                    • ☰ 11.3. Self-healing and pod restarts
                                                                                                                      • ☰ 11.4. High availability concepts
                                                                                                                        • ☰ 11.5. Multi-zone and multi-region clusters
                                                                                                                        • ☰ 12. Monitoring, Logging, and Observability
                                                                                                                          • ☰ 12.1. Built-in monitoring stack
                                                                                                                            • ☰ 12.2. Metrics and alerts
                                                                                                                              • ☰ 12.3. Logging architecture
                                                                                                                                • ☰ 12.4. Distributed tracing
                                                                                                                                  • ☰ 12.5. Troubleshooting applications
                                                                                                                                  • ☰ 13. Security in OpenShift
                                                                                                                                    • ☰ 13.1. Security model overview
                                                                                                                                      • ☰ 13.2. Role-Based Access Control
                                                                                                                                        • ☰ 13.3. Security Context Constraints
                                                                                                                                          • ☰ 13.4. Image security and scanning
                                                                                                                                            • ☰ 13.5. Network security
                                                                                                                                              • ☰ 13.6. Compliance and auditing
                                                                                                                                              • ☰ 14. CI/CD and DevOps with OpenShift
                                                                                                                                                • ☰ 14.1. DevOps concepts
                                                                                                                                                  • ☰ 14.2. CI/CD pipelines overview
                                                                                                                                                    • ☰ 14.3. OpenShift Pipelines (Tekton)
                                                                                                                                                      • ☰ 14.4. GitOps with Argo CD
                                                                                                                                                        • ☰ 14.5. Integrating OpenShift with external CI tools
                                                                                                                                                        • ☰ 15. Operators and Platform Services
                                                                                                                                                          • ☰ 15.1. What are Operators
                                                                                                                                                            • ☰ 15.2. Operator Lifecycle Manager
                                                                                                                                                              • ☰ 15.3. Installing and managing Operators
                                                                                                                                                                • ☰ 15.4. Common platform Operators
                                                                                                                                                                  • ☰ 15.5. Custom Operators
                                                                                                                                                                  • ☰ 16. Upgrades, Maintenance, and Operations
                                                                                                                                                                    • ☰ 16.1. OpenShift upgrade process
                                                                                                                                                                      • ☰ 16.2. Backup and restore
                                                                                                                                                                        • ☰ 16.3. Node maintenance
                                                                                                                                                                          • ☰ 16.4. Cluster troubleshooting
                                                                                                                                                                            • ☰ 16.5. Capacity planning
                                                                                                                                                                            • ☰ 17. OpenShift on HPC and Specialized Workloads
                                                                                                                                                                              • ☰ 17.1. Running batch workloads on OpenShift
                                                                                                                                                                                • ☰ 17.2. OpenShift and GPUs
                                                                                                                                                                                  • ☰ 17.3. MPI and parallel workloads in containers
                                                                                                                                                                                    • ☰ 17.4. Hybrid HPC and cloud workflows
                                                                                                                                                                                    • ☰ 18. OpenShift in Practice
                                                                                                                                                                                      • ☰ 18.1. Typical OpenShift workflows
                                                                                                                                                                                        • ☰ 18.2. Development to production lifecycle
                                                                                                                                                                                          • ☰ 18.3. Case studies from industry
                                                                                                                                                                                            • ☰ 18.4. Common pitfalls and best practices
                                                                                                                                                                                            • ☰ 19. Future Directions and Ecosystem
                                                                                                                                                                                              • ☰ 19.1. Kubernetes ecosystem overview
                                                                                                                                                                                                • ☰ 19.2. OpenShift roadmap
                                                                                                                                                                                                  • ☰ 19.3. Serverless and event-driven workloads
                                                                                                                                                                                                    • ☰ 19.4. AI and data platforms on OpenShift
                                                                                                                                                                                                    • ☰ 20. Final Project and Hands-On Exercises
                                                                                                                                                                                                      • ☰ 20.1. Deploying a containerized application
                                                                                                                                                                                                        • ☰ 20.2. Implementing CI/CD with OpenShift
                                                                                                                                                                                                          • ☰ 20.3. Securing and scaling an application
                                                                                                                                                                                                            • ☰ 20.4. Monitoring and troubleshooting report