Skip to content

Commit

Permalink
not update HPA if it's not ready (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho authored Oct 11, 2023
1 parent c555c8b commit f0f81be
Show file tree
Hide file tree
Showing 46 changed files with 1,712 additions and 35 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/tortoise_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type UpdateMode string
const (
UpdateModeOff UpdateMode = "Off"
UpdateModeEmergency UpdateMode = "Emergency"
AutoUpdateMode UpdateMode = "Auto"
UpdateModeAuto UpdateMode = "Auto"
)

// +kubebuilder:validation:Enum=Off;Horizontal;Vertical
Expand Down Expand Up @@ -184,7 +184,7 @@ const (
// TortoisePhaseWorking means tortoise is making the recommendations,
// and applying the recommendation values.
TortoisePhaseWorking TortoisePhase = "Working"
// TortoisePhasePartlyWorking means tortoise is making the recommendations,
// TortoisePhasePartlyWorking means tortoise has maxReplicas and minReplicas recommendations ready,
// and applying the recommendation values.
// But, some of the resources are not scaled due to some reasons. (probably still gathering data)
TortoisePhasePartlyWorking TortoisePhase = "PartlyWorking"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
container: istio-proxy
name: memory
target:
averageUtilization: 75
averageUtilization: 50
type: Utilization
type: ContainerResource
minReplicas: 5
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
metadata:
annotations:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
tortoises.autoscaling.mercari.com/tortoise-name: mercari
name: tortoise-hpa-mercari
namespace: default
spec:
behavior:
scaleDown:
policies:
- periodSeconds: 90
type: Percent
value: 2
selectPolicy: Max
scaleUp:
policies:
- periodSeconds: 60
type: Percent
value: 100
selectPolicy: Max
stabilizationWindowSeconds: 0
maxReplicas: 20
metrics:
- containerResource:
container: app
name: cpu
target:
averageUtilization: 75
type: Utilization
type: ContainerResource
minReplicas: 5
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
status:
currentMetrics: null
desiredReplicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
metadata:
name: mercari
namespace: default
spec:
resourcePolicy:
- autoscalingPolicy:
cpu: Horizontal
memory: Vertical
containerName: app
targetRefs:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
status:
conditions:
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
cpu:
quantity: "3"
updatedAt: null
memory:
quantity: 3Gi
updatedAt: null
recommendation:
cpu:
quantity: "3"
updatedAt: null
memory:
quantity: 3Gi
updatedAt: null
tortoiseConditions: null
recommendations:
horizontal:
maxReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-10-06T01:01:24Z"
value: 20
minReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-10-06T01:01:24Z"
value: 5
targetUtilizations:
- containerName: app
targetUtilization:
cpu: 75
vertical:
containerResourceRecommendation:
- RecommendedResource:
cpu: "4"
memory: 3Gi
containerName: app
targets:
deployment: ""
horizontalPodAutoscaler: tortoise-hpa-mercari
verticalPodAutoscalers:
- name: tortoise-updater-mercari
role: Updater
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
metadata:
annotations:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
tortoises.autoscaling.mercari.com/tortoise-name: mercari
name: tortoise-monitor-mercari
namespace: default
spec:
resourcePolicy:
containerPolicies:
- containerName: app
targetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
updatePolicy:
updateMode: "Off"
status:
conditions:
- lastTransitionTime: null
status: "True"
type: RecommendationProvided
recommendation:
containerRecommendations:
- containerName: app
lowerBound:
cpu: "3"
memory: 3Gi
target:
cpu: "3"
memory: 3Gi
upperBound:
cpu: "5"
memory: 5Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
metadata:
annotations:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
tortoises.autoscaling.mercari.com/tortoise-name: mercari
name: tortoise-updater-mercari
namespace: default
spec:
recommenders:
- name: tortoise-controller
resourcePolicy:
containerPolicies:
- containerName: app
targetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
updatePolicy:
updateMode: Auto
status:
recommendation:
containerRecommendations:
- containerName: app
lowerBound:
cpu: "4"
memory: 3Gi
target:
cpu: "4"
memory: 3Gi
uncappedTarget:
cpu: "4"
memory: 3Gi
upperBound:
cpu: "4"
memory: 3Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
metadata:
name: mercari-app
namespace: default
spec:
selector:
matchLabels:
app: mercari
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: mercari
spec:
containers:
- image: awesome-mercari-app-image
name: app
resources:
requests:
cpu: "4"
memory: 4Gi
status:
replicas: 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
metadata:
annotations:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
tortoises.autoscaling.mercari.com/tortoise-name: mercari
name: tortoise-hpa-mercari
namespace: default
spec:
behavior:
scaleDown:
policies:
- periodSeconds: 90
type: Percent
value: 2
selectPolicy: Max
scaleUp:
policies:
- periodSeconds: 60
type: Percent
value: 100
selectPolicy: Max
stabilizationWindowSeconds: 0
maxReplicas: 100
metrics:
- containerResource:
container: app
name: cpu
target:
averageUtilization: 50
type: Utilization
type: ContainerResource
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
status:
currentMetrics: null
desiredReplicas: 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
metadata:
name: mercari
namespace: default
spec:
resourcePolicy:
- autoscalingPolicy:
cpu: Horizontal
memory: Vertical
containerName: app
targetRefs:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
status:
conditions:
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
cpu:
quantity: "0"
updatedAt: null
memory:
quantity: "0"
updatedAt: null
recommendation:
cpu:
quantity: "0"
updatedAt: null
memory:
quantity: "0"
updatedAt: null
tortoiseConditions: null
recommendations:
horizontal:
maxReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-10-06T01:01:24Z"
value: 15
minReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-10-06T01:01:24Z"
value: 3
targetUtilizations:
- containerName: app
targetUtilization:
cpu: 50
vertical:
containerResourceRecommendation: null
targets:
deployment: ""
horizontalPodAutoscaler: tortoise-hpa-mercari
verticalPodAutoscalers:
- name: tortoise-updater-mercari
role: Updater
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: GatheringData
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu:
phase: GatheringData
memory:
phase: GatheringData
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
metadata:
annotations:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
tortoises.autoscaling.mercari.com/tortoise-name: mercari
name: tortoise-monitor-mercari
namespace: default
spec:
resourcePolicy:
containerPolicies:
- containerName: app
targetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
updatePolicy:
updateMode: "Off"
status:
conditions:
- lastTransitionTime: null
status: "True"
type: RecommendationProvided
recommendation:
containerRecommendations:
- containerName: app
lowerBound:
cpu: "3"
memory: 3Gi
target:
cpu: "3"
memory: 3Gi
upperBound:
cpu: "5"
memory: 5Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
metadata:
annotations:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
tortoises.autoscaling.mercari.com/tortoise-name: mercari
name: tortoise-updater-mercari
namespace: default
spec:
recommenders:
- name: tortoise-controller
resourcePolicy:
containerPolicies:
- containerName: app
targetRef:
apiVersion: apps/v1
kind: Deployment
name: mercari-app
updatePolicy:
updateMode: Auto
status: {}
Loading

0 comments on commit f0f81be

Please sign in to comment.