mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #54934 from akosiaris/master
Automatic merge from submit-queue (batch tested with PRs 54906, 54120, 54934, 54915, 54848). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Only parse ClusterCIDR, ServiceCIDR if AllocateNodeCIDRs **What this PR does / why we need it**: Avoid unnecessary spam in kube-controller-manager log if --cluster-cidr is not specified and --allocate-node-cidrs is false. Add clarification in kube-controller-manager help about that. **Release note** ```release-note Avoid unnecessary spam in kube-controller-manager log if --cluster-cidr is not specified and --allocate-node-cidrs is false. ```
This commit is contained in:
commit
9ca2bda520
@ -76,7 +76,9 @@ func startServiceController(ctx ControllerContext) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startNodeController(ctx ControllerContext) (bool, error) {
|
func startNodeController(ctx ControllerContext) (bool, error) {
|
||||||
var clusterCIDR *net.IPNet
|
var clusterCIDR *net.IPNet = nil
|
||||||
|
var serviceCIDR *net.IPNet = nil
|
||||||
|
if ctx.Options.AllocateNodeCIDRs {
|
||||||
var err error
|
var err error
|
||||||
if len(strings.TrimSpace(ctx.Options.ClusterCIDR)) != 0 {
|
if len(strings.TrimSpace(ctx.Options.ClusterCIDR)) != 0 {
|
||||||
_, clusterCIDR, err = net.ParseCIDR(ctx.Options.ClusterCIDR)
|
_, clusterCIDR, err = net.ParseCIDR(ctx.Options.ClusterCIDR)
|
||||||
@ -85,13 +87,13 @@ func startNodeController(ctx ControllerContext) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var serviceCIDR *net.IPNet
|
|
||||||
if len(strings.TrimSpace(ctx.Options.ServiceCIDR)) != 0 {
|
if len(strings.TrimSpace(ctx.Options.ServiceCIDR)) != 0 {
|
||||||
_, serviceCIDR, err = net.ParseCIDR(ctx.Options.ServiceCIDR)
|
_, serviceCIDR, err = net.ParseCIDR(ctx.Options.ServiceCIDR)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Unsuccessful parsing of service CIDR %v: %v", ctx.Options.ServiceCIDR, err)
|
glog.Warningf("Unsuccessful parsing of service CIDR %v: %v", ctx.Options.ServiceCIDR, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nodeController, err := nodecontroller.NewNodeController(
|
nodeController, err := nodecontroller.NewNodeController(
|
||||||
ctx.InformerFactory.Core().V1().Pods(),
|
ctx.InformerFactory.Core().V1().Pods(),
|
||||||
@ -124,10 +126,6 @@ func startNodeController(ctx ControllerContext) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startRouteController(ctx ControllerContext) (bool, error) {
|
func startRouteController(ctx ControllerContext) (bool, error) {
|
||||||
_, clusterCIDR, err := net.ParseCIDR(ctx.Options.ClusterCIDR)
|
|
||||||
if err != nil {
|
|
||||||
glog.Warningf("Unsuccessful parsing of cluster CIDR %v: %v", ctx.Options.ClusterCIDR, err)
|
|
||||||
}
|
|
||||||
if !ctx.Options.AllocateNodeCIDRs || !ctx.Options.ConfigureCloudRoutes {
|
if !ctx.Options.AllocateNodeCIDRs || !ctx.Options.ConfigureCloudRoutes {
|
||||||
glog.Infof("Will not configure cloud provider routes for allocate-node-cidrs: %v, configure-cloud-routes: %v.", ctx.Options.AllocateNodeCIDRs, ctx.Options.ConfigureCloudRoutes)
|
glog.Infof("Will not configure cloud provider routes for allocate-node-cidrs: %v, configure-cloud-routes: %v.", ctx.Options.AllocateNodeCIDRs, ctx.Options.ConfigureCloudRoutes)
|
||||||
return false, nil
|
return false, nil
|
||||||
@ -141,6 +139,10 @@ func startRouteController(ctx ControllerContext) (bool, error) {
|
|||||||
glog.Warning("configure-cloud-routes is set, but cloud provider does not support routes. Will not configure cloud provider routes.")
|
glog.Warning("configure-cloud-routes is set, but cloud provider does not support routes. Will not configure cloud provider routes.")
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
_, clusterCIDR, err := net.ParseCIDR(ctx.Options.ClusterCIDR)
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("Unsuccessful parsing of cluster CIDR %v: %v", ctx.Options.ClusterCIDR, err)
|
||||||
|
}
|
||||||
routeController := routecontroller.New(routes, ctx.ClientBuilder.ClientOrDie("route-controller"), ctx.InformerFactory.Core().V1().Nodes(), ctx.Options.ClusterName, clusterCIDR)
|
routeController := routecontroller.New(routes, ctx.ClientBuilder.ClientOrDie("route-controller"), ctx.InformerFactory.Core().V1().Nodes(), ctx.Options.ClusterName, clusterCIDR)
|
||||||
go routeController.Run(ctx.Stop, ctx.Options.RouteReconciliationPeriod.Duration)
|
go routeController.Run(ctx.Stop, ctx.Options.RouteReconciliationPeriod.Duration)
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -195,8 +195,8 @@ func (s *CMServer) AddFlags(fs *pflag.FlagSet, allControllers []string, disabled
|
|||||||
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
|
fs.BoolVar(&s.EnableProfiling, "profiling", true, "Enable profiling via web interface host:port/debug/pprof/")
|
||||||
fs.BoolVar(&s.EnableContentionProfiling, "contention-profiling", false, "Enable lock contention profiling, if profiling is enabled")
|
fs.BoolVar(&s.EnableContentionProfiling, "contention-profiling", false, "Enable lock contention profiling, if profiling is enabled")
|
||||||
fs.StringVar(&s.ClusterName, "cluster-name", s.ClusterName, "The instance prefix for the cluster")
|
fs.StringVar(&s.ClusterName, "cluster-name", s.ClusterName, "The instance prefix for the cluster")
|
||||||
fs.StringVar(&s.ClusterCIDR, "cluster-cidr", s.ClusterCIDR, "CIDR Range for Pods in cluster.")
|
fs.StringVar(&s.ClusterCIDR, "cluster-cidr", s.ClusterCIDR, "CIDR Range for Pods in cluster. Requires --allocate-node-cidrs to be true")
|
||||||
fs.StringVar(&s.ServiceCIDR, "service-cluster-ip-range", s.ServiceCIDR, "CIDR Range for Services in cluster.")
|
fs.StringVar(&s.ServiceCIDR, "service-cluster-ip-range", s.ServiceCIDR, "CIDR Range for Services in cluster. Requires --allocate-node-cidrs to be true")
|
||||||
fs.Int32Var(&s.NodeCIDRMaskSize, "node-cidr-mask-size", s.NodeCIDRMaskSize, "Mask size for node cidr in cluster.")
|
fs.Int32Var(&s.NodeCIDRMaskSize, "node-cidr-mask-size", s.NodeCIDRMaskSize, "Mask size for node cidr in cluster.")
|
||||||
fs.BoolVar(&s.AllocateNodeCIDRs, "allocate-node-cidrs", false,
|
fs.BoolVar(&s.AllocateNodeCIDRs, "allocate-node-cidrs", false,
|
||||||
"Should CIDRs for Pods be allocated and set on the cloud provider.")
|
"Should CIDRs for Pods be allocated and set on the cloud provider.")
|
||||||
|
Loading…
Reference in New Issue
Block a user