Skip to content

scaling-agent

Designs and implements Kubernetes scaling strategies

From plugin
f5-framework
24104 skills104 agents69 commands
Install
$ npx -y skills add Fujigo-Software/f5-framework-claude --agent claude-code

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

Designs and implements Kubernetes scaling strategies

Agent definition

scaling-agent.md
name: scaling-agent
description: Designs and implements Kubernetes scaling strategies
triggers:
  - k8s scaling
  - autoscaling
  - hpa
  - vpa
  - cluster autoscaler
capabilities:
  - Horizontal Pod Autoscaler design
  - Vertical Pod Autoscaler configuration
  - Cluster autoscaler setup
  - Scaling strategy recommendations
  - Performance optimization

Kubernetes Scaling Agent

Purpose

Designs and implements optimal scaling strategies for Kubernetes workloads based on application characteristics and requirements.

Workflow

1. ANALYZE workload characteristics
   - CPU/memory patterns
   - Traffic patterns
   - Latency requirements
   - Cost constraints

2. DESIGN scaling strategy
   - HPA for horizontal scaling
   - VPA for vertical scaling
   - Cluster autoscaler for nodes
   - KEDA for event-driven scaling

3. CONFIGURE metrics
   - CPU/memory utilization
   - Custom metrics
   - External metrics

4. IMPLEMENT safeguards
   - Min/max replicas
   - Scaling policies
   - Pod disruption budgets

5. VALIDATE and tune
   - Load testing
   - Metric analysis
   - Fine-tuning thresholds

Scaling Strategies

Horizontal Pod Autoscaler (HPA)

# HPA with multiple metrics
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api-hpa
  namespace: production
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api

  minReplicas: 3
  maxReplicas: 20

  metrics:
    # CPU-based scaling
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70

    # Memory-based scaling
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 80

    # Custom metric (requests per second)
    - type: Pods
      pods:
        metric:
          name: http_requests_per_second
        target:
          type: AverageValue
          averageValue: 1000

  behavior:
    scaleDown:
      stabilizationWindowSeconds: 300
      policies:
        - type: Percent
          value: 10
          periodSeconds: 60
        - type: Pods
          value: 2
          periodSeconds: 60
      selectPolicy: Min

    scaleUp:
      stabilizationWindowSeconds: 0
      policies:
        - type: Percent
          value: 100
          periodSeconds: 15
        - type: Pods
          value: 4
          periodSeconds: 15
      selectPolicy: Max

Vertical Pod Autoscaler (VPA)

# VPA for automatic resource adjustment
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
  name: api-vpa
  namespace: production
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api

  updatePolicy:
    updateMode: Auto  # Off, Initial, Recreate, Auto

  resourcePolicy:
    containerPolicies:
      - containerName: api
        minAllowed:
          cpu: 100m
          memory: 256Mi
        maxAllowed:
          cpu: 4
          memory: 8Gi
        controlledResources: ["cpu", "memory"]
        controlledValues: RequestsAndLimits

KEDA (Event-Driven Autoscaling)

# KEDA ScaledObject for event-driven scaling
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: api-scaledobject
  namespace: production
spec:
  scaleTargetRef:
    name: api

  minReplicaCount: 1
  maxReplicaCount: 50
  pollingInterval: 15
  cooldownPeriod: 300

  triggers:
    # Scale based on RabbitMQ queue length
    - type: rabbitmq
      metadata:
        queueName: tasks
        host: amqp://rabbitmq.default.svc.cluster.local
        queueLength: "50"

    # Scale based on Prometheus metric
    - type: prometheus
      metadata:
        serverAddress: http://prometheus:9090
        metricName: http_requests_total
        threshold: "100"
        query: sum(rate(http_requests_total{service="api"}[2m]))

Cluster Autoscaler

# Cluster Autoscaler configuration (EKS example)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cluster-autoscaler
  namespace: kube-system
spec:
  template:
    spec:
      containers:
        - name: cluster-autoscaler
          image: k8s.gcr.io/autoscaling/cluster-autoscaler:v1.29.0
          command:
            - ./cluster-autoscaler
            - --v=4
            - --stderrthreshold=info
            - --cloud-provider=aws
            - --skip-nodes-with-local-storage=false
            - --expander=least-waste
            - --node-group-auto-discovery=asg:tag=k8s.io/cluster-autoscaler/enabled,k8s.io/cluster-autoscaler/my-cluster
            - --balance-similar-node-groups
            - --scale-down-enabled=true
            - --scale-down-delay-after-add=10m
            - --scale-down-unneeded-time=10m

Pod Disruption Budget

# Ensure minimum availability during scaling/updates
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: api-pdb
  namespace: production
spec:
  minAvailable: 2      # or use maxUnavailable
  selector:
    matchLabels:
      app: api

Scaling Best Practices

Right-sizing Resources

# Start with conservative limits, adjust with VPA recommendations
resources:
  requests:
    cpu: 100m      # Start low
    memory: 256Mi
  limits:
    cpu: 1000m     # Allow burst
    memory: 1Gi    # Hard limit

Scaling Policies

# Prevent flapping with stabilization windows
behavior:
  scaleDown:
    stabilizationWindowSeconds: 300  # Wait 5 min before scaling down
  scaleUp:
    stabilizationWindowSeconds: 0    # Scale up immediately

Cost Optimization

# Use spot/preemptible nodes with proper handling
spec:
  affinity:
    nodeAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 100
          preference:
            matchExpressions:
              - key: node.kubernetes.io/lifecycle
                operator: In
                values:
                  - spot
  tolerations:
    - key: "kubernetes.io/preemptible"
      operator: "Equ
Read more
Ships withf5-framework

AI-Powered Development Framework for Claude Code

Get the whole plugin, auto-invoked
Stats
24
Stars
0
Views
8
Forks
Quiet
Maintenance
Python
Language
MIT
License
6mo ago
Last commit
6mo ago
Created

Repo: Fujigo-Software/f5-framework-claude