Infrastructure as Code (IaC) and GitOps workflows
The Mission Control UI is optional for cluster creation and modification.
Mission Control fully supports infrastructure-as-code (IaC) and GitOps workflows through direct Kubernetes API interaction.
You can manage your entire database infrastructure using YAML manifests, kubectl, and GitOps tools like Argo CD and Flux.
|
Direct Kubernetes API interaction is a primary supported method for production deployments. Most Mission Control testing occurs with direct Kubernetes API interaction. |
For a comparison of UI-based and programmatic workflows, including cluster creation modes and use cases, see Choose your workflow.
Best practices
Follow these best practices when you manage Mission Control clusters as code:
-
Version control: Store all cluster manifests in Git repositories to maintain history, enable rollbacks, and provide audit trails.
-
Separate environments: Use different namespaces or clusters for development, staging, and production environments to isolate changes and reduce risk.
-
Automated testing: Test manifest changes in non-production environments before you apply them to production to catch configuration errors early.
-
Monitoring and alerts: Set up monitoring for custom resource status conditions and operator health to detect issues quickly. For more information, see Metrics.
-
Resource management: Define resource requests and limits explicitly in your manifests to ensure predictable performance and prevent resource contention.
-
Backup automation: Automate backup creation using scheduled
K8ssandraTaskresources or CronJobs to protect against data loss. -
Documentation: Document your cluster configurations, naming conventions, and operational procedures to ensure team alignment and knowledge sharing.
Create clusters with the direct API workflow
You can create database clusters by applying MissionControlCluster custom resources directly to the Kubernetes API.
To create clusters with kubectl, do the following:
-
Make sure you have the following prerequisites:
-
Access to a Kubernetes cluster with Mission Control installed
-
kubectlconfigured to access your cluster -
Appropriate RBAC permissions to create
MissionControlClusterresources
-
-
Create a YAML manifest for your cluster:
apiVersion: missioncontrol.datastax.com/v1beta2 kind: MissionControlCluster metadata: name: production-cluster namespace: default spec: k8ssandra: cassandra: serverType: hcd serverVersion: "2.0.6" datacenters: - metadata: name: dc1 size: 3 storageConfig: cassandraDataVolumeClaimSpec: storageClassName: fast-ssd accessModes: - ReadWriteOnce resources: requests: storage: 100Gi resources: requests: memory: 16Gi cpu: 4 limits: memory: 16Gi cpu: 4 -
Apply the manifest to create the cluster:
kubectl apply -f production-cluster.yaml -
Monitor cluster creation progress:
kubectl get missioncontrolcluster production-cluster -w -
Check detailed cluster status:
kubectl describe missioncontrolcluster production-cluster
The cluster creation process follows the same automated reconciliation steps regardless of whether you use the UI or direct API interaction. For more information about the reconciliation process, see administration:control-plane/add-db-cluster.adoc#automatic-reconciliation-steps-for-missioncontrolcluster-resources.
Modify clusters with the direct API workflow
You can update the MissionControlCluster custom resource to modify existing clusters.
-
Edit the cluster manifest:
kubectl edit missioncontrolcluster production-clusterOr update your YAML file and reapply:
kubectl apply -f production-cluster.yaml -
Monitor the modification progress:
kubectl get missioncontrolcluster production-cluster -w
Mission Control operators detect the changes and reconcile the cluster to match the new desired state. The reconciliation process handles rolling updates, configuration changes, and scaling operations automatically.
Manage cluster lifecycle with the direct API workflow
You can perform common cluster lifecycle operations using kubectl and custom resources.
For example:
- Scale a datacenter
-
kubectl patch missioncontrolcluster production-cluster --type=merge -p ' { "spec": { "k8ssandra": { "cassandra": { "datacenters": [ { "metadata": {"name": "dc1"}, "size": 6 } ] } } } }' - Add a datacenter
-
Edit the cluster manifest to include an additional datacenter in the
datacentersarray, then apply the changes. - Remove a cluster
-
kubectl delete missioncontrolcluster production-cluster
For detailed information about cluster lifecycle operations, see Administer database clusters.
Perform database operations
You can execute database operations like backups, restores, and repairs using K8ssandraTask custom resources.
For example, to create an apply a backup task:
-
Create a backup task:
apiVersion: control.k8ssandra.io/v1alpha1 kind: K8ssandraTask metadata: name: backup-production namespace: default spec: cluster: name: production-cluster template: backup: name: daily-backup -
Apply the task:
kubectl apply -f backup-task.yaml -
Monitor task progress:
kubectl get k8ssandratask backup-production -w
For more information about database tasks, see Cassandra operations task CassandraTask.