OptiPod Annotations Reference
OptiPod Annotations Reference
Section titled “OptiPod Annotations Reference”Complete reference for all annotations used by OptiPod to store recommendations and manage workloads.
Overview
Section titled “Overview”OptiPod uses Kubernetes annotations to:
- Mark workloads as managed by OptiPod
- Store resource recommendations
- Track policy associations
- Record timestamps of recommendations and applications
- Enable webhook processing
All OptiPod annotations use the optipod.io/ prefix.
Management Annotations
Section titled “Management Annotations”These annotations identify and track OptiPod-managed workloads.
optipod.io/managed
Section titled “optipod.io/managed”Indicates the workload is managed by OptiPod.
Value: "true" or "false" Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller Required: Yes (for managed workloads)
Example:
metadata: annotations: optipod.io/managed: "true"Usage:
- Set to
"true"when OptiPod starts managing a workload - Used to identify workloads under OptiPod control
- Checked by webhook to determine if processing is needed
optipod.io/policy
Section titled “optipod.io/policy”Indicates which policy manages this workload.
Value: Policy name (string) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller Required: Yes (for managed workloads)
Example:
metadata: annotations: optipod.io/policy: "production-policy"Usage:
- Stores the name of the OptimizationPolicy resource
- Used for tracking and debugging
- Helps identify which policy generated recommendations
optipod.io/policy-uid
Section titled “optipod.io/policy-uid”Stores the unique identifier of the acting optimization policy.
Value: Policy UID (string) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller Required: Yes (for managed workloads)
Example:
metadata: annotations: optipod.io/policy-uid: "abc123-def456-ghi789"Usage:
- Provides unique identification of the policy
- Used for policy change detection
- Helps prevent conflicts when policies are recreated
optipod.io/last-recommendation
Section titled “optipod.io/last-recommendation”Timestamp of the last recommendation generation.
Value: RFC3339 timestamp (string) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller Required: No
Example:
metadata: annotations: optipod.io/last-recommendation: "2025-01-28T10:30:00Z"Usage:
- Tracks when recommendations were last computed
- Used for debugging and monitoring
- Helps identify stale recommendations
optipod.io/last-applied
Section titled “optipod.io/last-applied”Timestamp of the last applied change (Auto mode only).
Value: RFC3339 timestamp (string) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller (Auto mode) or Webhook Required: No
Example:
metadata: annotations: optipod.io/last-applied: "2025-01-28T10:35:00Z"Usage:
- Tracks when recommendations were last applied
- Only set in Auto mode
- Used for monitoring and audit trails
optipod.io/strategy
Section titled “optipod.io/strategy”Indicates which strategy is used for this workload.
Value: "ssa" or "webhook" Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller Required: No
Example:
metadata: annotations: optipod.io/strategy: "webhook"Usage:
- Indicates the update strategy (SSA or webhook)
- Used for debugging and monitoring
- Helps identify how recommendations are applied
Recommendation Annotations
Section titled “Recommendation Annotations”These annotations store per-container resource recommendations.
Format
Section titled “Format”Recommendation annotations follow this format:
optipod.io/recommendation.<container-name>.<resource>-<type>Where:
<container-name>- Name of the container<resource>-cpuormemory<type>-requestorlimit
CPU Request Recommendation
Section titled “CPU Request Recommendation”Format: optipod.io/recommendation.<container-name>.cpu-request Value: Kubernetes quantity (e.g., 500m, 1000m, 2) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller
Example:
metadata: annotations: optipod.io/recommendation.app.cpu-request: "500m" optipod.io/recommendation.sidecar.cpu-request: "100m"Usage:
- Stores recommended CPU request for each container
- Read by webhook to inject CPU requests
- Used by recommendation report script
Memory Request Recommendation
Section titled “Memory Request Recommendation”Format: optipod.io/recommendation.<container-name>.memory-request Value: Kubernetes quantity (e.g., 512Mi, 1Gi, 2Gi) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller
Example:
metadata: annotations: optipod.io/recommendation.app.memory-request: "1Gi" optipod.io/recommendation.sidecar.memory-request: "256Mi"Usage:
- Stores recommended memory request for each container
- Read by webhook to inject memory requests
- Used by recommendation report script
CPU Limit Recommendation
Section titled “CPU Limit Recommendation”Format: optipod.io/recommendation.<container-name>.cpu-limit Value: Kubernetes quantity (e.g., 750m, 1500m, 3) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller (when updateRequestsOnly: false)
Example:
metadata: annotations: optipod.io/recommendation.app.cpu-limit: "750m" optipod.io/recommendation.sidecar.cpu-limit: "150m"Usage:
- Stores recommended CPU limit for each container
- Only set when policy has
updateRequestsOnly: false - Read by webhook to inject CPU limits
- Calculated using
cpuLimitMultiplierfrom policy
Memory Limit Recommendation
Section titled “Memory Limit Recommendation”Format: optipod.io/recommendation.<container-name>.memory-limit Value: Kubernetes quantity (e.g., 1.1Gi, 2Gi, 4Gi) Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller (when updateRequestsOnly: false)
Example:
metadata: annotations: optipod.io/recommendation.app.memory-limit: "1.1Gi" optipod.io/recommendation.sidecar.memory-limit: "281Mi"Usage:
- Stores recommended memory limit for each container
- Only set when policy has
updateRequestsOnly: false - Read by webhook to inject memory limits
- Calculated using
memoryLimitMultiplierfrom policy
Webhook Annotations
Section titled “Webhook Annotations”These annotations control webhook behavior.
optipod.io/webhook-enabled
Section titled “optipod.io/webhook-enabled”Indicates the workload should be processed by webhook.
Value: "true" or "false" Applied to: Deployment, StatefulSet, DaemonSet Set by: Controller (when using webhook strategy) Required: No
Example:
metadata: annotations: optipod.io/webhook-enabled: "true"Usage:
- Enables webhook processing for this workload
- Set when policy uses webhook strategy
- Checked by webhook admission controller
Complete Example
Section titled “Complete Example”Here’s a complete example showing all annotations on a Deployment:
apiVersion: apps/v1kind: Deploymentmetadata: name: my-app namespace: production annotations: # Management annotations optipod.io/managed: "true" optipod.io/policy: "production-policy" optipod.io/policy-uid: "abc123-def456-ghi789" optipod.io/last-recommendation: "2025-01-28T10:30:00Z" optipod.io/last-applied: "2025-01-28T10:35:00Z" optipod.io/strategy: "webhook"
# Recommendation annotations (requests only) optipod.io/recommendation.app.cpu-request: "500m" optipod.io/recommendation.app.memory-request: "1Gi" optipod.io/recommendation.sidecar.cpu-request: "100m" optipod.io/recommendation.sidecar.memory-request: "256Mi"
# Webhook annotation optipod.io/webhook-enabled: "true"spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: app image: my-app:v1.0.0 resources: requests: cpu: "1000m" # Will be updated by webhook memory: "2Gi" # Will be updated by webhook - name: sidecar image: sidecar:v1.0.0 resources: requests: cpu: "200m" # Will be updated by webhook memory: "512Mi" # Will be updated by webhookExample with Limits
Section titled “Example with Limits”When updateRequestsOnly: false, limit recommendations are also stored:
metadata: annotations: # Management annotations optipod.io/managed: "true" optipod.io/policy: "production-policy" optipod.io/policy-uid: "abc123-def456-ghi789" optipod.io/last-recommendation: "2025-01-28T10:30:00Z" optipod.io/strategy: "webhook"
# Recommendation annotations (requests and limits) optipod.io/recommendation.app.cpu-request: "500m" optipod.io/recommendation.app.memory-request: "1Gi" optipod.io/recommendation.app.cpu-limit: "750m" # Limit = Request × 1.5 optipod.io/recommendation.app.memory-limit: "1.1Gi" # Limit = Request × 1.1
# Webhook annotation optipod.io/webhook-enabled: "true"Viewing Annotations
Section titled “Viewing Annotations”kubectl get
Section titled “kubectl get”View all annotations on a workload:
kubectl get deployment my-app -o jsonpath='{.metadata.annotations}' | jqkubectl describe
Section titled “kubectl describe”View annotations in human-readable format:
kubectl describe deployment my-appLook for the Annotations section:
Annotations: optipod.io/cpu-request.app: 500m optipod.io/memory-request.app: 1Gi optipod.io/managed: true optipod.io/policy: production-policySpecific annotation
Section titled “Specific annotation”View a specific annotation:
# CPU request for container "app"kubectl get deployment my-app \ -o jsonpath='{.metadata.annotations.optipod\.io/recommendation\.app\.cpu-request}'
# Memory request for container "app"kubectl get deployment my-app \ -o jsonpath='{.metadata.annotations.optipod\.io/recommendation\.app\.memory-request}'All OptiPod annotations
Section titled “All OptiPod annotations”View only OptiPod annotations:
kubectl get deployment my-app -o yaml | grep "optipod.io"Annotation Lifecycle
Section titled “Annotation Lifecycle”Recommend Mode
Section titled “Recommend Mode”- Controller discovers workload matching policy
- Controller fetches metrics and computes recommendations
- Controller adds management annotations:
optipod.io/managed: "true"optipod.io/policy: "<policy-name>"optipod.io/policy-uid: "<policy-uid>"optipod.io/last-recommendation: "<timestamp>"
- Controller adds recommendation annotations:
optipod.io/recommendation.<container>.cpu-requestoptipod.io/recommendation.<container>.memory-request- (Optional)
optipod.io/recommendation.<container>.cpu-limit - (Optional)
optipod.io/recommendation.<container>.memory-limit
- Annotations remain on workload for review
- No changes to pod template
Auto Mode (Webhook Strategy)
Section titled “Auto Mode (Webhook Strategy)”- Controller performs steps 1-4 from Recommend mode
- Controller adds webhook annotation:
optipod.io/webhook-enabled: "true"
- Controller adds strategy annotation:
optipod.io/strategy: "webhook"
- If
rolloutStrategy: immediate:- Controller triggers rolling restart
- Webhook intercepts pod creation
- Webhook reads recommendation annotations
- Webhook injects resource values into pod spec
- Controller updates
optipod.io/last-appliedtimestamp
Auto Mode (SSA Strategy)
Section titled “Auto Mode (SSA Strategy)”- Controller performs steps 1-4 from Recommend mode
- Controller adds strategy annotation:
optipod.io/strategy: "ssa"
- Controller applies resource changes using Server-Side Apply
- Kubernetes triggers rolling restart
- Controller updates
optipod.io/last-appliedtimestamp
Annotation Removal
Section titled “Annotation Removal”Annotations are removed when:
- Policy is deleted
- Workload no longer matches policy selector
- Policy mode is changed to
Disabled
When annotations are removed:
- All
optipod.io/*annotations are deleted - Pod template resources remain unchanged
- Workload continues running with last applied values
Troubleshooting
Section titled “Troubleshooting”Missing Annotations
Section titled “Missing Annotations”If annotations are not appearing:
Check policy mode:
Terminal window kubectl get optimizationpolicy my-policy -o jsonpath='{.spec.mode}'Check policy selector:
Terminal window kubectl get optimizationpolicy my-policy -o yamlCheck workload labels:
Terminal window kubectl get deployment my-app -o jsonpath='{.metadata.labels}'Check controller logs:
Terminal window kubectl logs -n optipod-system deployment/optipod-controller
Stale Annotations
Section titled “Stale Annotations”If annotations are outdated:
Check last recommendation timestamp:
Terminal window kubectl get deployment my-app \-o jsonpath='{.metadata.annotations.optipod\.io/last-recommendation}'Check policy reconciliation interval:
Terminal window kubectl get optimizationpolicy my-policy \-o jsonpath='{.spec.reconciliationInterval}'Force reconciliation by updating policy:
Terminal window kubectl annotate optimizationpolicy my-policy \force-reconcile="$(date +%s)" --overwrite
Annotation Format Errors
Section titled “Annotation Format Errors”If webhook fails to parse annotations:
Check annotation format:
Terminal window kubectl get deployment my-app -o yaml | grep "optipod.io/recommendation"Verify container names match:
Terminal window kubectl get deployment my-app \-o jsonpath='{.spec.template.spec.containers[*].name}'Check webhook logs:
Terminal window kubectl logs -n optipod-system deployment/optipod-webhook
Best Practices
Section titled “Best Practices”- Don’t manually edit annotations - Let OptiPod manage them
- Use recommendation report - Use
optipod-recommendation-report.shto view recommendations - Monitor timestamps - Check
last-recommendationto ensure recommendations are fresh - Verify container names - Ensure annotation container names match actual containers
- Check policy association - Verify
optipod.io/policymatches expected policy - Review before Auto mode - Review annotations in Recommend mode before enabling Auto
- Backup workloads - Keep backups before enabling Auto mode
- Monitor after changes - Watch workloads after OptiPod applies changes
Related Documentation
Section titled “Related Documentation”- CRD Specification - Complete OptimizationPolicy field reference
- Reviewing Recommendations - How to review recommendations
- Creating Policies - Policy configuration guide
- Troubleshooting - Common issues and solutions
- CLI Tools - Recommendation report script reference