defaults.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 v1alpha1
  14. import (
  15. "time"
  16. metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  17. "k8s.io/apimachinery/pkg/runtime"
  18. kubectrlmgrconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/apis/config/v1alpha1"
  19. serviceconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/service/config/v1alpha1"
  20. )
  21. func addDefaultingFuncs(scheme *runtime.Scheme) error {
  22. return RegisterDefaults(scheme)
  23. }
  24. func SetDefaults_CloudControllerManagerConfiguration(obj *CloudControllerManagerConfiguration) {
  25. zero := metav1.Duration{}
  26. if obj.NodeStatusUpdateFrequency == zero {
  27. obj.NodeStatusUpdateFrequency = metav1.Duration{Duration: 5 * time.Minute}
  28. }
  29. // These defaults override the recommended defaults from the apimachineryconfigv1alpha1 package that are applied automatically
  30. // These client-connection defaults are specific to the cloud-controller-manager
  31. if obj.Generic.ClientConnection.QPS == 0 {
  32. obj.Generic.ClientConnection.QPS = 20
  33. }
  34. if obj.Generic.ClientConnection.Burst == 0 {
  35. obj.Generic.ClientConnection.Burst = 30
  36. }
  37. // Use the default RecommendedDefaultGenericControllerManagerConfiguration options
  38. kubectrlmgrconfigv1alpha1.RecommendedDefaultGenericControllerManagerConfiguration(&obj.Generic)
  39. // Use the default RecommendedDefaultServiceControllerConfiguration options
  40. serviceconfigv1alpha1.RecommendedDefaultServiceControllerConfiguration(&obj.ServiceController)
  41. }