Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Overview
The DatadogPodAutoscaler (DPA) is a Kubernetes custom resource definition (CRD) that enables autoscaling of Kubernetes workloads using Datadog Kubernetes Autoscaling (DKA). This guide demonstrates how to manage DatadogPodAutoscaler resources using ArgoCD and GitOps principles to deploy an autoscaling configuration.
ArgoCD is a declarative, GitOps continuous delivery tool for Kubernetes. It monitors Git repositories containing Kubernetes manifests and keeps your cluster synchronized with the desired state defined in Git. This approach provides version control, audit trails, and automated deployment of your autoscaling infrastructure.
Prerequisites
Before you begin, ensure you have the following:
Kubernetes cluster: A working Kubernetes cluster (1.20 or later) with access using kubectl
ArgoCD installed: ArgoCD deployed in your cluster and accessible via CLI or UI
Datadog API credentials: Valid Datadog API key and application key
Git repository: A Git repository to store your manifests
Project structure
This guide uses the App of Apps pattern with ArgoCD sync waves to ensure proper dependency creation and deployment order.
.├──argocd/│├──root-app.yaml# App of Apps controller│└──apps/│├──datadog-operator.yaml# ArgoCD Application for Operator│├──datadog-agent.yaml# ArgoCD Application for Agent│└──nginx-dka-demo.yaml# ArgoCD Application for workload├──manifests/│└──stage2-agent/│└──datadog-agent.yaml# DatadogAgent custom resource└──charts/└──nginx-dka-demo/├──Chart.yaml├──values.yaml└──templates/├──deployment.yaml└──pod-autoscaler.yaml
Deployment stages
A multi-stage deployment approach is essential when working with Kubernetes custom resource definitions (CRDs) and ArgoCD. This ordered approach is necessary to ensure that you create and install the dependencies required for each stage in the process.
Kubernetes CRDs must be installed in the cluster before you can create custom resources that use them. The DatadogPodAutoscaler CRD is created when you install the Datadog Operator in Stage 1. ArgoCD needs these CRDs to be present before it can successfully sync resources that depend on them.
ArgoCD uses sync waves to control the deployment order through annotations. Sync waves are executed in ascending order (lower numbers first), and ArgoCD waits for all resources in a wave to be healthy before proceeding to the next wave.
Stage 1 (Wave 0): Datadog Operator using Helm (creates CRDs)
DatadogAgent custom resource with Autoscaling requirements enabled
Stage 3 (Wave 2): Application workload with DatadogPodAutoscaler
NGINX deployment in demo namespace
DatadogPodAutoscaler resource for autoscaling the NGINX deployment
Set up configuration files
First, create a Git repository. You need to update all repoURL references in the ArgoCD Application manifests to point to your repository, as ArgoCD pulls manifests from Git.
Set up the following configuration files for each stage in the process.
Stage 1: Root Application (App of Apps)
The root Application is the App of Apps controller that manages all child Applications.
You should see all applications appear and synchronize in wave order: datadog-operator (wave 0), then datadog-agent (wave 1), and nginx-dka-demo (wave 2).
Validate deployment
Verify that the Datadog Operator and CRDs are deployed:
kubectl get crd | grep datadoghq
kubectl get pods -n datadog
You should see the Datadog CRDs created and the datadog-operator pod running.
Verify that the Datadog Agent is deployed:
kubectl get datadogagent -n datadog
You should see the DatadogAgent custom resource created in the Running state. Also verify that the Datadog Agent and datadog-cluster-agent pods are running: