Skip to content

Kubernetes Connector

The Kubernetes connector provides deep visibility into your clusters with 11 live tools and comprehensive ETL ingestion of workloads, networking, and configuration into the knowledge graph.

Authentication

The Kubernetes connector supports two authentication modes: an external kubeconfig file or in-cluster service account credentials.

Kubeconfig File

Provide the path to a kubeconfig file or the raw kubeconfig content:

json
{
  "name": "Production Cluster",
  "source_type": "kubernetes",
  "config": {
    "kubeconfig": "/path/to/kubeconfig",
    "context": "prod-cluster"
  }
}

Or provide the kubeconfig content inline:

json
{
  "name": "Production Cluster",
  "source_type": "kubernetes",
  "config": {
    "kubeconfig_data": "apiVersion: v1\nclusters:\n- cluster:\n    server: https://k8s.example.com:6443\n    certificate-authority-data: LS0t...\n  name: prod\n...",
    "context": "prod"
  }
}
VariableRequiredDescription
kubeconfig / KUBECONFIGYes (or in-cluster)Path to the kubeconfig file
kubeconfig_dataNoRaw kubeconfig YAML content (alternative to file path)
contextNoKubeconfig context to use (defaults to current context)

In-Cluster Authentication

When Agentcy is deployed inside a Kubernetes cluster, it can use the pod's service account token automatically:

json
{
  "name": "Self Cluster",
  "source_type": "kubernetes",
  "config": {
    "in_cluster": true
  }
}

TIP

Create a dedicated ClusterRole and ClusterRoleBinding for the Agentcy service account. See RBAC Configuration below.

Live Tools (11)

ToolDescriptionArguments
k8s_list_podsList pods with status, restarts, and resource usagenamespace?, label_selector?
k8s_get_podGet detailed pod info including containers, events, and volumesname, namespace
k8s_get_pod_logsRetrieve container logs from a podname, namespace, container?, tail_lines?, since?
k8s_list_deploymentsList deployments with replica counts and rollout statusnamespace?, label_selector?
k8s_get_deploymentGet detailed deployment info including strategy and conditionsname, namespace
k8s_get_deployment_statusGet the rollout status of a deploymentname, namespace
k8s_list_servicesList services with type, cluster IP, and external endpointsnamespace?
k8s_list_namespacesList all namespaces with status and labels--
k8s_list_nodesList cluster nodes with capacity, allocatable resources, and conditions--
k8s_list_configmapsList ConfigMaps in a namespacenamespace?, label_selector?
k8s_list_eventsList events in a namespacenamespace?, field_selector?

Example: Agent Using Kubernetes Tools

User: "Are any pods crashing in the production namespace?"

Agent: Let me check the pods in production.
→ Calls k8s_list_pods(namespace: "production")
→ Finds 2 pods with CrashLoopBackOff status
→ Calls k8s_get_pod_logs(name: "api-server-7f8b9c-x4k2p", namespace: "production", tail_lines: 50)
→ Reports: "The api-server pod is crash-looping due to a database connection timeout.
  Last error: 'Failed to connect to postgres:5432 — connection refused'"
User: "What's the rollout status of the api-server deployment?"

Agent: I'll check the deployment status.
→ Calls k8s_get_deployment_status(name: "api-server", namespace: "production")
→ Reports: "Deployment api-server: 3/3 replicas ready, rollout complete."

ETL Ingestion

When you trigger a sync, the Kubernetes connector ingests the following resources into the knowledge graph.

Nodes Created

Node LabelPropertiesK8s Resource
Podname, namespace, status, phase, node_name, restart_count, ip, start_time, imagePod
Deploymentname, namespace, replicas, ready_replicas, strategy, selector, imageDeployment
Servicename, namespace, type, cluster_ip, external_ip, ports, selectorService
Namespacename, status, labels, annotationsNamespace
Nodename, status, roles, capacity_cpu, capacity_memory, os_image, kubelet_versionNode
ConfigMapname, namespace, data_keysConfigMap
Eventname, namespace, type, reason, message, involved_object, last_timestampEvent
Ingressname, namespace, hosts, paths, tls_enabled, ingress_classIngress

Relationships Created

RelationshipFromTo
RUNS_INPodNamespace
SCHEDULED_ONPodNode
MANAGED_BYPodDeployment
EXPOSESServicePod
ROUTES_TOIngressService
MOUNTSPodConfigMap
CONTAINSNamespaceDeployment, Service

Graph Queries

