Skip to content

Commit

Permalink
add autoscaling examples
Browse files Browse the repository at this point in the history
Signed-off-by: ericsyh <[email protected]>
  • Loading branch information
ericsyh committed Oct 10, 2024
1 parent 1078502 commit cd358fa
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
59 changes: 59 additions & 0 deletions examples/sn-platform/autoscaling-custom-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
broker:
autoScaling:
enabled: true
minReplicas: 1
maxReplicas: 4
# Deploy the https://prometheus.io/ and https://github.com/kubernetes-sigs/prometheus-adapter to support custom metrics.
# Refer the prometheus.-adapter.yaml how to setup the custom metrics.
metrics:
- pods:
metric:
name: cpu_usage
target:
averageValue: "75"
type: AverageValue
type: Pods
- pods:
metric:
name: network_in_rate_kb
target:
averageValue: "204800"
type: AverageValue
type: Pods
- pods:
metric:
name: network_out_rate_kb
target:
averageValue: "204800"
type: AverageValue
type: Pods

bookkeeper:
autoScaling:
enabled: true
minReplicas: 1
maxReplicas: 4
# Deploy the https://prometheus.io/ and https://github.com/kubernetes-sigs/prometheus-adapter to support custom metrics.
# Refer the prometheus.-adapter.yaml how to setup the custom metrics.
metrics:
- pods:
metric:
name: cpu_usage
target:
averageValue: "75"
type: AverageValue
type: Pods
- pods:
metric:
name: network_in_rate_kb
target:
averageValue: "204800"
type: AverageValue
type: Pods
- pods:
metric:
name: network_out_rate_kb
target:
averageValue: "204800"
type: AverageValue
type: Pods
29 changes: 29 additions & 0 deletions examples/sn-platform/autoscaling-resource-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
broker:
autoScaling:
enabled: true
minReplicas: 1
maxReplicas: 4
# Deploy the https://github.com/kubernetes-sigs/metrics-server to support resource metrics.
# Metrics server supports the cpu and memory PodMetrics.
metrics:
type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70

bookkeeper:
autoScaling:
enabled: true
minReplicas: 1
maxReplicas: 4
# Deploy the https://github.com/kubernetes-sigs/metrics-server to support resource metrics.
# Metrics server supports the cpu and memory PodMetrics.
metrics:
type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
79 changes: 79 additions & 0 deletions examples/sn-platform/prometheus.-adapter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
prometheus:
url: http://prometheus-server.monitor.svc
port: 80
listenPort: 8443
rules:
default: false
custom:
- seriesQuery: '{namespace!="",__name__!~"^container_.*"}'
resources:
template: "<<.Resource>>"
name:
matches: "^(.*)_total"
as: ""
metricsQuery: |
sum by (<<.GroupBy>>) (
irate (
<<.Series>>{<<.LabelMatchers>>}[1m]
)
)
- seriesQuery: 'container_cpu_usage_seconds_total{namespace!~"(sn-system|kube-system|olm|cert-manager)"}'
seriesFilters: []
resources:
overrides:
pod:
resource: pod
namespace:
resource: namespace
name:
matches: "container_cpu_usage_seconds_total"
as: "cpu_usage"
metricsQuery: sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>}[5m])) by (<<.GroupBy>>) / (sum(container_spec_cpu_shares{<<.LabelMatchers>>}/1000) by (<<.GroupBy>>)) * 100
- seriesQuery: 'container_network_receive_bytes_total{namespace!~"(sn-system|kube-system|olm|cert-manager)"}'
seriesFilters: []
resources:
overrides:
pod:
resource: pod
namespace:
resource: namespace
name:
matches: "container_network_receive_bytes_total"
as: "network_in_rate_kb"
metricsQuery: rate(container_network_receive_bytes_total{<<.LabelMatchers>>}[5m]) / 1024
- seriesQuery: 'container_network_transmit_bytes_total{namespace!~"(sn-system|kube-system|olm|cert-manager)"}'
seriesFilters: []
resources:
overrides:
pod:
resource: pod
namespace:
resource: namespace
name:
matches: "container_network_transmit_bytes_total"
as: "network_out_rate_kb"
metricsQuery: rate(container_network_transmit_bytes_total{<<.LabelMatchers>>}[5m]) / 1024
- seriesQuery: 'container_fs_reads_bytes_total{namespace!~"(sn-system|kube-system|olm|cert-manager)"}'
seriesFilters: []
resources:
overrides:
pod:
resource: pod
namespace:
resource: namespace
name:
matches: "container_fs_reads_bytes_total"
as: "disk_read_rate_kb"
metricsQuery: sum(rate(container_fs_reads_bytes_total{<<.LabelMatchers>>}[5m])) by (<<.GroupBy>>) / 1024
- seriesQuery: 'container_fs_writes_bytes_total{namespace!~"(sn-system|kube-system|olm|cert-manager)"}'
seriesFilters: []
resources:
overrides:
pod:
resource: pod
namespace:
resource: namespace
name:
matches: "container_fs_writes_bytes_total"
as: "disk_write_rate_kb"
metricsQuery: sum(rate(container_fs_writes_bytes_total{<<.LabelMatchers>>}[5m])) by (<<.GroupBy>>) / 1024

0 comments on commit cd358fa

Please sign in to comment.