This repo is dedicated to post processes that run after the our k8s vpa makes it's recommendation.
To add a post process function, make a go package in a new directory inside the processes
directory. In order to be added the post processor list, the given function must be structured as follows:
import (
v1 "github.com/ezoic/wphosting-vpa-autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
"github.com/ezoic/wphosting-vpa-autoscaler/vertical-pod-autoscaler/pkg/recommender/model"
)
func DoSomeProcess(vpa *model.Vpa, recommendation *v1.RecommendedPodResources, policy *v1.PodResourcePolicy) *v1.RecommendedPodResources {
// some code that does stuff
return newRecommendation // or just return the given one if you just wanna log some stuff
}
After making you're new package with your new process function, go ahead and slap that in the processes.go
file as part of the PostProcessList array:
var PostProcessList = postProcessList{
email.Process,
log.Process,
your.ProcessFunction,
}
Now run a go mod tidy
and you should be all set.
This repo is used in our wphosting-vpa-autoscaler repo which is a fork of the kubernetes vpa. Here we can make customizations to the vpa recommender and add post processors.