cypher
-- Find all pods on a specific node with their deployments
MATCH (p:Pod)-[:SCHEDULED_ON]->(n:Node),
      (p)-[:MANAGED_BY]->(d:Deployment)
WHERE n.name = "node-01"
RETURN d.name, p.name, p.status, p.restart_count

-- Find the full request path: Ingress → Service → Pod → Node
MATCH (i:Ingress)-[:ROUTES_TO]->(s:Service)-[:EXPOSES]->(p:Pod)-[:SCHEDULED_ON]->(n:Node)
WHERE i.hosts CONTAINS "api.example.com"
RETURN i.name, s.name, p.name, n.name, p.status

-- Find pods mounting a specific ConfigMap
MATCH (p:Pod)-[:MOUNTS]->(cm:ConfigMap)
WHERE cm.name = "app-config"
RETURN p.name, p.namespace, p.status

-- Cross-namespace service dependencies
MATCH (s1:Service)-[:EXPOSES]->(p1:Pod)-[:RUNS_IN]->(ns1:Namespace),
      (s2:Service)-[:EXPOSES]->(p2:Pod)-[:RUNS_IN]->(ns2:Namespace)
WHERE ns1 <> ns2
RETURN ns1.name, s1.name, ns2.name, s2.name

RBAC Configuration

Create a read-only ClusterRole for the Agentcy connector:

yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: agentcy-reader
rules:
  - apiGroups: [""]
    resources:
      - pods
      - pods/log
      - services
      - namespaces
      - nodes
      - configmaps
      - events
    verbs: ["get", "list", "watch"]
  - apiGroups: ["apps"]
    resources:
      - deployments
    verbs: ["get", "list", "watch"]
  - apiGroups: ["networking.k8s.io"]
    resources:
      - ingresses
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: agentcy-reader-binding
subjects:
  - kind: ServiceAccount
    name: agentcy
    namespace: agentcy
roleRef:
  kind: ClusterRole
  name: agentcy-reader
  apiGroup: rbac.authorization.k8s.io

Configuration Reference

json
{
  "name": "Production Cluster",
  "source_type": "kubernetes",
  "config": {
    "kubeconfig": "/path/to/kubeconfig",
    "context": "prod-cluster",
    "namespaces": ["production", "staging"],
    "exclude_namespaces": ["kube-system", "kube-public"],
    "sync_pods": true,
    "sync_deployments": true,
    "sync_services": true,
    "sync_configmaps": true,
    "sync_events": true,
    "sync_nodes": true,
    "sync_ingresses": true,
    "label_selector": "app.kubernetes.io/managed-by=helm"
  }
}
FieldTypeDefaultDescription
kubeconfigstring~/.kube/configPath to kubeconfig file
kubeconfig_datastring--Raw kubeconfig YAML content
contextstringcurrent contextKubeconfig context to use
in_clusterboolfalseUse in-cluster service account auth
namespacesstring[]allOnly ingest these namespaces
exclude_namespacesstring[][]Skip these namespaces during ingestion
sync_podsbooltrueInclude pods in ingestion
sync_deploymentsbooltrueInclude deployments in ingestion
sync_servicesbooltrueInclude services in ingestion
sync_configmapsbooltrueInclude ConfigMaps in ingestion
sync_eventsbooltrueInclude events in ingestion
sync_nodesbooltrueInclude cluster nodes
sync_ingressesbooltrueInclude Ingress resources
label_selectorstring--Only ingest resources matching this label selector

Troubleshooting

ErrorCauseFix
401 UnauthorizedKubeconfig token expired or service account missingRefresh kubeconfig or verify service account token
403 ForbiddenRBAC role lacks required permissionsUpdate the ClusterRole with missing resources/verbs
Connection refusedAPI server unreachable from AgentcyCheck network connectivity and firewall rules
No such contextSpecified context not found in kubeconfigRun kubectl config get-contexts to list available contexts
TimeoutAPI server is slow or cluster is overloadedIncrease timeout or reduce the number of namespaces to sync

Verifying Access

Test your credentials from the command line:

bash
# Verify cluster access
kubectl cluster-info --context prod-cluster

# Test pod listing
kubectl get pods --all-namespaces --context prod-cluster

# Check RBAC permissions
kubectl auth can-i list pods --all-namespaces \
  --as=system:serviceaccount:agentcy:agentcy

Built by AgentcyLabs. For in-house deployment or Agentcy Cloud (PaaS) access, visit agentcylabs.com.