mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-08 14:29:45 +00:00
Extend resyncPeriods in controllers in production.
This commit is contained in:
@@ -25,6 +25,7 @@ package app
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
@@ -78,6 +79,7 @@ type CMServer struct {
|
||||
TerminatedPodGCThreshold int
|
||||
HorizontalPodAutoscalerSyncPeriod time.Duration
|
||||
DeploymentControllerSyncPeriod time.Duration
|
||||
MinResyncPeriod time.Duration
|
||||
RegisterRetryCount int
|
||||
NodeMonitorGracePeriod time.Duration
|
||||
NodeStartupGracePeriod time.Duration
|
||||
@@ -115,6 +117,7 @@ func NewCMServer() *CMServer {
|
||||
PVClaimBinderSyncPeriod: 10 * time.Second,
|
||||
HorizontalPodAutoscalerSyncPeriod: 30 * time.Second,
|
||||
DeploymentControllerSyncPeriod: 30 * time.Second,
|
||||
MinResyncPeriod: 12 * time.Hour,
|
||||
RegisterRetryCount: 10,
|
||||
PodEvictionTimeout: 5 * time.Minute,
|
||||
ClusterName: "kubernetes",
|
||||
@@ -157,6 +160,7 @@ func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.DurationVar(&s.ResourceQuotaSyncPeriod, "resource-quota-sync-period", s.ResourceQuotaSyncPeriod, "The period for syncing quota usage status in the system")
|
||||
fs.DurationVar(&s.NamespaceSyncPeriod, "namespace-sync-period", s.NamespaceSyncPeriod, "The period for syncing namespace life-cycle updates")
|
||||
fs.DurationVar(&s.PVClaimBinderSyncPeriod, "pvclaimbinder-sync-period", s.PVClaimBinderSyncPeriod, "The period for syncing persistent volumes and persistent volume claims")
|
||||
fs.DurationVar(&s.MinResyncPeriod, "min-resync-period", s.MinResyncPeriod, "The resync period in reflectors will be random between MinResyncPeriod and 2*MinResyncPeriod")
|
||||
fs.StringVar(&s.VolumeConfigFlags.PersistentVolumeRecyclerPodTemplateFilePathNFS, "pv-recycler-pod-template-filepath-nfs", s.VolumeConfigFlags.PersistentVolumeRecyclerPodTemplateFilePathNFS, "The file path to a pod definition used as a template for NFS persistent volume recycling")
|
||||
fs.IntVar(&s.VolumeConfigFlags.PersistentVolumeRecyclerMinimumTimeoutNFS, "pv-recycler-minimum-timeout-nfs", s.VolumeConfigFlags.PersistentVolumeRecyclerMinimumTimeoutNFS, "The minimum ActiveDeadlineSeconds to use for an NFS Recycler pod")
|
||||
fs.IntVar(&s.VolumeConfigFlags.PersistentVolumeRecyclerIncrementTimeoutNFS, "pv-recycler-increment-timeout-nfs", s.VolumeConfigFlags.PersistentVolumeRecyclerIncrementTimeoutNFS, "the increment of time added per Gi to ActiveDeadlineSeconds for an NFS scrubber pod")
|
||||
@@ -191,6 +195,11 @@ func (s *CMServer) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.BoolVar(&s.EnableExperimental, "enable-experimental", s.EnableExperimental, "Enables experimental controllers (requires enabling experimental API on apiserver).")
|
||||
}
|
||||
|
||||
func (s *CMServer) resyncPeriod() time.Duration {
|
||||
factor := rand.Float64() + 1
|
||||
return time.Duration(float64(s.MinResyncPeriod.Nanoseconds()) * factor)
|
||||
}
|
||||
|
||||
// Run runs the CMServer. This should never exit.
|
||||
func (s *CMServer) Run(_ []string) error {
|
||||
if s.Kubeconfig == "" && s.Master == "" {
|
||||
@@ -231,14 +240,14 @@ func (s *CMServer) Run(_ []string) error {
|
||||
glog.Fatal(server.ListenAndServe())
|
||||
}()
|
||||
|
||||
endpoints := endpointcontroller.NewEndpointController(kubeClient)
|
||||
go endpoints.Run(s.ConcurrentEndpointSyncs, util.NeverStop)
|
||||
go endpointcontroller.NewEndpointController(kubeClient, s.resyncPeriod).
|
||||
Run(s.ConcurrentEndpointSyncs, util.NeverStop)
|
||||
|
||||
controllerManager := replicationControllerPkg.NewReplicationManager(kubeClient, replicationControllerPkg.BurstReplicas)
|
||||
go controllerManager.Run(s.ConcurrentRCSyncs, util.NeverStop)
|
||||
go replicationControllerPkg.NewReplicationManager(kubeClient, s.resyncPeriod, replicationControllerPkg.BurstReplicas).
|
||||
Run(s.ConcurrentRCSyncs, util.NeverStop)
|
||||
|
||||
if s.TerminatedPodGCThreshold > 0 {
|
||||
go gc.New(kubeClient, s.TerminatedPodGCThreshold).
|
||||
go gc.New(kubeClient, s.resyncPeriod, s.TerminatedPodGCThreshold).
|
||||
Run(util.NeverStop)
|
||||
}
|
||||
|
||||
@@ -269,16 +278,15 @@ func (s *CMServer) Run(_ []string) error {
|
||||
}
|
||||
}
|
||||
|
||||
resourceQuotaController := resourcequotacontroller.NewResourceQuotaController(kubeClient)
|
||||
resourceQuotaController.Run(s.ResourceQuotaSyncPeriod)
|
||||
resourcequotacontroller.NewResourceQuotaController(kubeClient).Run(s.ResourceQuotaSyncPeriod)
|
||||
|
||||
namespacecontroller.NewNamespaceController(kubeClient, s.EnableExperimental, s.NamespaceSyncPeriod).Run()
|
||||
|
||||
if s.EnableExperimental {
|
||||
go daemon.NewDaemonSetsController(kubeClient).
|
||||
go daemon.NewDaemonSetsController(kubeClient, s.resyncPeriod).
|
||||
Run(s.ConcurrentDSCSyncs, util.NeverStop)
|
||||
|
||||
go job.NewJobController(kubeClient).
|
||||
go job.NewJobController(kubeClient, s.resyncPeriod).
|
||||
Run(s.ConcurrentJobSyncs, util.NeverStop)
|
||||
|
||||
podautoscaler.NewHorizontalController(kubeClient, metrics.NewHeapsterMetricsClient(kubeClient)).
|
||||
|
Reference in New Issue
Block a user