> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sureops.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes

> Connect Kubernetes for pod inspection, cluster events, and deployment state during incidents

The Kubernetes integration gives sureops agents access to your cluster's API for pod and deployment inspection, log retrieval, event queries, and (with approval) remediation actions such as pod restarts and scaling operations.

***

## What this integration enables

* **Pod inspection** — agents read pod status, restart counts, resource utilization, and readiness state for affected services
* **Deployment state** — agents check current replica counts, rollout status, and recent rollout history
* **Cluster events** — agents query Kubernetes events correlated with incident timing to surface scheduling failures, OOM kills, and node pressure
* **Container logs** — agents retrieve container logs from affected pods for the incident time window
* **Remediation actions** — with explicit HITL approval, the resolution specialist can restart deployments, adjust replica counts, or patch a workload's spec. These are gated by Human-in-the-Loop by default, and a remediation classified high-risk — or one whose risk sureops can't classify — **always** pauses for a human, regardless of control mode or auto-approve settings. Five carve-outs always require explicit approval and none can be turned off: P1/P2-severity incidents, recommendations that open a fix PR, high-risk or unclassifiable actions, diagnoses rebuilt from incomplete evidence, and diagnoses started from the stage card while someone holds control. A lower-risk remediation on a P3/P4 incident can be auto-approved like any other recommendation if your org has opted in. See [HITL Gates](https://docs.sureops.ai/operating-modes/hitl-gates.md) for the full rule set.

***

## Prerequisites

* An environment selected in the top-right context switcher — **Settings → Environment → Integrations** is scoped to that environment and stays disabled until one is selected
* A Kubernetes cluster
* The `k8s-mcp` server running inside your cluster or accessible from sureops with an appropriate kubeconfig or service account token

> [!NOTE]
>
> Integration connections are per-environment. Connecting Kubernetes here only applies to the environment that was selected in the context switcher at the time — it does not carry over to your other environments. Repeat this connect flow for each environment that needs Kubernetes.

***

## Setup

**1. Stand up k8s-mcp**

Deploy `k8s-mcp` inside your cluster (recommended) or on infrastructure with access to your cluster's API server. If you're using the sureops demo environment, `k8s-mcp` is already provisioned in-cluster — you can skip this step.

For your own cluster, sureops runs [`kubernetes-mcp-server`](https://github.com/containers/kubernetes-mcp-server) — deploy it as a Kubernetes Deployment with a scoped ServiceAccount bound to a Role (see [Scoping k8s-mcp permissions](#scoping-k8s-mcp-permissions) below), and expose it inside your cluster or wherever sureops can reach it. The service account needs read access to pods, deployments, events, and logs, plus `update`/`patch` on Deployments/ReplicaSets/StatefulSets/DaemonSets, and the `scale` subresource specifically for Deployments and StatefulSets, for remediation — never `delete` on pods or `exec`.

**2. Connect in sureops**

In sureops, go to **Settings → Environment → Integrations** and click **Connect** next to Kubernetes.

Fill in:

* **Integration Name** — prefilled; change it if you need to tell two configurations of this integration apart
* **MCP Server Endpoint** — the URL of your running `k8s-mcp` server (e.g. `https://k8s-mcp.internal.company.com/mcp`)
* **Bearer Token** — the token your `k8s-mcp` endpoint (or the proxy in front of it) expects. sureops always sends this to `k8s-mcp` as an `Authorization: Bearer` header, so there is no authentication method to choose. The form won't save a blank token, so if nothing in front of `k8s-mcp` checks a token, put it behind an ingress or proxy that does.

Click **Save & Connect**.

***

## Required credentials

| Field | Required | Description |
| - | - | - |
| Integration Name | No | Prefilled with a default name; distinguishes two configurations of the same integration in one environment |
| MCP Server Endpoint | Yes | URL of your running `k8s-mcp` server |
| Bearer Token | Yes | Token your `k8s-mcp` endpoint (or the proxy in front of it) expects. Required; sent to `k8s-mcp` as an `Authorization: Bearer` header |

***

## Scoping k8s-mcp permissions

The level of access you grant `k8s-mcp` determines what sureops agents can do. Every real remediation mutates a pod spec through its **owning controller** (Deployment, StatefulSet, etc.) — never a pod directly:

| API group / resource | Verbs | Required for |
| - | - | - |
| `""` — `pods`, `pods/log`, `services`, `endpoints`, `events` | `get`, `list`, `watch` | Pod inspection, log retrieval, event queries (diagnosis) |
| `apps` — `deployments`, `replicasets`, `statefulsets`, `daemonsets` | `get`, `list`, `watch` | Deployment/rollout state, rollout history (diagnosis) |
| `batch` — `jobs`, `cronjobs` | `get`, `list`, `watch` | Job/CronJob state (diagnosis) |
| `""` — `persistentvolumeclaims` | `get`, `list`, `watch` | PVC status inspection (diagnosis) |
| `metrics.k8s.io` — `pods` | `get`, `list` | Pod CPU/memory utilization (diagnosis) |
| `apps` — `deployments`, `replicasets`, `statefulsets`, `daemonsets` | `update`, `patch` | Remediation — bump resource limits, roll out a config change, patch a controller's pod template (resolution) |
| `batch` — `jobs`, `cronjobs` | `update`, `patch` | Remediation — patch a Job or CronJob spec (resolution) |
| `apps` — `deployments/scale`, `statefulsets/scale` | `update`, `patch` | Scaling actions (resolution) |
| `""` — `services` | `update`, `patch` | Service spec patches (resolution) |

Grant only the permissions you want sureops to have. The read-only rows (the first five) are sufficient for diagnosis-only use; resolution actions need the `update`/`patch` rows as well. Also grant read access (`get`/`list`/`watch` on `configmaps`) to any ConfigMaps your services need for diagnosis — scope this to the specific names your workloads use rather than a blanket grant.

**sureops never needs `create`/`delete` on a workload resource, or `pods/exec`.** Its remediation model works entirely by patching an existing controller's spec, so those verbs are never required, and the Role sureops provisions for a sureops-supplied demo cluster deliberately excludes them — by design, not oversight.

> [!WARNING]
>
> That's a statement about what sureops *needs* and what *we* grant — not a guarantee enforced on your cluster. The upstream k8s-mcp image still exposes delete and exec tools, and sureops auto-enables write tools that your Role actually makes reachable. So if you bind a broad or cluster-admin ServiceAccount, those destructive tools become available. **Scope the Role yourself to the verbs in the table above** — don't rely on sureops to refuse permissions you granted it.

***

## Common errors

| Error | Fix |
| - | - |
| "401 Unauthorized" | The MCP connection token is incorrect or expired. Regenerate it and update both the `k8s-mcp` config and sureops. |
| "403 Forbidden" | The `k8s-mcp` service account lacks permission to access the requested resource. Review the service account's RBAC bindings and add the missing permission. |
| "Connection timed out" | Your `k8s-mcp` server is not reachable from sureops. If it's running in-cluster, check the service exposure configuration. |
| "Namespace not found" | The agent referenced a namespace that doesn't exist. Check that the namespace matches the service names and labels in your landscape. |

***

## Official documentation

* [Kubernetes RBAC documentation](https://kubernetes.io/docs/reference/access-authn-authz/rbac/)
* [kubernetes-mcp-server on GitHub](https://github.com/containers/kubernetes-mcp-server)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.