Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
710fb4e4
Commit
710fb4e4
authored
Jun 24, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add iptables rule for MASQUERADE for egress
parent
6ddfa512
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
4 deletions
+23
-4
container_bridge.go
pkg/kubelet/container_bridge.go
+16
-1
kubelet.go
pkg/kubelet/kubelet.go
+4
-0
status_manager.go
pkg/kubelet/status_manager.go
+2
-2
util.go
pkg/util/util.go
+1
-1
No files found.
pkg/kubelet/container_bridge.go
View file @
710fb4e4
...
@@ -39,7 +39,7 @@ func createCBR0(wantCIDR *net.IPNet) error {
...
@@ -39,7 +39,7 @@ func createCBR0(wantCIDR *net.IPNet) error {
glog
.
Error
(
err
)
glog
.
Error
(
err
)
return
err
return
err
}
}
if
err
:=
exec
.
Command
(
"ip"
,
"link"
,
"set"
,
"dev"
,
"cbr0"
,
"up"
)
.
Run
();
err
!=
nil
{
if
err
:=
exec
.
Command
(
"ip"
,
"link"
,
"set"
,
"dev"
,
"cbr0"
,
"
mtu"
,
"1460"
,
"
up"
)
.
Run
();
err
!=
nil
{
glog
.
Error
(
err
)
glog
.
Error
(
err
)
return
err
return
err
}
}
...
@@ -117,3 +117,18 @@ func cbr0CidrCorrect(wantCIDR *net.IPNet) bool {
...
@@ -117,3 +117,18 @@ func cbr0CidrCorrect(wantCIDR *net.IPNet) bool {
glog
.
V
(
5
)
.
Infof
(
"Want cbr0 CIDR: %s, have cbr0 CIDR: %s"
,
wantCIDR
,
cbr0CIDR
)
glog
.
V
(
5
)
.
Infof
(
"Want cbr0 CIDR: %s, have cbr0 CIDR: %s"
,
wantCIDR
,
cbr0CIDR
)
return
wantCIDR
.
IP
.
Equal
(
cbr0IP
)
&&
bytes
.
Equal
(
wantCIDR
.
Mask
,
cbr0CIDR
.
Mask
)
return
wantCIDR
.
IP
.
Equal
(
cbr0IP
)
&&
bytes
.
Equal
(
wantCIDR
.
Mask
,
cbr0CIDR
.
Mask
)
}
}
// TODO(dawnchen): Using pkg/util/iptables
func
ensureIPTablesMasqRule
()
error
{
// Check if the MASQUERADE rule exist or not
if
err
:=
exec
.
Command
(
"iptables"
,
"-t"
,
"nat"
,
"-C"
,
"POSTROUTING"
,
"-o"
,
"eth0"
,
"-j"
,
"MASQUERADE"
,
"!"
,
"-d"
,
"10.0.0.0/8"
)
.
Run
();
err
==
nil
{
// The MASQUERADE rule exists
return
nil
}
glog
.
Infof
(
"MASQUERADE rule doesn't exist, recreate it"
)
if
err
:=
exec
.
Command
(
"iptables"
,
"-t"
,
"nat"
,
"-A"
,
"POSTROUTING"
,
"-o"
,
"eth0"
,
"-j"
,
"MASQUERADE"
,
"!"
,
"-d"
,
"10.0.0.0/8"
)
.
Run
();
err
!=
nil
{
return
err
}
return
nil
}
pkg/kubelet/kubelet.go
View file @
710fb4e4
...
@@ -1918,6 +1918,10 @@ func (kl *Kubelet) syncNetworkStatus() {
...
@@ -1918,6 +1918,10 @@ func (kl *Kubelet) syncNetworkStatus() {
networkConfigured
:=
true
networkConfigured
:=
true
if
kl
.
configureCBR0
{
if
kl
.
configureCBR0
{
if
err
:=
ensureIPTablesMasqRule
();
err
!=
nil
{
networkConfigured
=
false
glog
.
Errorf
(
"Error on adding ip table rules: %v"
,
err
)
}
if
len
(
kl
.
podCIDR
)
==
0
{
if
len
(
kl
.
podCIDR
)
==
0
{
networkConfigured
=
false
networkConfigured
=
false
}
else
if
err
:=
kl
.
reconcileCBR0
(
kl
.
podCIDR
);
err
!=
nil
{
}
else
if
err
:=
kl
.
reconcileCBR0
(
kl
.
podCIDR
);
err
!=
nil
{
...
...
pkg/kubelet/status_manager.go
View file @
710fb4e4
...
@@ -17,7 +17,6 @@ limitations under the License.
...
@@ -17,7 +17,6 @@ limitations under the License.
package
kubelet
package
kubelet
import
(
import
(
"errors"
"fmt"
"fmt"
"reflect"
"reflect"
"sort"
"sort"
...
@@ -144,7 +143,8 @@ func (s *statusManager) RemoveOrphanedStatuses(podFullNames map[string]bool) {
...
@@ -144,7 +143,8 @@ func (s *statusManager) RemoveOrphanedStatuses(podFullNames map[string]bool) {
// syncBatch syncs pods statuses with the apiserver.
// syncBatch syncs pods statuses with the apiserver.
func
(
s
*
statusManager
)
syncBatch
()
error
{
func
(
s
*
statusManager
)
syncBatch
()
error
{
if
s
.
kubeClient
==
nil
{
if
s
.
kubeClient
==
nil
{
return
errors
.
New
(
"Kubernetes client is nil, skipping pod status updates"
)
glog
.
V
(
4
)
.
Infof
(
"Kubernetes client is nil, skipping pod status updates"
)
return
nil
}
}
syncRequest
:=
<-
s
.
podStatusChannel
syncRequest
:=
<-
s
.
podStatusChannel
pod
:=
syncRequest
.
pod
pod
:=
syncRequest
.
pod
...
...
pkg/util/util.go
View file @
710fb4e4
...
@@ -205,7 +205,7 @@ func CompileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) {
...
@@ -205,7 +205,7 @@ func CompileRegexps(regexpStrings []string) ([]*regexp.Regexp, error) {
// TODO(dchen1107): realiably detects the init system using on the system:
// TODO(dchen1107): realiably detects the init system using on the system:
// systemd, upstart, initd, etc.
// systemd, upstart, initd, etc.
func
UsingSystemdInitSystem
()
bool
{
func
UsingSystemdInitSystem
()
bool
{
if
_
,
err
:=
os
.
Stat
(
"/run/systemd/system"
);
err
!
=
nil
{
if
_
,
err
:=
os
.
Stat
(
"/run/systemd/system"
);
err
=
=
nil
{
return
true
return
true
}
}
...
...
Write
Preview
Markdown
is supported
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