Cluster-Autoscaler: add map to disable status configmap

This commit is contained in:
Maciej Pytel 2017-03-01 10:57:44 +01:00
parent 5caf10a9c5
commit 84f19c1e1e
3 changed files with 11 additions and 0 deletions

View File

@ -94,6 +94,8 @@ type AutoscalingOptions struct {
ScaleDownDelay time.Duration
// ScaleDownTrialInterval sets how often scale down possibility is check
ScaleDownTrialInterval time.Duration
// WriteStatusConfigMap tells if the status information should be written to a ConfigMap
WriteStatusConfigMap bool
}
// NewAutoscalingContext returns an autoscaling context from all the necessary parameters passed via arguments

View File

@ -265,6 +265,9 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) {
// ExitCleanUp removes status configmap.
func (a *StaticAutoscaler) ExitCleanUp() {
if !a.AutoscalingContext.WriteStatusConfigMap {
return
}
maps := a.AutoscalingContext.ClientSet.CoreV1().ConfigMaps(StatusConfigMapNamespace)
err := maps.Delete(StatusConfigMapName, &metav1.DeleteOptions{})
if err != nil {
@ -274,6 +277,9 @@ func (a *StaticAutoscaler) ExitCleanUp() {
}
func (a *StaticAutoscaler) writeStatusConfigMap() {
if !a.AutoscalingContext.WriteStatusConfigMap {
return
}
statusUpdateTime := time.Now()
status := a.ClusterStateRegistry.GetStatus(statusUpdateTime)
statusMsg := fmt.Sprintf("Cluster-autoscaler status at %v:\n%v", statusUpdateTime, status.GetReadableString())

View File

@ -95,6 +95,8 @@ var (
expanderFlag = flag.String("expander", expander.RandomExpanderName,
"Type of node group expander to be used in scale up. Available values: ["+strings.Join(expander.AvailableExpanders, ",")+"]")
writeStatusConfigMapFlag = flag.Bool("write-status-configmap", true, "Should CA write status information to a configmap")
)
func createAutoscalerOptions() core.AutoscalerOptions {
@ -117,6 +119,7 @@ func createAutoscalerOptions() core.AutoscalerOptions {
ScaleDownUnreadyTime: *scaleDownUnreadyTime,
ScaleDownUtilizationThreshold: *scaleDownUtilizationThreshold,
VerifyUnschedulablePods: *verifyUnschedulablePods,
WriteStatusConfigMap: *writeStatusConfigMapFlag,
}
configFetcherOpts := dynamic.ConfigFetcherOptions{