### Get DatadogAgent, Profile, and DatadogAgentInternal (With Profiles) Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_agent_internal.md Example of retrieving DatadogAgent, DatadogAgentProfile, and the resulting DatadogAgentInternal resources when using DatadogAgentProfiles. ```bash kubectl get datadogagent -n datadog NAME AGE datadog 10m ``` ```bash kubectl get datadogagentprofile -n datadog NAME AGE high-memory-nodes 2m ``` ```bash kubectl get ddai -n datadog NAME AGENT CLUSTER-AGENT CLUSTER-CHECKS-RUNNER AGE datadog Running Running Running 10m high-memory-nodes Running 2m ``` -------------------------------- ### Setup for Upstream CI Testing Source: https://github.com/datadog/datadog-operator/blob/main/RELEASING.md Install Ansible and Docker, configure user permissions, and clone the community-operators repository to run the operator test suite. ```bash sudo apt update && sudo apt install ansible docker.io sudo usermod -a -G docker ubuntu # Close and re-open connection sudo sysctl net/netfilter/nf_conntrack_max=131072 # Fix startup issues in `kube-proxy` git clone https://github.com/k8s-operatorhub/community-operators.git cd community-operators ``` -------------------------------- ### Install Operator SDK Source: https://github.com/datadog/datadog-operator/blob/main/RELEASING.md Install the Operator SDK if it's not already present in your cluster. ```bash ./bin/operator-sdk olm install ``` -------------------------------- ### Install Datadog kubectl Plugin Source: https://github.com/datadog/datadog-operator/blob/main/docs/kubectl-plugin.md Install the Datadog plugin using the Krew plugin manager. This command installs the plugin and provides feedback on the installation status. ```shell kubectl krew install datadog ``` ```console $ kubectl krew install datadog Installing plugin: datadog Installed plugin: datadog \ | Use this plugin: | datadog | Documentation: | https://github.com/DataDog/datadog-operator / ``` -------------------------------- ### Copy Component Template Source: https://github.com/datadog/datadog-operator/blob/main/docs/component_registry_dev/QUICK_START.md Use this command to copy the component example template to your new component file. ```bash cp component_example.go.tmpl component_myservice.go ``` -------------------------------- ### Get DatadogAgent and DatadogAgentInternal (No Profiles) Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_agent_internal.md Example of retrieving DatadogAgent and its corresponding DatadogAgentInternal resources when not using DatadogAgentProfiles. ```bash kubectl get datadogagent -n datadog NAME AGE datadog 5m ``` ```bash kubectl get ddai -n datadog NAME AGENT CLUSTER-AGENT CLUSTER-CHECKS-RUNNER AGE datadog Running Running Running 5m ``` -------------------------------- ### Install Datadog Operator with Generic Resource Enabled Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_generic_resource.md Install the Datadog Operator, enabling the DatadogGenericResource controller and providing API and application keys. ```shell helm install datadog-operator datadog/datadog-operator --set apiKey= --set appKey= --set datadogGenericResource.enabled=true ``` -------------------------------- ### Add Datadog Helm Repository and Install Operator Source: https://github.com/datadog/datadog-operator/blob/main/docs/getting_started.md Add the Datadog Helm repository and install the Datadog Operator. Ensure Helm is installed. ```shell helm repo add datadog https://helm.datadoghq.com helm install my-datadog-operator datadog/datadog-operator ``` -------------------------------- ### Query Datadog Generic Resources Source: https://context7.com/datadog/datadog-operator/llms.txt Example command to list DatadogGenericResource objects in the 'datadog' namespace. ```shell kubectl get datadoggenericresources -n datadog # NAME TYPE SYNC ID AGE # api-health-check synthetics_api_test OK abc-123-def 5m ``` -------------------------------- ### Install YAML Mapper Tool Source: https://github.com/datadog/datadog-operator/blob/main/cmd/yaml-mapper/README.md Build the yaml-mapper executable using make. Add the /bin directory to your PATH for easy access. ```bash make yaml-mapper ``` -------------------------------- ### Install Datadog Operator with values.yaml Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_generic_resource.md Install the Datadog Operator using a values.yaml file that includes API/application keys and enables the DatadogGenericResource controller. ```shell helm install datadog-operator datadog/datadog-operator -f values.yaml ``` -------------------------------- ### Install Datadog Operator with Conversion Webhook Source: https://github.com/datadog/datadog-operator/blob/main/docs/v2alpha1_migration.md Install the Datadog Operator v1.0.0+ with the necessary configurations for CRD migration, including enabling the conversion webhook server. ```shell helm install \ datadog-operator datadog/datadog-operator \ --set image.tag=1.0.0 \ --set datadogCRDs.migration.datadogAgents.version=v2alpha1 \ --set datadogCRDs.migration.datadogAgents.useCertManager=true \ --set datadogCRDs.migration.datadogAgents.conversionWebhook.enabled=true ``` -------------------------------- ### Install Autoscaling on EKS Cluster Source: https://github.com/datadog/datadog-operator/blob/main/docs/kubectl-plugin.md Installs Karpenter on an EKS cluster and configures it for Datadog Cluster Autoscaling. This command creates necessary AWS resources, configures authentication, and installs Karpenter via Helm. ```shell kubectl datadog autoscaling cluster install --help Install autoscaling on an EKS cluster Usage: datadog autoscaling cluster install [flags] Examples: # install autoscaling kubectl datadog autoscaling cluster install Flags: --cluster-name string Name of the EKS cluster --create-karpenter-resources CreateKarpenterResources Which Karpenter resources to create: none, ec2nodeclass, all (default: all) (default all) --debug Enable debug logs --inference-method InferenceMethod Method to infer EC2NodeClass and NodePool properties: nodes, nodegroups (default nodegroups) --karpenter-namespace string Name of the Kubernetes namespace to deploy Karpenter into (default "dd-karpenter") --karpenter-version string Version of Karpenter to install (default to latest) ``` -------------------------------- ### DatadogAgent - Minimal Deployment Source: https://context7.com/datadog/datadog-operator/llms.txt This example demonstrates a minimal DatadogAgent configuration, which deploys the Node Agent and Cluster Agent with default settings. It requires the Datadog API and App keys to be provided. ```APIDOC ## DatadogAgent — Minimal deployment The primary CRD (`datadoghq.com/v2alpha1`) deploys Node Agent DaemonSets, a Cluster Agent Deployment, and optionally Cluster Checks Runners. `spec.global` sets cluster-wide settings; `spec.features` enables individual product features; `spec.override` provides per-component Pod template overrides. ### Request Example ```yaml apiVersion: datadoghq.com/v2alpha1 kind: DatadogAgent metadata: name: datadog spec: global: clusterName: my-cluster credentials: apiKey: appKey: ``` ### Response Example ```shell kubectl apply -f datadog-agent.yaml kubectl get datadogagents datadog # NAME AGENT CLUSTER-AGENT CLUSTER-CHECKS-RUNNER AGE # datadog Deployment available Available 2m ``` ``` -------------------------------- ### Generate Red Hat Bundle Source: https://github.com/datadog/datadog-operator/blob/main/RELEASING.md Run this command locally to generate the Red Hat bundle. This requires Skopeo to be installed and Red Hat registry credentials configured. ```bash make bundle-redhat ``` -------------------------------- ### Install Datadog Operator with DatadogMonitor Enabled Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_monitor.md Install the Datadog Operator using Helm, enabling DatadogMonitor functionality and providing your Datadog API and application keys. ```shell helm install my-datadog-operator datadog/datadog-operator --set apiKey= --set appKey= --set datadogMonitor.enabled=true ``` -------------------------------- ### Create a DatadogDashboard resource Source: https://context7.com/datadog/datadog-operator/llms.txt Manage Datadog dashboards using the DatadogDashboard custom resource. This example creates a CPU usage dashboard with template variables. ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogDashboard metadata: name: cpu-usage-dashboard namespace: datadog spec: title: "Kubernetes CPU Usage" layoutType: ordered # "ordered" or "free" tags: - "team:platform" notifyList: - platform-team@example.com templateVariables: - name: env prefix: env availableValues: - prod - staging widgets: | [{ "definition": { "title": "CPU Usage by Host", "type": "timeseries", "requests": [{ "formulas": [{"formula": "query1"}], "queries": [{ "name": "query1", "data_source": "metrics", "query": "avg:system.cpu.user{$env} by {host}" }], "response_format": "timeseries", "style": {"palette": "dog_classic", "line_type": "solid"} }], "show_legend": true }, "layout": {"x": 0, "y": 0, "width": 6, "height": 3} }] ``` -------------------------------- ### Install Datadog Operator with SLO enabled (API Key) Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_slo.md Install the Datadog Operator using Helm, enabling the DatadogSLO controller and providing your Datadog API and application keys. ```shell helm install my-datadog-operator datadog/datadog-operator --set apiKey= --set appKey= --set datadogSLO.enabled=true ``` -------------------------------- ### Build and Deploy Datadog Agent with mpdev Source: https://github.com/datadog/datadog-operator/blob/main/marketplaces/charts/google-marketplace/README.md This command builds the Datadog deployer image, pushes it to your Google Container Registry, and then installs the Datadog Agent using mpdev. Replace "" with your actual Datadog API key. Ensure the `TAG` variable is set to the desired Datadog Operator version. ```shell export REGISTRY=gcr.io/$(gcloud config get-value project | tr ':' '/') export APP_NAME=datadog export TAG=1.3.0 # Datadog Operator version that will be installed kubectl create ns datadog-agent docker build --pull --platform linux/amd64 --build-arg TAG=$TAG --tag $REGISTRY/$APP_NAME/deployer . && docker push $REGISTRY/$APP_NAME/deployer && mpdev install \ --deployer=$REGISTRY/$APP_NAME/deployer \ --parameters='{"name": "datadog", "namespace": "datadog-agent", "datadog.credentials.apiKey": ""}' ``` -------------------------------- ### Create a DatadogMonitor resource Source: https://context7.com/datadog/datadog-operator/llms.txt Define a Datadog monitor using the DatadogMonitor custom resource. This example creates a query alert for deployment replica issues. ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogMonitor metadata: name: deployment-replicas-monitor namespace: datadog spec: name: "[kubernetes] Deployment Replica Pods Down" type: "query alert" query: > avg(last_15m):avg:kubernetes_state.deployment.replicas_desired{*} - avg:kubernetes_state.deployment.replicas_available{*} message: "More than one Deployment replica pod is unavailable. @pagerduty-oncall" tags: - "integration:kubernetes" - "env:prod" options: evaluationDelay: 300 includeTags: true newGroupDelay: 60 notificationPresetName: show_all thresholds: critical: "2" warning: "1" priority: 2 ``` -------------------------------- ### Install Datadog Operator with SLO enabled (values.yaml) Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_slo.md Install the Datadog Operator using Helm with a custom values.yaml file that enables the DatadogSLO controller and includes your Datadog API and application keys. ```shell helm install my-datadog-operator datadog/datadog-operator -f values.yaml ``` -------------------------------- ### DatadogGenericResource Notebook Example Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_generic_resource.md Define a DatadogGenericResource for a notebook, specifying the notebook's structure and content. ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogGenericResource metadata: name: ddgr-notebook-sample namespace: spec: type: notebook jsonSpec: |- { "data": { "attributes": { "cells": [ { "attributes": { "definition": { "text": "## Some test markdown\n\n```js\nvar x, y;\nx = 5;\ny = 6;\n```", "type": "markdown" } }, "type": "notebook_cells" }, { "attributes": { "definition": { "requests": [ { "display_type": "line", "q": "avg:system.load.1{*}", "style": { "line_type": "solid", "line_width": "normal", "palette": "dog_classic" } } ], "show_legend": true, "type": "timeseries", "yaxis": { "scale": "linear" } }, "graph_size": "m", "split_by": { "keys": [], "tags": [] }, "time": null }, "type": "notebook_cells" } ], "name": "Example-Notebook", "status": "published", "time": { "live_span": "1h" } }, "type": "notebooks" } } ``` -------------------------------- ### Verify ConfigMap Creation Source: https://github.com/datadog/datadog-operator/blob/main/docs/integrations_autodiscovery.md Use `kubectl get configmap` to verify that the ConfigMap has been created correctly with the configuration data. ```shell $ kubectl get configmap -n $DD_NAMESPACE confd-config -o yaml apiVersion: v1 data: http_check.yaml: |- init_config: instances: - url: "http://%%host%%" name: "My service" kind: ConfigMap metadata: name: confd-config namespace: datadog ``` -------------------------------- ### Verify DatadogAgentProfile Deployment Source: https://context7.com/datadog/datadog-operator/llms.txt Use `kubectl get` commands to verify the creation and status of DatadogAgentProfile resources and their corresponding DaemonSets. ```shell kubectl get datadogagentprofiles # NAME VALID APPLIED AGE # high-memory-nodes True True 3m kubectl get ds # NAME DESIRED CURRENT READY ... # datadog-agent 8 8 8 ... (default profile) # high-memory-nodes 2 2 2 ... (profile DaemonSet) ``` -------------------------------- ### Describe Datadog Monitor Details Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_monitor.md Inspect a DatadogMonitor resource for detailed information, including its configuration, labels, annotations, and status conditions. This is useful for understanding the monitor's setup and any reported errors. ```shell $ kubectl describe datadogmonitor datadog-event-v2-alert-test Name: datadog-event-v2-alert-test Namespace: system Labels: Annotations: API Version: datadoghq.com/v1alpha1 Kind: DatadogMonitor Metadata: Creation Timestamp: 2025-09-22T19:10:03Z Finalizers: finalizer.monitor.datadoghq.com Generation: 5 Resource Version: 3193 UID: 60c8071f-518f-4b75-a445-caaecea92061 Spec: Controller Options: Message: 1-2-3 testing Name: Test event v2 alert made from DatadogMonitor Options: Evaluation Delay: 300 Include Tags: true Locked: false No Data Timeframe: 30 Notify No Data: true Renotify Interval: 1440 Priority: 5 Query: events("sources:nagios status:(error OR warning) priority:normal").rollup("count").last("1h") > 10 Tags: test:datadog generated:kubernetes Type: event-v2 alert Status: Conditions: Last Transition Time: 2025-09-22T19:10:21Z Last Update Time: 2025-09-22T19:10:21Z Status: False Type: Error Last Transition Time: 2025-09-22T19:10:21Z Last Update Time: 2025-09-22T19:10:21Z Message: DatadogMonitor Created Status: True Type: Created Last Transition Time: 2025-09-22T19:10:21Z Last Update Time: 2025-09-22T19:10:21Z Message: DatadogMonitor ready Status: True Type: Active Last Transition Time: 2025-09-22T19:10:26Z Last Update Time: 2025-09-22T19:10:26Z Message: DatadogMonitor Updated Status: True Type: Updated Created: 2025-09-22T19:10:21Z Creator: eman.okyere@datadoghq.com Current Hash: 009148d415bf6e16d2f920e69d03a5f3 Downtime Status: Id: 217179025 Monitor Last Force Sync Time: 2025-09-22T19:10:26Z Monitor State: OK Monitor State Last Transition Time: 2025-09-22T19:11:27Z Monitor State Last Update Time: 2025-09-22T19:32:31Z Monitor State Sync Status: OK Primary: true Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Create DatadogMonitor 22m DatadogMonitor system/datadog-event-v2-alert-test ``` -------------------------------- ### Run Tests and Build Source: https://github.com/datadog/datadog-operator/blob/main/docs/component_registry_dev/QUICK_START.md After implementing and registering your component, run the provided make commands to test and build your changes. ```bash make test make build ``` -------------------------------- ### Kubectl Datadog Plugin Commands Source: https://context7.com/datadog/datadog-operator/llms.txt The kubectl datadog plugin provides commands for operator introspection and management, including installing the plugin, getting status, finding agents, running checks, upgrading images, managing cluster agents, validating configurations, converting Helm values, collecting flares, and inspecting autoscaling. ```shell # Install kubectl krew install datadog # Get DatadogAgent status summary kubectl datadog get # Find which Node Agent pod monitors a given pod kubectl datadog agent find -n # Run a check on the Node Agent and display results kubectl datadog agent check # Upgrade the Node Agent image tag kubectl datadog agent upgrade --image-tag 7.52.0 # Get the current Cluster Agent leader kubectl datadog clusteragent leader # Validate an Autodiscovery configuration file kubectl datadog validate ad # Convert Helm chart values to DatadogAgent CRD kubectl datadog helm2dda -f helm-values.yaml # Collect a flare and send it to Datadog support kubectl datadog flare # Inspect autoscaling recommendations kubectl datadog autoscaling ``` -------------------------------- ### List Available Make Commands Source: https://github.com/datadog/datadog-operator/blob/main/docs/how-to-contribute.md Run this command to see all available make targets for building, testing, and deploying the operator. ```shell make help ``` -------------------------------- ### Install cert-manager with CRDs enabled Source: https://github.com/datadog/datadog-operator/blob/main/docs/v2alpha1_migration.md Ensure cert-manager is installed with CRDs enabled before proceeding with the Datadog Operator migration. ```shell helm install \ cert-manager jetstack/cert-manager \ --version v1.11.0 \ --set installCRDs=true ``` -------------------------------- ### Install CRDs into the cluster Source: https://context7.com/datadog/datadog-operator/llms.txt Installs the Custom Resource Definitions (CRDs) required for the Datadog Operator to function within your Kubernetes cluster. ```bash make install ``` -------------------------------- ### Run Bundle with Operator SDK Source: https://github.com/datadog/datadog-operator/blob/main/RELEASING.md Test a locally generated bundle by running it with the Operator SDK. Replace `` with your bundle's image name. ```bash # When using a local image # kind load docker-image ./bin/operator-sdk olm install # If not already installed in your cluster. ./bin/operator-sdk run bundle docker.io/datadog/operator-bundle:0.7.1 ``` -------------------------------- ### Install Datadog Operator with Dashboard Enabled (Helm) Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_dashboard.md Install the Datadog Operator using Helm, enabling the DatadogDashboard controller and providing your Datadog API and application keys. ```shell helm install my-datadog-operator datadog/datadog-operator --set apiKey= --set appKey= --set datadogDashboard.enabled=true ``` -------------------------------- ### Create HTTP Check Configuration File Source: https://github.com/datadog/datadog-operator/blob/main/docs/integrations_autodiscovery.md Create the `http_check.yaml` file containing the configuration for the HTTP Check integration. ```yaml init_config: instances: - url: "http://%%host%%" name: "My service" ``` -------------------------------- ### Create hello.yaml for custom check Source: https://github.com/datadog/datadog-operator/blob/main/docs/custom_check.md Define the configuration for a custom check. This YAML file specifies initialization settings and instances. ```yaml init_config: instances: [{}] ``` -------------------------------- ### Generate Release Candidate Bundle Source: https://github.com/datadog/datadog-operator/blob/main/RELEASING.md Run this command locally to generate a release candidate bundle. Replace `x.v.z-rc.w` with the desired version. ```bash make VERSION=x.v.z-rc.w bundle ``` -------------------------------- ### Install Datadog Operator with Custom Image using Helm Source: https://github.com/datadog/datadog-operator/blob/main/docs/installation.md Install the Datadog Operator using Helm charts, specifying a custom container image repository and tag. This allows you to deploy a specific version or a custom-built image of the operator. ```shell helm install my-datadog-operator --set image.repository= --set image.tag= datadog/datadog-operator ``` -------------------------------- ### Deploy Datadog Agent Minimum Configuration Source: https://github.com/datadog/datadog-operator/blob/main/docs/how-to-contribute.md This script sets up necessary environment variables, creates Kubernetes secrets for API and App keys, and applies the minimum DatadogAgent resource configuration. Ensure you replace placeholders like '' with actual values. ```bash #!/bin/bash export KUBE_NAMESPACE=system export DD_API_KEY= export DD_APP_KEY= export DD_TOKEN=<32-chars-token> kubectl -n $KUBE_NAMESPACE create secret generic datadog-secret --from-literal api-key=$DD_API_KEY --from-literal app-key=$DD_APP_KEY kubectl -n $KUBE_NAMESPACE create secret generic datadog-token --from-literal token=$DD_TOKEN kubectl -n $KUBE_NAMESPACE apply -f examples/datadogagent/datadog-agent-minimum.yaml ``` -------------------------------- ### Set Namespace Source: https://github.com/datadog/datadog-operator/blob/main/docs/how-to-contribute.md Switch the current Kubernetes namespace context to 'system'. ```console kubens system ``` -------------------------------- ### Build the kubectl plugin Source: https://context7.com/datadog/datadog-operator/llms.txt Builds the kubectl plugin for interacting with Datadog resources. ```bash make build-kubectl-plugin ``` -------------------------------- ### Apply and Get DatadogAgent Status Source: https://context7.com/datadog/datadog-operator/llms.txt Applies the DatadogAgent manifest and retrieves its status. Useful for verifying deployment. ```shell kubectl apply -f datadog-agent.yaml kubectl get datadogagents datadog # NAME AGENT CLUSTER-AGENT CLUSTER-CHECKS-RUNNER AGE # datadog Deployment available Available 2m ``` -------------------------------- ### Register New Component in Controller Source: https://github.com/datadog/datadog-operator/blob/main/docs/component_registry_dev/QUICK_START.md Add the registration of your new component to the `initializeComponentRegistry` function in `controller.go`. ```go func (r *Reconciler) initializeComponentRegistry() { r.componentRegistry = NewComponentRegistry(r) r.componentRegistry.Register(NewClusterAgentComponent(r)) r.componentRegistry.Register(NewClusterChecksRunnerComponent(r)) r.componentRegistry.Register(NewMyServiceComponent(r)) // <-- Add this } ``` -------------------------------- ### Datadog kubectl Plugin Help Source: https://github.com/datadog/datadog-operator/blob/main/docs/kubectl-plugin.md Display the main help message for the Datadog kubectl plugin, listing all available top-level commands. ```console $ kubectl datadog --help Usage: datadog [command] Available Commands: agent autoscaling Manage autoscaling features clusteragent completion Generate the autocompletion script for the specified shell flare Collect a Datadog's Operator flare and send it to Datadog get Get DatadogAgent deployment(s) helm2dda Map Datadog Helm values to DatadogAgent CRD schema help Help about any command metrics validate ``` -------------------------------- ### Configure Datadog Agent with Custom Registry Source: https://github.com/datadog/datadog-operator/blob/main/docs/getting_started.md Example DatadogAgent configuration to specify a custom container registry. This overrides the default registry. ```yaml apiVersion: datadoghq.com/v2alpha1 kind: DatadogAgent metadata: name: datadog spec: global: registry: public.ecr.aws/datadog # ... ``` -------------------------------- ### DatadogMonitor Resource Source: https://context7.com/datadog/datadog-operator/llms.txt Defines a Datadog monitor using the DatadogMonitor custom resource. This example creates a monitor for Kubernetes deployment replica issues. ```APIDOC ## DatadogMonitor ### Description Manages Datadog monitors through a Kubernetes custom resource. ### Kind DatadogMonitor ### API Version datadoghq.com/v1alpha1 ### Example Usage ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogMonitor metadata: name: deployment-replicas-monitor namespace: datadog spec: name: "[kubernetes] Deployment Replica Pods Down" type: "query alert" query: > avg(last_15m):avg:kubernetes_state.deployment.replicas_desired{*} by {kube_deployment} - avg:kubernetes_state.deployment.replicas_available{*} by {kube_deployment} >= 2 message: "More than one Deployment replica pod is unavailable. @pagerduty-oncall" tags: - "integration:kubernetes" - "env:prod" options: evaluationDelay: 300 includeTags: true newGroupDelay: 60 notificationPresetName: show_all thresholds: critical: "2" warning: "1" priority: 2 ``` ### Get Datadog Monitors ```shell kubectl get datadogmonitors -n datadog ``` ### Output Example ``` # NAME ID SYNC AGE # deployment-replicas-monitor 123456789 OK 1m ``` ``` -------------------------------- ### Create hello.py for custom check Source: https://github.com/datadog/datadog-operator/blob/main/docs/custom_check.md Implement a custom Datadog Agent check. This Python script defines a check that reports a 'hello.world' gauge metric. ```python from datadog_checks.base import AgentCheck __version__ = "1.0.0" class HelloCheck(AgentCheck): def check(self, instance): self.gauge('hello.world', 1, tags=['env:dev']) ``` -------------------------------- ### Clone Datadog Operator Repository Source: https://github.com/datadog/datadog-operator/blob/main/marketplaces/charts/google-marketplace/README.md Clone the Datadog Operator repository to your local machine to access the necessary deployment files. This is a prerequisite for the command-line installation. ```shell git clone git@github.com:DataDog/datadog-operator.git ``` -------------------------------- ### Create GKE Cluster with gcloud Source: https://github.com/datadog/datadog-operator/blob/main/marketplaces/charts/google-marketplace/README.md Use this command to create a new Google Kubernetes Engine cluster. Ensure you have the gcloud CLI installed and configured. ```shell export CLUSTER=datadog-cluster export ZONE=us-west1-a gcloud container clusters create "$CLUSTER" --zone "$ZONE" ``` -------------------------------- ### Datadog Operator Test Command Source: https://github.com/datadog/datadog-operator/blob/main/AGENTS.md The `make test` command runs a comprehensive suite including builds, formatting, licenses, and all tests. For faster iteration, use `go test ./...` or `make ci-test`. ```bash make test # Build + formats + licenses + all tests. Use `go test ./...` or `make ci-test` for quick iteration ``` -------------------------------- ### Generate Final Release Bundle Source: https://github.com/datadog/datadog-operator/blob/main/RELEASING.md Run this command locally to generate the final release bundle. Replace `x.v.z` with the desired final version. ```bash make VERSION=x.v.z bundle ``` -------------------------------- ### Enable Introspection via Helm Command Line Source: https://github.com/datadog/datadog-operator/blob/main/docs/introspection.md Alternatively, enable introspection by passing the `--set introspection.enabled=true` flag during helm installation or upgrade. ```bash --set introspection.enabled=true ``` -------------------------------- ### Datadog Agent Sub-commands Help Source: https://github.com/datadog/datadog-operator/blob/main/docs/kubectl-plugin.md Display the help message for the `agent` sub-command, listing available actions related to Datadog Agent management. ```console $ kubectl datadog agent --help Usage: datadog agent [command] Available Commands: check Find check errors find Find datadog agent pod monitoring a given pod upgrade Upgrade the Datadog Agent version ``` -------------------------------- ### Implement Component Methods in Go Source: https://github.com/datadog/datadog-operator/blob/main/docs/component_registry_dev/QUICK_START.md Implement the required methods for your new component. Ensure you define the component name and condition type in the appropriate API and common files. ```go type MyServiceComponent struct { reconciler *Reconciler } func NewMyServiceComponent(reconciler *Reconciler) *MyServiceComponent { return &MyServiceComponent{reconciler: reconciler} } func (c *MyServiceComponent) Name() datadoghqv2alpha1.ComponentName { return datadoghqv2alpha1.MyServiceComponentName // Define in API types } func (c *MyServiceComponent) IsEnabled(requiredComponents feature.RequiredComponents) bool { return requiredComponents.MyService.IsEnabled() // Add to RequiredComponents } func (c *MyServiceComponent) GetConditionType() string { return common.MyServiceReconcileConditionType // Define in common/const.go } func (c *MyServiceComponent) Reconcile(ctx context.Context, params *ReconcileComponentParams) (reconcile.Result, error) { // Your reconciliation logic here } func (c *MyServiceComponent) Cleanup(ctx context.Context, params *ReconcileComponentParams) (reconcile.Result, error) { // Your cleanup logic here } ``` -------------------------------- ### Populate ConfigMap with multiple check configurations Source: https://github.com/datadog/datadog-operator/blob/main/docs/custom_check.md Create a ConfigMap containing multiple custom check YAML configuration files by finding all .yaml files in the conf.d directory. ```bash $ kubectl create cm -n $DD_NAMESPACE confd-config $(find ./conf.d -name "*.yaml" | xargs -I'{}' echo -n '--from-file={} ') configmap/confd-config created ``` -------------------------------- ### DatadogAgent vs DatadogAgentInternal Architecture Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_agent_internal.md Illustrates the architectural shift from direct DatadogAgent to DatadogAgentInternal management of Kubernetes workloads starting from Operator version v1.16.0. ```text DatadogAgent → DaemonSets / Deployments ``` ```text DatadogAgent → DatadogAgentInternal(s) → DaemonSets / Deployments ``` -------------------------------- ### Implement Provider-Specific Logic Source: https://github.com/datadog/datadog-operator/blob/main/docs/component_registry_dev/COMPONENT_REGISTRY.md Conditionally add labels to a deployment based on introspection settings and the current provider. Ensure the labels map is initialized if it's nil. ```go if c.reconciler.options.IntrospectionEnabled { if deployment.Labels == nil { deployment.Labels = make(map[string]string) } deployment.Labels[constants.MD5AgentDeploymentProviderLabelKey] = params.Provider } ``` -------------------------------- ### Enable DatadogAgentProfiles via Helm Chart Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_agent_profiles.md Configure the Datadog Operator Helm chart to enable DatadogAgentProfiles. This involves enabling the controller and installing the necessary CRDs. ```yaml datadogAgentProfile.enabled=true datadogCRDs.crds.datadogAgentProfiles=true ``` -------------------------------- ### Create ConfigMap for custom check Python script Source: https://github.com/datadog/datadog-operator/blob/main/docs/custom_check.md Create a Kubernetes ConfigMap to store the custom check's Python script file. ```bash $ kubectl create configmap -n $DD_NAMESPACE checksd-config --from-file=hello.py configmap/checksd-config created ``` -------------------------------- ### Create a metric-based DatadogSLO resource Source: https://context7.com/datadog/datadog-operator/llms.txt Define a metric-based Service Level Objective (SLO) using the DatadogSLO custom resource. This example tracks API availability. ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogSLO metadata: name: api-availability-slo namespace: datadog spec: name: "API Availability SLO" description: "99.9% of requests succeed in production" type: metric query: numerator: "sum:requests.success{service:api,env:prod}.as_count()" denominator: "sum:requests.total{service:api,env:prod}.as_count()" targetThreshold: "99.9" warningThreshold: "99.95" timeframe: "7d" tags: - "service:api" - "env:prod" ``` -------------------------------- ### DatadogSLO Custom Resource Definition Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_slo.md Define a Datadog SLO using the DatadogSLO custom resource. This example configures a metric-based SLO with specific thresholds and tags. ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogSLO metadata: name: example-slo namespace: system spec: name: example-slo description: "This is an example metric SLO from datadog-operator" query: denominator: "sum:requests.total{service:example,env:prod}.as_count()" numerator: "sum:requests.success{service:example,env:prod}.as_count()" tags: - "service:example" - "env:prod" targetThreshold: "99.9" timeframe: "7d" type: "metric" ``` -------------------------------- ### Deploy DatadogDashboard Resource Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_dashboard.md Apply the DatadogDashboard configuration file to your Kubernetes cluster using kubectl. ```shell kubectl apply -f /path/to/your/datadog-dashboard.yaml ``` -------------------------------- ### Create a monitor-based DatadogSLO resource Source: https://context7.com/datadog/datadog-operator/llms.txt Define a monitor-based Service Level Objective (SLO) using the DatadogSLO custom resource. This example uses existing monitor IDs. ```yaml apiVersion: datadoghq.com/v1alpha1 kind: DatadogSLO metadata: name: api-uptime-slo spec: name: "API Uptime SLO" type: monitor monitorIDs: - 123456 # Datadog monitor ID(s) defining the SLI targetThreshold: "99.9" timeframe: "30d" tags: - "service:api" ``` -------------------------------- ### Deploy DatadogMonitor with kubectl Source: https://github.com/datadog/datadog-operator/blob/main/docs/datadog_monitor.md Apply the DatadogMonitor configuration file using kubectl to create a new monitor in Datadog. Monitors are tagged with 'generated:kubernetes'. ```shell kubectl apply -f /path/to/your/datadog-monitor.yaml ```