mercari / tortoise

Tortoise: Shell-Shockingly-Good Kubernetes Autoscaling
MIT License
316 stars 14 forks source link

How to change GatheringDataPeriodType #408

Closed e-volusian closed 1 week ago

e-volusian commented 1 week ago

I'm testing Tortoise because it looks promising. In order to accelerate the testing, I'm trying to figure out how to change the GatheringDataPeriodType from weekly to daily, so I can see results more quickly in a dev cluster.

It's not clear to me how or where to make that change. I tried modifying pkg/config/config.go, uninstalling, rebuilding, reinstalling, redeploying, but every new tortoise I create will always say:

It will take 1 week to finish gathering data and then tortoise starts to work actually

Can anybody help me out with the correct process?

Also, can this value be set at the workload level?

sanposhiho commented 1 week ago

The cluster admin can set the global configurations via the configuration file, and the configuration file is passed via --config flag.

You have to create a config file with GatheringDataPeriodType and specify the path via --config flag. https://github.com/mercari/tortoise/blob/main/docs/admin-guide.md

sanposhiho commented 1 week ago

Also, can this value be set at the workload level?

No, unfortunately this is (only) a global parameter.

e-volusian commented 1 week ago

Thanks for your answer. It works (not sure how I missed that).

Just needed to either modify file:

config/manager/controller_manager_config.yaml

to include the GatheringDataPeriodType as a top-level key before installation:

apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
kind: ControllerManagerConfig
health:
  healthProbeBindAddress: :8081
metrics:
  bindAddress: 127.0.0.1:8080
webhook:
  port: 9443
leaderElection:
  leaderElect: true
  resourceName: 76c4d78a.mercari.com
GatheringDataPeriodType: daily

or edit the configmap in place after installation:

kubectl edit cm -n tortoise-system tortoise-manager-config

Then:

$ kubectl get cm -n tortoise-system tortoise-manager-config --output yaml | grep PeriodType
    GatheringDataPeriodType: daily
$ kubectl describe -n $MY_NAMESPACE tortoise.autoscaling.mercari.com/default-tortoise | tail

# Tortoise is initialized and starts to gather data to make recommendations. 
# It will take 1 day to finish gathering data and then tortoise starts to work actually

Thanks again!