Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Kube OVN
Commits
54acd0c3
Commit
54acd0c3
authored
4 years ago
by
Mengxin Liu
Committed by
oilbeater
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
feat: support gw qos
parent
24e6435e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
pkg/daemon/controller.go
+1
-1
pkg/daemon/controller.go
pkg/daemon/gateway.go
+17
-0
pkg/daemon/gateway.go
pkg/daemon/ovs.go
+1
-1
pkg/daemon/ovs.go
pkg/ovs/ovs-vsctl.go
+5
-5
pkg/ovs/ovs-vsctl.go
with
24 additions
and
7 deletions
+24
-7
pkg/daemon/controller.go
+
1
-
1
View file @
54acd0c3
...
...
@@ -342,7 +342,7 @@ func (c *Controller) handlePod(key string) error {
return
err
}
return
ovs
.
Set
Pod
Bandwidth
(
pod
.
Name
,
pod
.
Namespace
,
pod
.
Annotations
[
util
.
EgressRateAnnotation
],
pod
.
Annotations
[
util
.
IngressRateAnnotation
])
return
ovs
.
Set
Interface
Bandwidth
(
fmt
.
Sprintf
(
"%s.%s"
,
pod
.
Name
,
pod
.
Namespace
)
,
pod
.
Annotations
[
util
.
EgressRateAnnotation
],
pod
.
Annotations
[
util
.
IngressRateAnnotation
])
}
// Run starts controller
...
...
This diff is collapsed.
Click to expand it.
pkg/daemon/gateway.go
+
17
-
0
View file @
54acd0c3
...
...
@@ -3,8 +3,10 @@ package daemon
import
(
"fmt"
kubeovnv1
"github.com/alauda/kube-ovn/pkg/apis/kubeovn/v1"
"github.com/alauda/kube-ovn/pkg/ovs"
"github.com/alauda/kube-ovn/pkg/util"
"github.com/projectcalico/felix/ipsets"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog"
"net"
...
...
@@ -131,6 +133,21 @@ func (c *Controller) runGateway() {
}
}
}
if
err
:=
c
.
setGatewayBandwidth
();
err
!=
nil
{
klog
.
Errorf
(
"failed to set gw bandwidth, %v"
,
err
)
}
}
func
(
c
*
Controller
)
setGatewayBandwidth
()
error
{
node
,
err
:=
c
.
config
.
KubeClient
.
CoreV1
()
.
Nodes
()
.
Get
(
c
.
config
.
NodeName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
klog
.
Errorf
(
"failed to get node, %v"
,
err
)
return
err
}
ingress
,
egress
:=
node
.
Annotations
[
util
.
IngressRateAnnotation
],
node
.
Annotations
[
util
.
EgressRateAnnotation
]
ifaceId
:=
fmt
.
Sprintf
(
"node-%s"
,
c
.
config
.
NodeName
)
return
ovs
.
SetInterfaceBandwidth
(
ifaceId
,
ingress
,
egress
)
}
func
(
c
*
Controller
)
getLocalPodIPsNeedNAT
(
protocol
string
)
([]
string
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/daemon/ovs.go
+
1
-
1
View file @
54acd0c3
...
...
@@ -53,7 +53,7 @@ func (csh cniServerHandler) configureNic(podName, podNamespace, netns, container
if
err
=
configureHostNic
(
hostNicName
,
vlanID
,
macAddr
);
err
!=
nil
{
return
err
}
if
err
=
ovs
.
Set
Pod
Bandwidth
(
podName
,
podNamespace
,
ingress
,
egress
);
err
!=
nil
{
if
err
=
ovs
.
Set
Interface
Bandwidth
(
fmt
.
Sprintf
(
"%s.%s"
,
podName
,
podNamespace
)
,
ingress
,
egress
);
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
pkg/ovs/ovs-vsctl.go
+
5
-
5
View file @
54acd0c3
...
...
@@ -91,11 +91,11 @@ func ClearPodBandwidth(podName, podNamespace string) error {
return
nil
}
// Set
Pod
Bandwidth set ingress/egress qos for given pod
func
Set
Pod
Bandwidth
(
podName
,
podNamesp
ace
,
ingress
,
egress
string
)
error
{
// Set
Interface
Bandwidth set ingress/egress qos for given pod
func
Set
Interface
Bandwidth
(
if
ace
,
ingress
,
egress
string
)
error
{
ingressMPS
,
_
:=
strconv
.
Atoi
(
ingress
)
ingressKPS
:=
ingressMPS
*
1000
interfaceList
,
err
:=
ovsFind
(
"interface"
,
"name"
,
fmt
.
Sprintf
(
"external-ids:iface-id=%s
.%s"
,
podName
,
podNamesp
ace
))
interfaceList
,
err
:=
ovsFind
(
"interface"
,
"name"
,
fmt
.
Sprintf
(
"external-ids:iface-id=%s
"
,
if
ace
))
if
err
!=
nil
{
return
err
}
...
...
@@ -110,13 +110,13 @@ func SetPodBandwidth(podName, podNamespace, ingress, egress string) error {
egressMPS
,
_
:=
strconv
.
Atoi
(
egress
)
egressBPS
:=
egressMPS
*
1000
*
1000
qosList
,
err
:=
ovsFind
(
"qos"
,
"_uuid"
,
fmt
.
Sprintf
(
"external-ids:iface-id=%s
.%s"
,
podName
,
podNamesp
ace
))
qosList
,
err
:=
ovsFind
(
"qos"
,
"_uuid"
,
fmt
.
Sprintf
(
"external-ids:iface-id=%s
"
,
if
ace
))
if
err
!=
nil
{
return
err
}
if
egressBPS
>
0
{
if
len
(
qosList
)
==
0
{
qos
,
err
:=
ovsCreate
(
"qos"
,
"type=linux-htb"
,
fmt
.
Sprintf
(
"other-config:max-rate=%d"
,
egressBPS
),
fmt
.
Sprintf
(
"external-ids:iface-id=%s
.%s"
,
podName
,
podNamesp
ace
))
qos
,
err
:=
ovsCreate
(
"qos"
,
"type=linux-htb"
,
fmt
.
Sprintf
(
"other-config:max-rate=%d"
,
egressBPS
),
fmt
.
Sprintf
(
"external-ids:iface-id=%s
"
,
if
ace
))
if
err
!=
nil
{
return
err
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help