Skip to main content
This resource wrapper does not currently exist in the openshift-python-wrapper library.You can use the class generator to create this wrapper for your cluster:
Or work with DeploymentConfig resources using the generic Resource class with kind="DeploymentConfig" and api_group="apps.openshift.io".

Overview

DeploymentConfig is an OpenShift-specific resource that defines the template for a pod and manages deploying new images or configuration changes. DeploymentConfigs provide more advanced deployment strategies and triggers compared to standard Kubernetes Deployments. API Group: apps.openshift.io/v1
While still supported, OpenShift recommends using standard Kubernetes Deployments for new applications. DeploymentConfigs are maintained for backward compatibility and specific OpenShift features.

Class Definition

Constructor

Parameters

str
default:"None"
Name of the DeploymentConfig resource. If not provided, it must be specified in the YAML file.
str
default:"None"
Namespace where the DeploymentConfig will be created. Required for namespaced resources.
DynamicClient
default:"None"
Kubernetes dynamic client for API communication. If not provided, the default client will be used.
int
default:"None"
Number of desired pod replicas. Defaults to 1 if not specified.
dict[str, Any]
default:"None"
Label selector for pods. Must match the labels in the pod template.Example:
dict[str, Any]
default:"None"
Pod template specification. Describes the pods that will be created.Example:
dict[str, Any]
default:"None"
Deployment strategy specification. Defines how the deployment should be executed (Rolling, Recreate, or Custom).Example for Rolling strategy:
list[dict[str, Any]]
default:"None"
List of triggers that automatically start a new deployment. Common trigger types include ConfigChange and ImageChange.Example:
int
default:"None"
Number of old ReplicationControllers to retain for rollback. Defaults to 10.
int
default:"None"
Minimum number of seconds for which a newly created pod should be ready without any containers crashing. Defaults to 0.
bool
default:"None"
Indicates whether the deployment is paused. Paused deployments do not automatically deploy new versions.
bool
default:"True"
If True, the resource will be automatically deleted when used as a context manager.
str
default:"None"
Path to a YAML file containing the DeploymentConfig definition. If provided, the DeploymentConfig will be created from this file.
int
default:"TIMEOUT_4MINUTES"
Timeout in seconds for delete operations. Defaults to 4 minutes.
Any
Additional keyword arguments passed to the parent NamespacedResource class. Common options include label and annotations.

Usage Examples

Basic DeploymentConfig

Create a simple DeploymentConfig:

DeploymentConfig with ImageStream Trigger

Create a DeploymentConfig that automatically deploys when the ImageStream changes:

Rolling Deployment Strategy

Create a DeploymentConfig with a custom rolling deployment strategy:

Recreate Deployment Strategy

Create a DeploymentConfig with Recreate strategy for applications that cannot run multiple versions:

Creating from YAML

Create a DeploymentConfig from a YAML file:

Using Context Manager

Automatically clean up the DeploymentConfig after use:

Deployment Strategies

Rolling Strategy

Gradually replaces old pods with new ones, maintaining availability:

Recreate Strategy

Terminates all old pods before creating new ones:

Custom Strategy

Uses a custom deployment process:

Lifecycle Hooks

DeploymentConfigs support lifecycle hooks for executing tasks during deployment:

Pre Hook

Executes before the deployment starts:

Mid Hook (Recreate only)

Executes after old pods are scaled down but before new pods are created:

Post Hook

Executes after the deployment completes:

Triggers

Configuration Change Trigger

Automatically starts a new deployment when the DeploymentConfig changes:

Image Change Trigger

Automatically starts a new deployment when the specified image changes:

DeploymentConfig vs Deployment

See Also