Blog

Kubernetes Rollbacks with Confidence: Rollout History + Undo as First‑Class Tools

Shipping safe rollback primitives for deployments/daemonsets/statefulsets—and where approvals belong.

8 min read
kubernetesmcpsafety

Why Do Kubernetes Rollbacks Often Fail in Practice?

Rollbacks are one of those operations teams talk about as if they're trivial—until they need one during an incident.

In real incidents, rollbacks fail because:

  • No one remembers which revision was "good"
  • Rollout history is cluttered and confusing
  • Engineers panic and "just restart things" instead of rolling back
  • Wrong resource type (deployment vs. statefulset vs. daemonset)

Skyflo treats rollbacks as a structured workflow, not a single command.


What Is the Safe Rollback Workflow?

A safe rollback follows this sequence:

Step1
OperationInspect rollout history
Access LevelRead-only
Step2
OperationIdentify target revision
Access LevelRead-only
Step3
OperationRequest approval for rollback
Access LevelHuman decision
Step4
OperationExecute rollback
Access LevelWrite (after approval)
Step5
OperationVerify rollout status
Access LevelRead-only

The key insight: Never undo without first inspecting history. If an agent executes kubectl rollout undo without checking which revision exists, you'll eventually roll back to the wrong thing.


How Does Skyflo Expose Rollout Tools via MCP?

Skyflo provides two MCP tools that enforce the safe sequence:

`k8s_rollout_history` (read-only)

bash
kubectl rollout history deployment/api-server -n production

Returns revision list with change causes, timestamps, and annotations.

`k8s_rollout_undo` (requires approval)

bash
kubectl rollout undo deployment/api-server -n production --to-revision=3

Only executes after explicit human approval.

The agent's natural flow becomes:

  1. "Let me check the rollout history for this deployment"
  2. "I see revision 4 (current) was deployed 30 minutes ago, revision 3 was stable for 2 weeks"
  3. "I recommend rolling back to revision 3. [Approve] [Deny]"

Why Do Resource Types Matter for Rollbacks?

Rollout commands behave differently across Kubernetes resource types:

ResourceDeployment
Rollout SupportFull
NotesMost common rollback target
ResourceDaemonSet
Rollout SupportFull
NotesRolling updates across nodes
ResourceStatefulSet
Rollout SupportFull
NotesOrdered rollback with pod identity
ResourceReplicaSet
Rollout SupportNone
NotesManaged by Deployments

Skyflo's tools explicitly require resource type as a parameter rather than guessing. Guessing is how you end up rolling back a deployment when you meant a statefulset.


Why Do Approvals Belong on Undo Operations?

Rollout history is read-only and executes immediately—it gathers information.

Rollout undo changes production state. Therefore:

  • Undo requires explicit approval
  • The approval shows: namespace, resource name, target revision
  • Audit trail: Who approved, when, what revision

This gives operators a chance to verify they're rolling back:

  • The correct namespace
  • The correct resource
  • The correct revision

Related articles:


FAQ: Kubernetes Rollbacks with AI Agents

What is kubectl rollout history? kubectl rollout history shows the revision history of a deployment, daemonset, or statefulset, including change causes and timestamps.

What is kubectl rollout undo? kubectl rollout undo reverts a workload to a previous revision. Without --to-revision, it rolls back to the immediately previous revision.

Why should you check history before rolling back? Checking history ensures you understand what revision you're reverting to. Blindly undoing might roll back to an equally broken or older broken state.

Do all Kubernetes resources support rollout? No. Deployments, DaemonSets, and StatefulSets support rollout. ReplicaSets, Pods, and Services do not have rollout history.

Schedule a Demo

See Skyflo in Action

Book a personalized demo with our team. We'll show you how Skyflo can transform your DevOps workflows.