2026-09-01 21:32:59 +00:00
2026-09-01 21:32:59 +00:00

kagent DevOps Remediator Function

OCI Function bridge used by OCI DevOps to ask kagent for post-deployment diagnosis, business degradation analysis, pod troubleshooting, or remediation recommendations.

Network prerequisite

The function cannot resolve Kubernetes svc.cluster.local names. Expose the kagent controller through a private LoadBalancer:

kubectl apply -f k8s/kagent/kagent-controller-private-lb.yaml
kubectl get svc kagent-controller-private-lb -n kagent

Set KAGENT_MCP_URL to:

http://<private-kagent-lb-ip>:8083/mcp

The Function must run in a subnet that can reach that private LB.

Function config

Required config:

KAGENT_MCP_URL=http://<private-kagent-lb-ip>:8083/mcp
KAGENT_AGENT_NAME=k8s-agent
KAGENT_AGENT_NAMESPACE=kagent
APP_NAMESPACE=kagent-demo
ORDER_OBSERVABILITY_URL=http://<order-lb-ip>/api/observability
OCI_REGION=mx-monterrey-1
NOTIFICATION_TOPIC_OCID=<oci-notifications-topic-ocid>
DEVOPS_APPROVAL_URL=https://cloud.oracle.com/devops/projects/<project-ocid>/deploy-pipelines/<remediation-pipeline-ocid>?region=mx-monterrey-1

NOTIFICATION_TOPIC_OCID is optional. If it is configured, the Function publishes an OCI Notifications message only when kagent reports an active failure or degradation. Healthy results do not send email.

DEVOPS_APPROVAL_URL is optional but recommended for the demo. Use a stable remediation pipeline URL because deployment OCIDs change on every run:

DEVOPS_APPROVAL_URL=https://cloud.oracle.com/devops/projects/<project-ocid>/deploy-pipelines/<remediation-pipeline-ocid>?region=mx-monterrey-1

If you later want to include a specific deployment URL, pass it in the Function payload as devopsApprovalUrl. Payload values override the environment variable.

Default diagnosis payload

{
  "appNamespace": "kagent-demo",
  "agentNamespace": "kagent",
  "agentName": "k8s-agent",
  "observabilityUrl": "http://40.233.26.150/api/observability"
}

If no prompt is provided, the Function uses the default business-remediation prompt for the kagent-demo application.

OCI DevOps parameterized payload

For the Invoke Function stage, create a General artifact using k8s/kagent-multi-error-payload.json and enable parameter substitution.

Recommended OCI DevOps deployment pipeline parameters:

OCI_REGION=mx-monterrey-1
APP_NAMESPACE=kagent-demo
ORDER_OBSERVABILITY_URL=http://<order-lb-ip>/api/observability
NOTIFICATION_TOPIC_OCID=<oci-notifications-topic-ocid>
DEVOPS_APPROVAL_URL=https://cloud.oracle.com/devops/projects/<project-ocid>/deploy-pipelines/<default-remediation-pipeline-ocid>?region=mx-monterrey-1
BUSINESS_REMEDIATION_PIPELINE_OCID=<business-remediation-pipeline-ocid>
IMAGEPULL_REMEDIATION_PIPELINE_OCID=<imagepull-remediation-pipeline-ocid>
HPA_REMEDIATION_PIPELINE_OCID=<hpa-remediation-pipeline-ocid>
BUSINESS_REMEDIATION_PROJECT_OCID=<business-remediation-project-ocid>
IMAGEPULL_REMEDIATION_PROJECT_OCID=<imagepull-remediation-project-ocid>
HPA_REMEDIATION_PROJECT_OCID=<hpa-remediation-project-ocid>

The Function uses these payload values before falling back to func.yaml environment variables. This lets each OCI DevOps pipeline control its own topic, URLs, and remediation pipeline OCIDs.

Generic prompt payload

Use this mode when OCI DevOps needs to ask a different question.

{
  "agentNamespace": "kagent",
  "agentName": "k8s-agent",
  "responseMode": "json",
  "prompt": "Analiza el namespace kagent-demo. Identifica pods con ImagePullBackOff, causa raiz, imagen afectada y accion recomendada para OCI DevOps. Responde JSON valido con fields: status, failureType, rootCause, evidence, recommendedAction."
}

For free-form answers:

{
  "agentNamespace": "kagent",
  "agentName": "k8s-agent",
  "responseMode": "text",
  "prompt": "Resume el estado actual del namespace kagent-demo y separa eventos historicos de fallas activas."
}

For OCI DevOps automation, prompts should request this kind of structure:

{
  "status": "HEALTHY|DEGRADED|FAILED",
  "failureType": "OKE_PLATFORM_FAILURE|DEPENDENCY_FAILURE|DEPLOYMENT_FAILURE|BUSINESS_PROCESS_DEGRADATION|NO_ACTIVE_FAILURE",
  "rootCause": "",
  "evidence": [],
  "recommendedAction": "CONTINUE|APPROVAL_REQUIRED|APPLY_CONFIGMAP_FIX|ROLLBACK|REDEPLOY",
  "configMapPatchRequired": false,
  "recommendedConfigMapData": {},
  "deploymentsToRestart": []
}
Description
OKE AI Remediator Demo is a cloud-native reference project that demonstrates how to connect Kubernetes platform health with real business impact using Oracle Kubernetes Engine, kagent, OCI Generative AI and OCI DevOps. The project deploys a microservices-based business application with Orders, Inventory and Payments services, plus an intelligent remediator that periodically analyzes application health, HPA behavior and ImagePull failures. When a real issue is detected, the remediator generates an AI-assisted diagnostic report with root cause, business impact, evidence and recommended action, then triggers a governed OCI DevOps remediation pipeline that requires human approval before execution. This demo shows how organizations can move beyond infrastructure-only monitoring toward business-aware operations, where AI helps teams detect incidents earlier, understand their impact faster and respond through controlled, auditable remediation workflows.
Readme 82 KiB
Languages
Python 62.7%
Java 22.3%
JavaScript 4.6%
CSS 4%
HTML 3.3%
Other 3.1%