Operational Modes
OptiPod supports three operational modes that control how recommendations are generated and applied. Choose the mode that best fits your workflow and risk tolerance.
Mode Overview
Section titled “Mode Overview”| Mode | Generates Recommendations | Applies Changes | Best For |
|---|---|---|---|
| Recommend | ✅ Yes | ❌ No | GitOps, testing, getting started |
| Auto | ✅ Yes | ✅ Yes | Production with confidence |
| Disabled | ❌ No | ❌ No | Troubleshooting, pausing |
Recommend Mode
Section titled “Recommend Mode”Default and safest mode. OptiPod analyzes workloads and stores recommendations as annotations, but doesn’t apply them automatically.
How It Works
Section titled “How It Works”- OptiPod analyzes metrics for workloads matching policy selectors
- Generates recommendations based on usage patterns and policy configuration
- Stores recommendations as annotations on the workload metadata
- You review and decide whether to apply changes manually
Recommendation Format
Section titled “Recommendation Format”Recommendations appear as separate annotations for each container and resource type:
apiVersion: apps/v1kind: Deploymentmetadata: name: my-app annotations: # Management annotations optipod.io/managed: "true" optipod.io/policy: "production-policy" optipod.io/last-recommendation: "2026-01-26T10:30:00Z"
# Resource recommendations for 'my-app' container optipod.io/recommendation.my-app.cpu-request: "250m" optipod.io/recommendation.my-app.memory-request: "512Mi" optipod.io/recommendation.my-app.cpu-limit: "500m" optipod.io/recommendation.my-app.memory-limit: "1Gi"
# Strategy annotation optipod.io/strategy: "webhook"spec: # ... deployment spec unchangedWhen to Use
Section titled “When to Use”- Getting started: Build confidence in OptiPod’s recommendations
- GitOps workflows: Review and commit changes through Git
- Strict change control: Manual approval required for all changes
- Testing: Validate recommendations before auto-applying
- Critical workloads: Extra caution for production systems
Viewing Recommendations
Section titled “Viewing Recommendations”# Get all OptiPod annotationskubectl get deployment my-app -o json | \ jq '.metadata.annotations | with_entries(select(.key | startswith("optipod.io/")))'
# Get specific container recommendationsecho "CPU Request: $(kubectl get deployment my-app -o jsonpath='{.metadata.annotations.optipod\.io/cpu-request\.my-app}')"echo "Memory Request: $(kubectl get deployment my-app -o jsonpath='{.metadata.annotations.optipod\.io/memory-request\.my-app}')"Applying Recommendations
Section titled “Applying Recommendations”You have several options for applying recommendations:
Option 1: Manual kubectl
Section titled “Option 1: Manual kubectl”# Apply recommendations manuallykubectl set resources deployment my-app \ --requests=cpu=250m,memory=512Mi \ --limits=cpu=500m,memory=1GiOption 2: GitOps Workflow (Recommended)
Section titled “Option 2: GitOps Workflow (Recommended)”- Review recommendation annotations on workload
- Update deployment YAML in Git repository
- Commit and push changes
- GitOps tool (ArgoCD/Flux) applies changes
Example:
# Update your Git repositoryapiVersion: apps/v1kind: Deploymentmetadata: name: my-appspec: template: spec: containers: - name: my-app resources: requests: cpu: 250m # From optipod.io/recommendation.my-app.cpu-request memory: 512Mi # From optipod.io/recommendation.my-app.memory-request limits: cpu: 500m # From optipod.io/recommendation.my-app.cpu-limit memory: 1Gi # From optipod.io/memory-limit.my-appOption 3: Automation Script
Section titled “Option 3: Automation Script”#!/bin/bashDEPLOYMENT=$1NAMESPACE=${2:-default}
if [ -z "$DEPLOYMENT" ]; then echo "Usage: $0 <deployment-name> [namespace]" exit 1fi
# Get container namesCONTAINERS=$(kubectl get deployment $DEPLOYMENT -n $NAMESPACE -o json | \ jq -r '.metadata.annotations | keys[] | select(startswith("optipod.io/recommendation.")) | select(contains(".cpu-request")) | split(".")[1]' | sort -u)
for CONTAINER in $CONTAINERS; do CPU_REQ=$(kubectl get deployment $DEPLOYMENT -n $NAMESPACE -o jsonpath="{.metadata.annotations.optipod\.io/cpu-request\.$CONTAINER}") MEM_REQ=$(kubectl get deployment $DEPLOYMENT -n $NAMESPACE -o jsonpath="{.metadata.annotations.optipod\.io/memory-request\.$CONTAINER}")
echo "Applying recommendations for container: $CONTAINER" echo " CPU Request: $CPU_REQ" echo " Memory Request: $MEM_REQ"
kubectl set resources deployment $DEPLOYMENT -n $NAMESPACE \ --containers=$CONTAINER \ --requests=cpu=$CPU_REQ,memory=$MEM_REQdoneAuto Mode
Section titled “Auto Mode”Automatic application mode. OptiPod generates recommendations and automatically applies them to workloads.
How It Works
Section titled “How It Works”- OptiPod analyzes metrics and generates recommendations
- Stores recommendations as annotations (same as Recommend mode)
- Automatically applies recommendations based on update strategy
- Monitors workload health after changes
Enabling Auto Mode
Section titled “Enabling Auto Mode”apiVersion: optipod.optipod.io/v1alpha1kind: OptimizationPolicymetadata: name: auto-policy namespace: productionspec: mode: Auto # Enable automatic application
selector: workloadSelector: matchLabels: optipod.io/enabled: "true"
metricsConfig: provider: prometheus rollingWindow: 7d percentile: P90 safetyFactor: 1.2
resourceBounds: cpu: min: 10m max: 4000m memory: min: 64Mi max: 8Gi
updateStrategy: strategy: ssa # or "webhook" rolloutStrategy: onNextRestart allowUnsafeMemoryDecrease: false # Note: gradualDecreaseConfig not yet implementedUpdate Strategies
Section titled “Update Strategies”OptiPod supports two update strategies in Auto mode:
Server-Side Apply (SSA)
Section titled “Server-Side Apply (SSA)”Updates workload specs directly using Kubernetes Server-Side Apply:
updateStrategy: strategy: ssa useServerSideApply: true updateRequestsOnly: truePros:
- Direct updates to workload specs
- Field-level ownership tracking
- Works with all workload types
Cons:
- May conflict with GitOps controllers
- Changes not reflected in Git
Webhook Strategy
Section titled “Webhook Strategy”Uses mutating webhook to inject resources at pod creation:
updateStrategy: strategy: webhook rolloutStrategy: onNextRestartPros:
- GitOps-safe (doesn’t modify workload specs)
- No conflicts with ArgoCD/Flux
- Changes stored in annotations only
Cons:
- Requires webhook deployment
- Only applies on pod restart
When to Use
Section titled “When to Use”- Stable workloads: Consistent usage patterns
- Non-critical environments: Development, staging
- After validation: Tested in Recommend mode first
- With monitoring: Active observability in place
- Gradual rollout: Start with a few workloads
Safety Considerations
Section titled “Safety Considerations”Auto mode includes safety features:
- Resource bounds: Min/max limits prevent extreme values
- Safety factor: Adds headroom above observed usage
- Memory safety: Blocks unsafe memory decreases by default
- Reconciliation interval: Limits frequency of changes
Monitoring Auto Mode
Section titled “Monitoring Auto Mode”# Check policy statuskubectl describe optimizationpolicy auto-policy
# Check workload annotationskubectl get deployment my-app -o yaml | grep optipod.io
# Check last applied timekubectl get deployment my-app \ -o jsonpath='{.metadata.annotations.optipod\.io/last-applied}'
# Monitor resource usagekubectl top pod -l app=my-appDisabled Mode
Section titled “Disabled Mode”Paused mode. OptiPod stops processing workloads under this policy.
How It Works
Section titled “How It Works”- OptiPod stops analyzing workloads matching this policy
- No new recommendations are generated
- Existing annotations remain unchanged
- No automatic updates are applied
Enabling Disabled Mode
Section titled “Enabling Disabled Mode”apiVersion: optipod.optipod.io/v1alpha1kind: OptimizationPolicymetadata: name: my-policyspec: mode: Disabled # Pause optimization # ... rest of specWhen to Use
Section titled “When to Use”- Troubleshooting: Isolate OptiPod from issues
- Maintenance: During cluster maintenance windows
- Investigation: When recommendations seem incorrect
- Temporary pause: Stop optimization without deleting policy
- Emergency: Quick way to disable OptiPod
Behavior
Section titled “Behavior”- Existing recommendations remain as annotations
- No new recommendations generated
- No automatic updates applied
- Policy still exists and can be re-enabled
Re-enabling
Section titled “Re-enabling”Simply change the mode back:
kubectl patch optimizationpolicy my-policy --type merge \ -p '{"spec":{"mode":"Recommend"}}'Switching Between Modes
Section titled “Switching Between Modes”Recommend → Auto
Section titled “Recommend → Auto”Recommended progression:
- Start in Recommend mode
- Review recommendations for 1-2 weeks
- Validate recommendations are reasonable
- Test on non-critical workloads first
- Switch to Auto mode gradually
# Switch to Auto modekubectl patch optimizationpolicy my-policy --type merge \ -p '{"spec":{"mode":"Auto"}}'Auto → Recommend
Section titled “Auto → Recommend”Rollback to manual control:
# Switch back to Recommend modekubectl patch optimizationpolicy my-policy --type merge \ -p '{"spec":{"mode":"Recommend"}}'Existing recommendations remain, but no new automatic updates.
Any Mode → Disabled
Section titled “Any Mode → Disabled”Emergency stop:
# Disable policykubectl patch optimizationpolicy my-policy --type merge \ -p '{"spec":{"mode":"Disabled"}}'Mode Comparison
Section titled “Mode Comparison”Recommend Mode
Section titled “Recommend Mode”Pros:
- ✅ Safest option
- ✅ Full control over changes
- ✅ GitOps-friendly
- ✅ Easy to review before applying
Cons:
- ❌ Manual work required
- ❌ Slower optimization
- ❌ Can forget to apply recommendations
Auto Mode
Section titled “Auto Mode”Pros:
- ✅ Automatic optimization
- ✅ Continuous adaptation
- ✅ Reduced manual work
- ✅ Faster optimization
Cons:
- ❌ Less control
- ❌ Requires trust in OptiPod
- ❌ May conflict with GitOps (SSA strategy)
- ❌ Needs monitoring
Disabled Mode
Section titled “Disabled Mode”Pros:
- ✅ Quick pause
- ✅ Preserves policy configuration
- ✅ Easy to re-enable
Cons:
- ❌ No optimization
- ❌ Workloads may become over/under-provisioned
Best Practices
Section titled “Best Practices”- Start with Recommend: Always begin in Recommend mode
- Test thoroughly: Validate recommendations before Auto mode
- Gradual rollout: Enable Auto mode for a few workloads first
- Monitor closely: Watch for issues after enabling Auto mode
- Use appropriate strategy: Webhook for GitOps, SSA otherwise
- Set safety bounds: Configure appropriate resource bounds
- Have rollback plan: Know how to quickly disable if needed
Troubleshooting
Section titled “Troubleshooting”No Recommendations in Recommend Mode
Section titled “No Recommendations in Recommend Mode”Check:
- Workload has correct labels matching policy selector
- Sufficient metrics data available (check rolling window)
- Policy is not in Disabled mode
- Metrics provider is accessible
Auto Mode Not Applying Changes
Section titled “Auto Mode Not Applying Changes”Verify:
- Mode is set to
Auto - Update strategy is configured
- Webhook is deployed (if using webhook strategy)
- No safety checks blocking updates
- Check policy status for errors
Unexpected Changes in Auto Mode
Section titled “Unexpected Changes in Auto Mode”Review:
- Policy configuration (bounds, safety factor)
- Recent metrics data
- Safety settings (allowUnsafeMemoryDecrease)
- Gradual decrease configuration