Loading...
Loading...
Install the Datadog Agent on Kubernetes using the Datadog Operator — required before enabling Single Step Instrumentation (SSI), which automatically instruments applications for APM without code changes. Only use if no Datadog Agent is deployed on the cluster yet.
npx skill4agent add datadog-labs/agent-skills agent-installBefore doing anything else: Fully resolve all variables in. Do not begin Step 1 until every variable has a concrete value.## Context to resolve before acting
[ -f environment ] && source environment
echo "DD_API_KEY set: $([ -n "${DD_API_KEY:-}" ] && echo yes || echo no)"
echo "DD_SITE: ${DD_SITE:-not set}"
echo "helm: $(helm version --short 2>/dev/null || echo NOT FOUND)"helmis required for this skill. Install it with:helmbashbrew install helm # macOS # or see https://helm.sh/docs/intro/install/ for other platformsOnce installed, let me know and I'll continue.
helmDD_API_KEYDD_API_KEYI need two things to continue:1. Datadog API Key — used to authenticate the Agent with your Datadog account. You can find or create one at: https://app.datadoghq.com/organization-settings/api-keys2. Datadog Site — the region your Datadog account is on. Most accounts use. Check your Datadog URL to confirm (e.g.datadoghq.com→ site isapp.datadoghq.eu). Other options:datadoghq.eu,us3.datadoghq.com,us5.datadoghq.com.ap1.datadoghq.comPlease run the following in this chat to set your credentials (theprefix executes it in this session):!! export DD_API_KEY=your-api-key-here ! export DD_SITE=datadoghq.com
kubectl versionhelm versionkubectl config current-contextpup --versionif [[ "$(uname)" == "Darwin" ]]; then
brew tap datadog-labs/pack && brew install pup
else
PUP_VERSION=$(curl -s https://api.github.com/repos/datadog-labs/pup/releases/latest | grep '"tag_name"' | cut -d'"' -f4)
curl -L "https://github.com/datadog-labs/pup/releases/download/${PUP_VERSION}/pup_linux_amd64.tar.gz" | tar xz -C /usr/local/bin pup
chmod +x /usr/local/bin/pup
fi
pup --versionpup --version| Variable | How to resolve |
|---|---|
| Check repo IaC, scripts, or |
| Ask the user. Default: |
| Use |
| Run |
helm list -A | grep -i datadogdeployedhelm repo add datadog https://helm.datadoghq.com
helm repo update
helm upgrade --install datadog-operator datadog/datadog-operator \
--namespace <AGENT_NAMESPACE> \
--create-namespace \
--version <CHART_VERSION>
kubectl wait --for=condition=Ready pod \
-l app.kubernetes.io/name=datadog-operator \
-n <AGENT_NAMESPACE> \
--timeout=120skubectl describe pod -l app.kubernetes.io/name=datadog-operator -n <AGENT_NAMESPACE>export DD_API_KEY=<your-api-key>
kubectl create secret generic datadog-secret \
--from-literal api-key=$DD_API_KEY \
--namespace <AGENT_NAMESPACE>secret/datadog-secret createdAlreadyExistskubelet.tlsVerify: falsespec.globalkubelet.tlsVerifyDatadogAgentfeatures.apmenable-ssidatadog-agent.yamlapiVersion: datadoghq.com/v2alpha1
kind: DatadogAgent
metadata:
name: datadog
namespace: <AGENT_NAMESPACE>
spec:
global:
clusterName: <CLUSTER_NAME>
site: <DD_SITE>
credentials:
apiSecret:
secretName: datadog-secret
keyName: api-key
# Self-hosted clusters only (minikube, kind):
# kubelet:
# tlsVerify: false
features:
orchestratorExplorer:
enabled: true
clusterChecks:
enabled: true
logCollection:
enabled: true
containerCollectAll: falsekubectl apply -f datadog-agent.yaml
kubectl wait --for=condition=Ready pod \
-l app.kubernetes.io/component=agent \
-n <AGENT_NAMESPACE> \
--timeout=120s 2>/dev/null || truekubectl logs -l app.kubernetes.io/component=agent \
-n <AGENT_NAMESPACE> \
--tail=50 2>/dev/null \
| grep -iE "invalid.*api\.?key|api\.?key.*invalid" \
|| echo "No authentication errors found"No authentication errors found# Prefer pup (OAuth) — fall back to curl with API key
if pup auth status 2>/dev/null | grep -q "Logged in"; then
echo "pup OAuth authenticated"
elif [ -n "${DD_API_KEY:-}" ]; then
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" \
-X GET "https://api.<DD_SITE>/api/v1/validate" \
-H "DD-API-KEY: $DD_API_KEY")
if [ "$RESPONSE" = "200" ]; then
echo "API key is valid for <DD_SITE>"
else
echo "ERROR: Validation failed (HTTP $RESPONSE) — check key and site alignment"
fi
else
echo "ERROR: No credentials available — run 'pup auth login' or set DD_API_KEY"
fiexport DD_API_KEY=<new-api-key>
kubectl delete secret datadog-secret -n <AGENT_NAMESPACE>
kubectl create secret generic datadog-secret \
--from-literal api-key=$DD_API_KEY \
-n <AGENT_NAMESPACE>
kubectl rollout restart daemonset datadog-agent -n <AGENT_NAMESPACE>
kubectl rollout restart deployment datadog-cluster-agent -n <AGENT_NAMESPACE>AGENT_NAMESPACEdatadog-secretAGENT_NAMESPACEenable-ssi$DD_API_KEYkubectl create secretapiKey:DatadogAgentapiSecret:--set datadog.apiKey=...defaultkubectl delete