nodelifecyclecontroller.go 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package options
  14. import (
  15. "github.com/spf13/pflag"
  16. nodelifecycleconfig "k8s.io/kubernetes/pkg/controller/nodelifecycle/config"
  17. )
  18. // NodeLifecycleControllerOptions holds the NodeLifecycleController options.
  19. type NodeLifecycleControllerOptions struct {
  20. *nodelifecycleconfig.NodeLifecycleControllerConfiguration
  21. }
  22. // AddFlags adds flags related to NodeLifecycleController for controller manager to the specified FlagSet.
  23. func (o *NodeLifecycleControllerOptions) AddFlags(fs *pflag.FlagSet) {
  24. if o == nil {
  25. return
  26. }
  27. fs.DurationVar(&o.NodeStartupGracePeriod.Duration, "node-startup-grace-period", o.NodeStartupGracePeriod.Duration,
  28. "Amount of time which we allow starting Node to be unresponsive before marking it unhealthy.")
  29. fs.DurationVar(&o.NodeMonitorGracePeriod.Duration, "node-monitor-grace-period", o.NodeMonitorGracePeriod.Duration,
  30. "Amount of time which we allow running Node to be unresponsive before marking it unhealthy. "+
  31. "Must be N times more than kubelet's nodeStatusUpdateFrequency, "+
  32. "where N means number of retries allowed for kubelet to post node status.")
  33. fs.DurationVar(&o.PodEvictionTimeout.Duration, "pod-eviction-timeout", o.PodEvictionTimeout.Duration, "The grace period for deleting pods on failed nodes.")
  34. fs.Float32Var(&o.NodeEvictionRate, "node-eviction-rate", 0.1, "Number of nodes per second on which pods are deleted in case of node failure when a zone is healthy (see --unhealthy-zone-threshold for definition of healthy/unhealthy). Zone refers to entire cluster in non-multizone clusters.")
  35. fs.Float32Var(&o.SecondaryNodeEvictionRate, "secondary-node-eviction-rate", 0.01, "Number of nodes per second on which pods are deleted in case of node failure when a zone is unhealthy (see --unhealthy-zone-threshold for definition of healthy/unhealthy). Zone refers to entire cluster in non-multizone clusters. This value is implicitly overridden to 0 if the cluster size is smaller than --large-cluster-size-threshold.")
  36. fs.Int32Var(&o.LargeClusterSizeThreshold, "large-cluster-size-threshold", 50, "Number of nodes from which NodeController treats the cluster as large for the eviction logic purposes. --secondary-node-eviction-rate is implicitly overridden to 0 for clusters this size or smaller.")
  37. fs.Float32Var(&o.UnhealthyZoneThreshold, "unhealthy-zone-threshold", 0.55, "Fraction of Nodes in a zone which needs to be not Ready (minimum 3) for zone to be treated as unhealthy. ")
  38. fs.BoolVar(&o.EnableTaintManager, "enable-taint-manager", o.EnableTaintManager, "WARNING: Beta feature. If set to true enables NoExecute Taints and will evict all not-tolerating Pod running on Nodes tainted with this kind of Taints.")
  39. }
  40. // ApplyTo fills up NodeLifecycleController config with options.
  41. func (o *NodeLifecycleControllerOptions) ApplyTo(cfg *nodelifecycleconfig.NodeLifecycleControllerConfiguration) error {
  42. if o == nil {
  43. return nil
  44. }
  45. cfg.EnableTaintManager = o.EnableTaintManager
  46. cfg.NodeStartupGracePeriod = o.NodeStartupGracePeriod
  47. cfg.NodeMonitorGracePeriod = o.NodeMonitorGracePeriod
  48. cfg.PodEvictionTimeout = o.PodEvictionTimeout
  49. cfg.NodeEvictionRate = o.NodeEvictionRate
  50. cfg.SecondaryNodeEvictionRate = o.SecondaryNodeEvictionRate
  51. cfg.LargeClusterSizeThreshold = o.LargeClusterSizeThreshold
  52. cfg.UnhealthyZoneThreshold = o.UnhealthyZoneThreshold
  53. return nil
  54. }
  55. // Validate checks validation of NodeLifecycleControllerOptions.
  56. func (o *NodeLifecycleControllerOptions) Validate() []error {
  57. if o == nil {
  58. return nil
  59. }
  60. errs := []error{}
  61. return errs
  62. }