You are looking at the documentation of a prior release. To read the documentation of the latest release, please
visit here.
New to KubeDB? Please start here.
DocumentDBOpsRequest
What is DocumentDBOpsRequest
DocumentDBOpsRequest is a Kubernetes Custom Resource Definitions (CRD). It provides declarative configuration for DocumentDB administrative operations like database version updating, horizontal scaling, vertical scaling, volume expansion, reconfiguration, TLS reconfiguration, auth rotation, restart, and failover in a Kubernetes native way.
DocumentDBOpsRequest CRD Specifications
Like any official Kubernetes resource, a DocumentDBOpsRequest has TypeMeta, ObjectMeta, Spec and Status sections.
Here, some sample DocumentDBOpsRequest CRs for different administrative operations is given below.
Sample DocumentDBOpsRequest for updating database:
apiVersion: ops.kubedb.com/v1alpha1
kind: DocumentDBOpsRequest
metadata:
name: documentdb-ops-update
namespace: demo
spec:
databaseRef:
name: documentdb-group
type: UpdateVersion
updateVersion:
targetVersion: "16.0"
status:
conditions:
- lastTransitionTime: "2020-06-11T09:59:05Z"
message: The controller has scaled/updated the DocumentDB successfully
observedGeneration: 3
reason: OpsRequestSuccessful
status: "True"
type: Successful
observedGeneration: 3
phase: Successful
Sample DocumentDBOpsRequest for horizontal scaling:
apiVersion: ops.kubedb.com/v1alpha1
kind: DocumentDBOpsRequest
metadata:
name: documentdb-hscale
namespace: demo
spec:
databaseRef:
name: documentdb-group
type: HorizontalScaling
horizontalScaling:
replicas: 3
status:
conditions:
- lastTransitionTime: "2020-06-11T09:59:05Z"
message: The controller has scaled/updated the DocumentDB successfully
observedGeneration: 3
reason: OpsRequestSuccessful
status: "True"
type: Successful
observedGeneration: 3
phase: Successful
Sample DocumentDBOpsRequest for vertical scaling:
apiVersion: ops.kubedb.com/v1alpha1
kind: DocumentDBOpsRequest
metadata:
name: documentdb-vscale
namespace: demo
spec:
databaseRef:
name: documentdb-group
type: VerticalScaling
verticalScaling:
documentdb:
resources:
requests:
memory: "1200Mi"
cpu: "0.7"
limits:
memory: "1200Mi"
cpu: "0.7"
status:
conditions:
- lastTransitionTime: "2020-06-11T09:59:05Z"
message: The controller has scaled/updated the DocumentDB successfully
observedGeneration: 3
reason: OpsRequestSuccessful
status: "True"
type: Successful
observedGeneration: 3
phase: Successful
Here, we are going to describe the various sections of a DocumentDBOpsRequest cr.
DocumentDBOpsRequest Spec
A DocumentDBOpsRequest object has the following fields in the spec section.
spec.databaseRef
spec.databaseRef is a required field that points to the DocumentDB object where the administrative operations will be applied. This field consists of the following sub-field:
- spec.databaseRef.name : specifies the name of the
DocumentDBobject.
spec.type
spec.type is a required field that specifies the kind of operation that will be applied to the database. Currently, the following types of operations are allowed in DocumentDBOpsRequest.
UpdateVersionHorizontalScalingVerticalScalingVolumeExpansionRestartReconfigureReconfigureTLSRotateAuthReconnectStandbyForceFailOverSetRaftKeyPairStorageMigration
You can perform only one type of operation on a single
DocumentDBOpsRequestCR. For example, if you want to update your database and scale up its replicas then you have to create two separateDocumentDBOpsRequest. At first, you have to create aDocumentDBOpsRequestfor updating. Once it is completed, then you can create anotherDocumentDBOpsRequestfor scaling. You should not create twoDocumentDBOpsRequestsimultaneously.
spec.updateVersion
If you want to update your DocumentDB version, you have to specify the spec.updateVersion section that specifies the desired version information. This field consists of the following sub-field:
spec.updateVersion.targetVersionrefers to aDocumentDBVersionCR that contains the DocumentDB version information where you want to update.
You can only update between DocumentDB versions. KubeDB does not support downgrade for DocumentDB.
spec.horizontalScaling
If you want to scale-up or scale-down your DocumentDB cluster, you have to specify the spec.horizontalScaling section. This field consists of the following sub-fields:
spec.horizontalScaling.replicasindicates the desired number of replicas for your DocumentDB cluster after scaling. For example, if your cluster currently has 3 replicas and you want to add 2 more, then you have to specify 5 in this field. Similarly, to remove one replica you specify 2.spec.horizontalScaling.standbyModespecifies the standby mode of the newly added standbys. It can be eitherHotorWarm. Optional; defaults toHot.spec.horizontalScaling.streamingModespecifies the replication streaming mode used for the standbys. It can be eitherSynchronousorAsynchronous. Optional; defaults toAsynchronous.spec.horizontalScaling.readReplicasis a list used to scale the read-replica members of the cluster.
spec.verticalScaling
spec.verticalScaling is a field specifying the information of DocumentDB resources like cpu, memory etc. that will be scaled. This field consists of the following sub-fields:
spec.verticalScaling.documentdbindicates theDocumentDBserver (main container) resources. It has the below structure:
requests:
memory: "200Mi"
cpu: "0.1"
limits:
memory: "300Mi"
cpu: "0.2"
Here, when you specify the resource request for the DocumentDB container, the scheduler uses this information to decide which node to place the container of the Pod on, and when you specify a resource limit for the DocumentDB container, the kubelet enforces those limits so that the running container is not allowed to use more of that resource than the limit you set. You can find more details from here.
spec.verticalScaling.exporterindicates theexportercontainer resources. It has the same structure asspec.verticalScaling.documentdband you can scale the resource the same way.spec.verticalScaling.coordinatorindicates thecoordinatorcontainer resources. It has the same structure asspec.verticalScaling.documentdb.spec.verticalScaling.arbiterindicates the resources of thearbiterPods.spec.verticalScaling.readReplicasis a list used to scale the resources of individual read replicas. Each entry has adocumentdbfield (the container resources) and anamefield identifying the read replica.spec.verticalScaling.modespecifies how the scaling is actuated.Restart(the default) applies the new resources by restarting the Pods, whileInPlaceresizes the running Pods in place via the Kubernetespods/resizesubresource (no restart), automatically falling back toRestartfor any Pod whose Node cannot fit the new resources. Optional; defaults toRestart.
You can increase/decrease resources for the
documentdb,exporter,coordinator, andarbitercontainers on a singleDocumentDBOpsRequestCR.
spec.volumeExpansion
If you want to expand the volume of your DocumentDB cluster, you have to specify the spec.volumeExpansion section. This field consists of the following sub-fields:
spec.volumeExpansion.modespecifies the volume expansion mode. It can be eitherOnlineorOffline, depending on whether the underlying storage class supports online volume expansion.spec.volumeExpansion.documentdbindicates the desired size for the persistent volume of theDocumentDBcontainer.
Volume expansion is only supported when the underlying
StorageClasssupports volume expansion (allowVolumeExpansion: true).
spec.configuration
If you want to reconfigure your running DocumentDB cluster with a new custom configuration, you have to specify the spec.configuration section (used with the Reconfigure type). It lets you apply, change, or remove custom configuration by referencing a Secret or providing inline configuration data.
spec.tls
If you want to reconfigure the TLS configuration of your DocumentDB cluster (issuer, certificates, or turning TLS on/off), you have to specify the spec.tls section (used with the ReconfigureTLS type).
spec.authentication
spec.authentication is used with the RotateAuth type to rotate the database credentials. You can let the operator generate a new random password, or supply your own credentials by referencing a Secret.
spec.restart
spec.restart is used with the Restart type to restart every Pod of the database in a controlled, rolling fashion.
spec.reconnectStandby
spec.reconnectStandby is used with the ReconnectStandby type to re-establish replication for standbys that have fallen out of sync with the primary.
spec.forceFailOver
spec.forceFailOver is used with the ForceFailOver type to force a failover, promoting a standby to become the new primary.
spec.setRaftKeyPair
spec.setRaftKeyPair is used with the SetRaftKeyPair type to set the Raft key pair used for secure intra-cluster communication.
spec.migration
spec.migration is used with the StorageMigration type to migrate the database storage between different storage backends.
spec.timeout
spec.timeout is the timeout for each step of the ops request. If a step doesn’t finish within the specified timeout, the ops request will result in failure.
spec.apply
spec.apply controls the execution of the OpsRequest depending on the database state. It can be either IfReady or Always. When set to IfReady (the default), the operator only proceeds if the database is in a ready state. When set to Always, the operator applies the OpsRequest regardless of the database state.
spec.maxRetries
spec.maxRetries specifies how many times a failed step of the OpsRequest should be retried before the OpsRequest is marked as failed. Optional; defaults to 1.
DocumentDBOpsRequest Status
.status describes the current state and progress of the DocumentDBOpsRequest operation. It has the following fields:
status.phase
status.phase indicates the overall phase of the operation for this DocumentDBOpsRequest. It can have the following values:
| Phase | Meaning |
|---|---|
| Successful | KubeDB has successfully performed the operation requested in the DocumentDBOpsRequest |
| Failed | KubeDB has failed the operation requested in the DocumentDBOpsRequest |
| Denied | KubeDB has denied the operation requested in the DocumentDBOpsRequest |
status.observedGeneration
status.observedGeneration shows the most recent generation observed by the DocumentDBOpsRequest controller.
status.conditions
status.conditions is an array that specifies the conditions of different steps of DocumentDBOpsRequest processing. Each condition entry has the following fields:
typespecifies the type of the condition. DocumentDBOpsRequest has the following types of conditions:
| Type | Meaning |
|---|---|
Progressing | Specifies that the operation is now progressing |
Successful | Specifies such a state that the operation on the database has been successful. |
HaltDatabase | Specifies such a state that the database is halted by the operator |
ResumeDatabase | Specifies such a state that the database is resumed by the operator |
Failure | Specifies such a state that the operation on the database has been failed. |
Scaling | Specifies such a state that the scaling operation on the database has started |
VerticalScaling | Specifies such a state that vertical scaling has performed successfully on database |
HorizontalScaling | Specifies such a state that horizontal scaling has performed successfully on database |
Updating | Specifies such a state that database updating operation has started |
UpdateVersion | Specifies such a state that version updating on the database has performed successfully |
- The
statusfield is a string, with possible values"True","False", and"Unknown".statuswill be"True"if the current transition succeeded.statuswill be"False"if the current transition failed.statuswill be"Unknown"if the current transition is denied.
- The
messagefield is a human-readable message indicating details about the condition. - The
reasonfield is a unique, one-word, CamelCase reason for the condition’s last transition. - The
lastTransitionTimefield provides a timestamp for when the operation last transitioned from one state to another. - The
observedGenerationshows the most recent condition transition generation observed by the controller.































