interfaces.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Copyright 2015 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 bandwidth
  14. import "k8s.io/apimachinery/pkg/api/resource"
  15. // Shaper is designed so that the shaper structs created
  16. // satisfy the Shaper interface.
  17. type Shaper interface {
  18. // Limit the bandwidth for a particular CIDR on a particular interface
  19. // * ingress and egress are in bits/second
  20. // * cidr is expected to be a valid network CIDR (e.g. '1.2.3.4/32' or '10.20.0.1/16')
  21. // 'egress' bandwidth limit applies to all packets on the interface whose source matches 'cidr'
  22. // 'ingress' bandwidth limit applies to all packets on the interface whose destination matches 'cidr'
  23. // Limits are aggregate limits for the CIDR, not per IP address. CIDRs must be unique, but can be overlapping, traffic
  24. // that matches multiple CIDRs counts against all limits.
  25. Limit(cidr string, egress, ingress *resource.Quantity) error
  26. // Remove a bandwidth limit for a particular CIDR on a particular network interface
  27. Reset(cidr string) error
  28. // Reconcile the interface managed by this shaper with the state on the ground.
  29. ReconcileInterface() error
  30. // Reconcile a CIDR managed by this shaper with the state on the ground
  31. ReconcileCIDR(cidr string, egress, ingress *resource.Quantity) error
  32. // GetCIDRs returns the set of CIDRs that are being managed by this shaper
  33. GetCIDRs() ([]string, error)
  34. }