Add config for fetcher resource requests & limits (#1489)
This PR adds fetcher resource requests&limits chart setting and remove unreasonable limits value from the charts.
This commit is contained in:
@@ -43,7 +43,7 @@ func (gpm *GenericPoolManager) makePkgController(fissionClient *crd.FissionClien
|
||||
pkg := obj.(*fv1.Package)
|
||||
gpm.logger.Debug("list watch for package reported a new package addition",
|
||||
zap.String("package_name", pkg.Metadata.Name),
|
||||
zap.String("package_namepsace", pkg.Metadata.Namespace))
|
||||
zap.String("package_namespace", pkg.Metadata.Namespace))
|
||||
|
||||
// create or update role-binding for fetcher sa in env ns to be able to get the pkg contents from pkg namespace
|
||||
envNs := fissionfnNamespace
|
||||
|
||||
@@ -207,7 +207,7 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
// we can list the functions once per role-binding.
|
||||
funcList, err := fissionClient.Functions(roleBinding.Namespace).List(meta_v1.ListOptions{})
|
||||
if err != nil {
|
||||
logger.Error("error fetching environment list in namespace", zap.Error(err), zap.String("namespace", roleBinding.Namespace))
|
||||
logger.Error("error fetching function list in namespace", zap.Error(err), zap.String("namespace", roleBinding.Namespace))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ func CleanupRoleBindings(logger *zap.Logger, client *kubernetes.Clientset, fissi
|
||||
}
|
||||
}
|
||||
|
||||
// if its a package-getterr-rb, we have 2 kinds of SAs and each of them is handled differently
|
||||
// if its a package-getter-rb, we have 2 kinds of SAs and each of them is handled differently
|
||||
// else if its a secret-configmap-rb, we have only one SA which is fission-fetcher
|
||||
if roleBinding.Name == types.PackageGetterRB {
|
||||
// check if there is an env obj in saNs
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
@@ -31,46 +32,36 @@ type Config struct {
|
||||
sharedSecretPath string
|
||||
sharedCfgMapPath string
|
||||
|
||||
// dockerRegistryAuthDomain string
|
||||
// dockerRegistryUsername string
|
||||
// dockerRegistryPassword string
|
||||
|
||||
serviceAccount string
|
||||
|
||||
jaegerCollectorEndpoint string
|
||||
}
|
||||
|
||||
func getFetcherResources() (apiv1.ResourceRequirements, error) {
|
||||
mincpu, err := resource.ParseQuantity(os.Getenv("FETCHER_MINCPU"))
|
||||
if err != nil {
|
||||
return apiv1.ResourceRequirements{}, err
|
||||
resourceReqs := apiv1.ResourceRequirements{
|
||||
Requests: map[apiv1.ResourceName]resource.Quantity{},
|
||||
Limits: map[apiv1.ResourceName]resource.Quantity{},
|
||||
}
|
||||
errs := utils.MultiErrorWithFormat()
|
||||
errs = multierror.Append(errs,
|
||||
parseResources("FETCHER_MINCPU", resourceReqs.Requests, apiv1.ResourceCPU),
|
||||
parseResources("FETCHER_MINMEM", resourceReqs.Requests, apiv1.ResourceMemory),
|
||||
parseResources("FETCHER_MAXCPU", resourceReqs.Limits, apiv1.ResourceCPU),
|
||||
parseResources("FETCHER_MAXMEM", resourceReqs.Limits, apiv1.ResourceMemory),
|
||||
)
|
||||
return resourceReqs, errs.ErrorOrNil()
|
||||
}
|
||||
|
||||
minmem, err := resource.ParseQuantity(os.Getenv("FETCHER_MINMEM"))
|
||||
if err != nil {
|
||||
return apiv1.ResourceRequirements{}, err
|
||||
func parseResources(env string, resourceReqs map[apiv1.ResourceName]resource.Quantity, resName apiv1.ResourceName) error {
|
||||
val := os.Getenv(env)
|
||||
if len(val) > 0 {
|
||||
quantity, err := resource.ParseQuantity(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resourceReqs[resName] = quantity
|
||||
}
|
||||
|
||||
maxcpu, err := resource.ParseQuantity(os.Getenv("FETCHER_MAXCPU"))
|
||||
if err != nil {
|
||||
return apiv1.ResourceRequirements{}, err
|
||||
}
|
||||
|
||||
maxmem, err := resource.ParseQuantity(os.Getenv("FETCHER_MAXMEM"))
|
||||
if err != nil {
|
||||
return apiv1.ResourceRequirements{}, err
|
||||
}
|
||||
|
||||
return apiv1.ResourceRequirements{
|
||||
Requests: map[apiv1.ResourceName]resource.Quantity{
|
||||
apiv1.ResourceCPU: mincpu,
|
||||
apiv1.ResourceMemory: minmem,
|
||||
},
|
||||
Limits: map[apiv1.ResourceName]resource.Quantity{
|
||||
apiv1.ResourceCPU: maxcpu,
|
||||
apiv1.ResourceMemory: maxmem,
|
||||
},
|
||||
}, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func MakeFetcherConfig(sharedMountPath string) (*Config, error) {
|
||||
|
||||
Reference in New Issue
Block a user