Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceUsage API #737

Closed
wzshiming opened this issue Jul 24, 2023 · 0 comments · Fixed by #740
Closed

ResourceUsage API #737

wzshiming opened this issue Jul 24, 2023 · 0 comments · Fixed by #740
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@wzshiming
Copy link
Member

wzshiming commented Jul 24, 2023

What would you like to be added?

kind: ResourceUsage
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
  name: pod
  namespace: default
spec:
  usages:
  - usage:
      cpu: container.resources.requests.cpu || 100m
      # Take the value from the annotation and divide it equally between each container.
      # cpu: Quantity(pod.metadata["cpu_usage"]) / len(pod.spec.containers)
      # Each container uses one-tenth of the host node
      # cpu: node.status.allocatable.cpu / 10.0
      # Value from annotations
      # cpu: '"kwok.x-k8s.io/usage-cpu" in pod.metadata.annotations ? Quantity(pod.metadata.annotations["kwok.x-k8s.io/usage-cpu"]) : Quantity("1m")'
      
      memory: container.resources.requests.memory || 100Mi
      # Memory keeps growing
      # memory: Quantity(pod.SinceSecond()) * 1Mi
      # Value from annotations
      # memory: '"kwok.x-k8s.io/usage-memory" in pod.metadata.annotations ? Quantity(pod.metadata.annotations["kwok.x-k8s.io/usage-memory"]) : Quantity("1Mi")'
---
kind: ClusterResourceUsage
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
  name: cluster-resource-usage
spec:
...

examples

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      run: nginx
  template:
    metadata:
      labels:
        run: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        resources:
          limits:
            cpu: 500m
          requests:
            cpu: 200m
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: nginx
spec:
  maxReplicas: 10
  minReplicas: 1
  behavior:
    scaleDown:
      stabilizationWindowSeconds: 10
      policies:
      - type: Percent
        value: 100
        periodSeconds: 3
      selectPolicy: Max
    scaleUp:
      stabilizationWindowSeconds: 0
      policies:
      - type: Percent
        value: 100
        periodSeconds: 2
      - type: Pods
        value: 2
        periodSeconds: 2
      selectPolicy: Max
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: nginx
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50
---
kind: ClusterResourceUsage
apiVersion: kwok.x-k8s.io/v1alpha1
metadata:
  name: cluster-resource-usage
spec:
  usages:
  - usage:
      cpu: 100m
      memory: 100Mi

Why is this needed?

Need a simple way to describe resource usage for Pod

@wzshiming wzshiming added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 24, 2023
@wzshiming wzshiming added this to the v0.4 milestone Jul 25, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in KWOK Tracking Jul 25, 2023
@wzshiming wzshiming moved this from 🆕 New to 🏗 In progress in KWOK Tracking Jul 25, 2023
@wzshiming wzshiming modified the milestones: v0.4, v0.5 Aug 23, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in KWOK Tracking Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant