r
Kubernetes Skills
Scanned@rohitg00
npx machina-cli add skill @rohitg00/k8s-backup --openclawFiles (1)
SKILL.md
3.2 KB
Kubernetes Backup with Velero
Manage backups and restores using kubectl-mcp-server's Velero tools.
Check Velero Installation
# Detect Velero
velero_detect_tool()
# List backup locations
velero_backup_locations_list_tool()
Create Backups
# Backup entire namespace
velero_backup_create_tool(
name="my-backup",
namespaces=["default", "app-namespace"]
)
# Backup with label selector
velero_backup_create_tool(
name="app-backup",
namespaces=["default"],
label_selector="app=my-app"
)
# Backup excluding resources
velero_backup_create_tool(
name="config-backup",
namespaces=["default"],
exclude_resources=["pods", "replicasets"]
)
# Backup with TTL
velero_backup_create_tool(
name="daily-backup",
namespaces=["production"],
ttl="720h" # 30 days
)
List and Describe Backups
# List all backups
velero_backups_list_tool()
# Get backup details
velero_backup_get_tool(name="my-backup")
# Check backup status
# - New: Backup request created
# - InProgress: Backup running
# - Completed: Backup successful
# - Failed: Backup failed
# - PartiallyFailed: Some items failed
Restore from Backup
# Full restore
velero_restore_create_tool(
name="my-restore",
backup_name="my-backup"
)
# Restore to different namespace
velero_restore_create_tool(
name="my-restore",
backup_name="my-backup",
namespace_mappings={"old-ns": "new-ns"}
)
# Restore specific resources
velero_restore_create_tool(
name="config-restore",
backup_name="my-backup",
include_resources=["configmaps", "secrets"]
)
# Restore excluding resources
velero_restore_create_tool(
name="partial-restore",
backup_name="my-backup",
exclude_resources=["persistentvolumeclaims"]
)
List and Monitor Restores
# List restores
velero_restores_list_tool()
# Get restore details
velero_restore_get_tool(name="my-restore")
Scheduled Backups
# List schedules
velero_schedules_list_tool()
# Get schedule details
velero_schedule_get_tool(name="daily-backup")
# Create schedule (via kubectl)
kubectl_apply(manifest="""
apiVersion: velero.io/v1
kind: Schedule
metadata:
name: daily-backup
namespace: velero
spec:
schedule: "0 2 * * *" # 2 AM daily
template:
includedNamespaces:
- production
ttl: 720h
""")
Disaster Recovery Workflow
Create DR Backup
1. velero_backup_create_tool(
name="dr-backup-$(date)",
namespaces=["production"]
)
2. velero_backup_get_tool(name="dr-backup-...") # Wait for completion
Restore to New Cluster
1. velero_detect_tool() # Verify Velero installed
2. velero_backups_list_tool() # Find backup
3. velero_restore_create_tool(
name="dr-restore",
backup_name="dr-backup-..."
)
4. velero_restore_get_tool(name="dr-restore") # Monitor
Related Skills
- k8s-multicluster - Multi-cluster operations
- k8s-incident - Incident response
Overview
This skill enables reliable Kubernetes backups and restores using Velero via kubectl-mcp-server tools. It supports creating backups for entire namespaces or specific resources, restoring across clusters, disaster recovery workflows, and migrating workloads between clusters.
How This Skill Works
Velero is leveraged through kubectl-mcp-server tools to detect Velero, create backups, list and describe backups, and perform restores with options like namespace mappings and resource filtering. Backups can be scheduled and monitored, and restores can be tailored to include or exclude resources, ensuring flexible disaster recovery and migration scenarios.
When to Use It
- Creating a backup for one or more namespaces (default and app-namespace).
- Restoring applications after a failure or data loss.
- Managing disaster recovery across clusters (DR workflows).
- Migrating workloads between Kubernetes clusters.
- Scheduling automated backups for ongoing protection.
Quick Start
- Step 1: velero_detect_tool() and velero_backup_locations_list_tool() to verify Velero is installed and locations are available.
- Step 2: Create a backup, e.g., velero_backup_create_tool(name="my-backup", namespaces=["default", "app-namespace"]).
- Step 3: Restore from backup, e.g., velero_restore_create_tool(name="my-restore", backup_name="my-backup").
Best Practices
- Test restore procedures regularly to verify recoverability.
- Use label selectors to target only the required resources for backup.
- Be careful with exclude_resources to avoid omitting critical items.
- Set a meaningful TTL for backups to control retention.
- Document backup names, namespaces included, and restore mappings for future use.
Example Use Cases
- Backup entire namespace: my-backup for namespaces default and app-namespace.
- Backup with label selector: app-backup for namespace default with label app=my-app.
- Backup excluding resources: config-backup excluding pods and replicasets.
- Full restore: my-restore from backup my-backup.
- Restore to different namespace: map old-ns to new-ns during restore.
Frequently Asked Questions
Add this skill to your agents