mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 16:06:51 +00:00
Implement network plugin capabilities hook and shaping capability
Allow network plugins to declare that they handle shaping and that Kuberenetes should not. Will be first used by openshift-sdn which handles shaping through OVS, but this triggers a warning when kubelet notices the bandwidth annotations.
This commit is contained in:
@@ -1798,6 +1798,9 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, podStatus *kubecont
|
||||
return err
|
||||
}
|
||||
|
||||
if !kl.shapingEnabled() {
|
||||
return nil
|
||||
}
|
||||
ingress, egress, err := extractBandwidthResources(pod)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -2734,11 +2737,14 @@ func (kl *Kubelet) reconcileCBR0(podCIDR string) error {
|
||||
if err := ensureCbr0(cidr, kl.hairpinMode == componentconfig.PromiscuousBridge, kl.babysitDaemons); err != nil {
|
||||
return err
|
||||
}
|
||||
if kl.shaper == nil {
|
||||
glog.V(5).Info("Shaper is nil, creating")
|
||||
kl.shaper = bandwidth.NewTCShaper("cbr0")
|
||||
if kl.shapingEnabled() {
|
||||
if kl.shaper == nil {
|
||||
glog.V(5).Info("Shaper is nil, creating")
|
||||
kl.shaper = bandwidth.NewTCShaper("cbr0")
|
||||
}
|
||||
return kl.shaper.ReconcileInterface()
|
||||
}
|
||||
return kl.shaper.ReconcileInterface()
|
||||
return nil
|
||||
}
|
||||
|
||||
// updateNodeStatus updates node status to master with retries.
|
||||
@@ -3594,6 +3600,15 @@ func (kl *Kubelet) updatePodCIDR(cidr string) {
|
||||
kl.networkPlugin.Event(network.NET_PLUGIN_EVENT_POD_CIDR_CHANGE, details)
|
||||
}
|
||||
}
|
||||
|
||||
func (kl *Kubelet) shapingEnabled() bool {
|
||||
// Disable shaping if a network plugin is defined and supports shaping
|
||||
if kl.networkPlugin != nil && kl.networkPlugin.Capabilities().Has(network.NET_PLUGIN_CAPABILITY_SHAPING) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (kl *Kubelet) GetNodeConfig() cm.NodeConfig {
|
||||
return kl.containerManager.GetNodeConfig()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user