协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
devops-finops【开发与工程】Trigger: "FinOps", "cloud cost", "cost optimization", "cloud spend", "cost allocation", "reserved instance", "savings plan", "cost tagging", "cloud budget", "cost governance", "FinOps framework", "cloud economics" Exclusion: Not for infra provisioning -- use cloud-specific skills.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Implement FinOps practices for cloud cost visibility, allocation, optimization, and governance -- covering compute, storage, Kubernetes, and organizational maturity from crawl to run.
Any user message referencing cloud cost, FinOps, cost optimization, reserved instances, savings plans, tagging, budgets, chargeback, or Kubecost.
Cloud provider(s), current monthly spend, team structure, tagging conventions, optimization goals, compliance requirements.
Tagging strategy, budget alerts, right-sizing recommendations, RI/SP purchase plans, cost dashboards, chargeback/showback reports, K8s cost optimization config.
Tabular data, tagging schemas, policy definitions. CLI/API examples for cost tools.
No preamble. No postamble. No explanations. No filler/hedging/transitions.
Tagging enforced, budgets active, right-sizing recommendations implemented, cost visibility dashboards deployed, chargeback process documented, K8s cost visibility enabled.
| Stage | Capabilities | Metrics | Automation Level |
|---|---|---|---|
| Crawl | Tagging, basic budgets, monthly reports | Total spend, top services | Manual |
| Walk | Anomaly detection, RI/SP management, team allocation | Unit economics, coverage % | Semi-automated |
| Run | Automated optimization, chargeback, continuous governance | Efficiency KPIs, forecasting | Fully automated |
| Model | Structure | Best For |
|---|---|---|
| Centralized | Single FinOps team manages all | Small orgs (<100 people) |
| Federated | Each team manages own costs | Large orgs (>500 people) |
| Hub-and-Spoke | Central team + decentralized executors | Mid-size orgs |
| Embedded | FinOps practitioners in each team | Enterprise with dedicated budget |
| Resource Type | Optimization Potential | Effort | Priority |
|---|---|---|---|
| Compute (EC2, GCE, VM) | 30-60% savings | Medium | High |
| Kubernetes (idle, over-provisioned) | 40-60% savings | High | High |
| Storage (lifecycle, unattached) | 20-40% savings | Low | Medium |
| Data transfer (egress, cross-region) | 30-50% savings | Medium | High |
| Database (right-sizing, RI) | 25-50% savings | Medium | High |
| Serverless (over-provisioned memory/timeout) | 20-30% savings | Low | Medium |
# Terraform tagging convention
locals {
required_tags = {
Environment = var.environment # dev, staging, prod
CostCenter = var.cost_center # platform, data, ml, security
Service = var.service_name # myapp, auth, payments
Team = var.team_name # backend, frontend, infra
Owner = var.owner_email # team lead email
ManagedBy = "terraform"
CreatedAt = formatdate("YYYY-MM-DD", timestamp())
}
}
resource "aws_instance" "app" {
tags = local.required_tags
volume_tags = local.required_tags
}
# AWS Budget with multiple thresholds and automation
resource "aws_budgets_budget" "monthly" {
name = "monthly-budget-${var.service}"
budget_type = "COST"
limit_amount = var.budget_amount
limit_unit = "USD"
time_period_start = "2024-01-01_00:00"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = 50
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = [var.owner_email]
}
notification {
comparison_operator = "GREATER_THAN"
threshold = 80
threshold_type = "PERCENTAGE"
notification_type = "FORECASTED"
subscriber_sns_topic_arns = [aws_sns_topic.cost_alerts.arn]
}
notification {
comparison_operator = "GREATER_THAN"
threshold = 100
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_sns_topic_arns = [aws_sns_topic.cost_escalation.arn]
}
}
-- Query billing export for top spenders
SELECT
service.description AS service,
ROUND(SUM(cost), 2) AS total_cost,
ROUND(SUM(usage.amount), 2) AS total_usage
FROM `project.dataset.gcp_billing_export_v1`
WHERE DATE(_PARTITIONTIME) >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY service
ORDER BY total_cost DESC
LIMIT 10;
# AWS Compute Optimizer recommendations
aws compute-optimizer get-ec2-instance-recommendations \
--instance-arn arn:aws:ec2:us-east-1:123456789012:instance/i-12345
# Azure Advisor cost recommendations
az advisor recommendation list \
--category Cost \
--query "[].{Name:resourceName, Saving:savings}" \
--output table
# GCP Recommender
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1 \
--recommender=google.compute.image.IdleResourceRecommender
# AWS: Purchase Compute Savings Plan
aws savingsplans purchase-savings-plan \
--savings-plan-offering-id <offering-id> \
--commitment 1000.00 \
--purchase-time "2024-01-01T00:00:00Z"
# AWS: Purchase EC2 RI
aws ec2 purchase-reserved-instances-offering \
--reserved-instances-offering-id <offering-id> \
--instance-count 5
# GCP: Purchase CUD
gcloud compute commitments create reservation \
--project=my-project \
--region=us-central1 \
--plan=12-month \
--resources=vcpu=100,memory=384GB
# Kubecost namespace annotations for cost allocation
apiVersion: v1
kind: Namespace
metadata:
name: myapp-prod
annotations:
kubecost.owner: "team-backend"
kubecost.env: "production"
kubecost.app: "myapp"
kubecost.cost-center: "platform"
kubecost.budget: "5000"
---
apiVersion: v1
kind: ResourceQuota
metadata:
name: myapp-quota
namespace: myapp-prod
spec:
hard:
requests.cpu: "10"
requests.memory: "32Gi"
limits.cpu: "20"
limits.memory: "64Gi"
# Lambda function to stop untagged instances
def lambda_handler(event, context):
ec2 = boto3.client('ec2')
instances = ec2.describe_instances(
Filters=[{'Name': 'tag-key', 'Values': ['CostCenter']}]
)
untagged = []
for r in instances['Reservations']:
for i in r['Instances']:
if not i.get('Tags'):
untagged.append(i['InstanceId'])
if untagged:
ec2.stop_instances(InstanceIds=untagged)
send_slack_alert(f"Stopped untagged instances: {untagged}")
resource "aws_s3_bucket_lifecycle_configuration" "main" {
bucket = aws_s3_bucket.data.id
rule {
id = "transition-to-ia"
status = "Enabled"
filter {
prefix = "logs/"
}
transition {
days = 30
storage_class = "STANDARD_IA"
}
transition {
days = 90
storage_class = "GLACIER"
}
expiration {
days = 365
}
}
rule {
id = "noncurrent-version-cleanup"
status = "Enabled"
noncurrent_version_expiration {
noncurrent_days = 90
}
}
}
Jumping to automated optimization without establishing tagging, visibility, and allocation leads to chaos. Follow crawl-walk-run maturity. Do not automate before you can measure.
Buying RIs for unstable workloads or before right-sizing wastes money. Always right-size for 14 days first. Only commit to RIs for stable baseline under 60% utilization.
Implementing finance-grade chargeback without team buy-in creates friction. Start with showback (visibility only). Transition to chargeback when teams understand their costs.
Too many budget alerts lead to ignored alerts. Set meaningful thresholds: 50% (info), 80% (warn), 100% (critical), 150% (escalation). Route to cost center owners, not everyone.
Unattached volumes, idle load balancers, and orphaned snapshots accumulate silently. A single unattached volume costs $8/month, but 100 cost $800/month. Automate detection and remediation.
Teams optimize compute and storage but ignore egress. A data-heavy app can spend more on data transfer than compute. Use CDN for egress. Keep data in-region. Monitor NAT Gateway charges.
FinOps focuses on cloud infrastructure but SaaS tools, API costs, and data transfer to third parties add up. Include SaaS costs in visibility dashboards. Review subscription utilization quarterly.
FinOps: cloud-specific cost management with team accountability and continuous optimization. ITFM: broader discipline covering all IT costs (hardware, software, personnel). FinOps is a subset of ITFM for cloud costs with DevOps culture.
FinOps includes cost optimization as one pillar but also covers visibility, allocation, governance, and maturity. Cost optimization is technical; FinOps is organizational and technical.
Traditional chargeback is annual, static, and opaque. FinOps chargeback is continuous, granular (per resource/namespace), and transparent. FinOps provides showback before chargeback.
Detection: daily anomaly alert shows 35% increase in compute. Investigation: drill into billing export by service, region, label. Root cause: new deployment without spot flag. Fix: tag with spot config, add CI validation.
Detection: weekly idle resource report. Investigation: identify owners via creator tag. Fix: delete unattached volumes, orphaned LBs, idle NAT. Automation: auto-delete after grace period.
Detection: monthly RI report shows coverage dropped from 65% to 45%. Investigation: new workload without RI. Fix: purchase additional RI, adjust workload. Automation: alert when coverage under 50%.
Hand off to finops for cost visibility and optimization. Hand off to cloud-specific skills (aws/azure/gcp) for resource provisioning at optimized price.
| Decision | Reserved (1yr/3yr) | On-demand / Spot |
|---|---|---|
| Discount | 30-70% | 0-90% (spot) |
| Commitment | 1-3 year term | None / ephemeral |
| Flexibility | Convertible or standard | Full |
| Workload fit | Steady-state, predictable | Variable, batch, stateless |
| Risk | Over-provisioning if demand shrinks | Spot termination, price spikes |
| Best for | Databases, production K8s | CI runners, dev, batch jobs |
| Dimension | Savings Plan | EC2 RI |
|---|---|---|
| Scope | Compute ($/hr commitment) | Instance family × region |
| Coverage | EC2, Fargate, Lambda | EC2 only |
| Flexibility | Instance family changes okay | Locked to family |
| Management | Simpler (single $ commitment) | Per-instance-type tracking |
Budgets:
- BudgetName: "Monthly-Infrastructure"
BudgetType: "COST"
BudgetLimit:
Amount: 50000
Unit: USD
TimePeriod:
Start: "2026-01-01"
TimeUnit: "MONTHLY"
CostFilters:
TagKeyValue:
- "Environment$production"
NotificationThresholds:
- Threshold: 80
ComparisonOperator: GREATER_THAN
NotificationType: ACTUAL
Subscribers:
- Address: finops@company.com
SubscriptionType: EMAIL
- Threshold: 100
ComparisonOperator: GREATER_THAN
NotificationType: FORECASTED
Subscribers:
- Address: finops-team@company.com
SubscriptionType: EMAIL
SubscriptionType: SLACK
#!/usr/bin/env bash
set -euo pipefail
check_tag_compliance() {
local required_tags=("Environment" "Owner" "CostCenter" "Project")
local violations=0
aws resourcegroupstaggingapi get-resources \
--query 'ResourceTagMappingList[?Tags == `null` || length(Tags) == `0`]' \
--output json | jq -c '.[]' | while read -r resource; do
arn=$(echo "$resource" | jq -r '.ResourceARN')
echo "UNTAGGED: $arn"
violations=$((violations + 1))
done
echo "Total untagged resources: $violations"
return "$violations"
}
ce:*, budgets:*, pricing:* to FinOps team