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
8183a480
Commit
8183a480
authored
Mar 25, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5973 from ArtfulCoder/pause_no_port_forward_for_net_host
Stop port forwarding from pause in net=host mode
parents
5d379a2c
cd5ed382
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
20 deletions
+32
-20
kubelet.go
pkg/kubelet/kubelet.go
+30
-18
kubelet_test.go
pkg/kubelet/kubelet_test.go
+2
-2
No files found.
pkg/kubelet/kubelet.go
View file @
8183a480
...
@@ -1023,12 +1023,21 @@ func allowHostNetwork(pod *api.Pod) (bool, error) {
...
@@ -1023,12 +1023,21 @@ func allowHostNetwork(pod *api.Pod) (bool, error) {
// createPodInfraContainer starts the pod infra container for a pod. Returns the docker container ID of the newly created container.
// createPodInfraContainer starts the pod infra container for a pod. Returns the docker container ID of the newly created container.
func
(
kl
*
Kubelet
)
createPodInfraContainer
(
pod
*
api
.
Pod
)
(
dockertools
.
DockerID
,
error
)
{
func
(
kl
*
Kubelet
)
createPodInfraContainer
(
pod
*
api
.
Pod
)
(
dockertools
.
DockerID
,
error
)
{
// Use host networking if specified and allowed.
netNamespace
:=
""
var
ports
[]
api
.
ContainerPort
var
ports
[]
api
.
ContainerPort
// Docker only exports ports from the pod infra container. Let's
// collect all of the relevant ports and export them.
if
pod
.
Spec
.
HostNetwork
{
for
_
,
container
:=
range
pod
.
Spec
.
Containers
{
netNamespace
=
"host"
ports
=
append
(
ports
,
container
.
Ports
...
)
}
else
{
// Docker only exports ports from the pod infra container. Let's
// collect all of the relevant ports and export them.
for
_
,
container
:=
range
pod
.
Spec
.
Containers
{
ports
=
append
(
ports
,
container
.
Ports
...
)
}
}
}
container
:=
&
api
.
Container
{
container
:=
&
api
.
Container
{
Name
:
dockertools
.
PodInfraContainerName
,
Name
:
dockertools
.
PodInfraContainerName
,
Image
:
kl
.
podInfraContainerImage
,
Image
:
kl
.
podInfraContainerImage
,
...
@@ -1055,20 +1064,6 @@ func (kl *Kubelet) createPodInfraContainer(pod *api.Pod) (dockertools.DockerID,
...
@@ -1055,20 +1064,6 @@ func (kl *Kubelet) createPodInfraContainer(pod *api.Pod) (dockertools.DockerID,
kl
.
recorder
.
Eventf
(
ref
,
"pulled"
,
"Successfully pulled image %q"
,
container
.
Image
)
kl
.
recorder
.
Eventf
(
ref
,
"pulled"
,
"Successfully pulled image %q"
,
container
.
Image
)
}
}
// Use host networking if specified and allowed.
netNamespace
:=
""
if
pod
.
Spec
.
HostNetwork
{
allowed
,
err
:=
allowHostNetwork
(
pod
)
if
err
!=
nil
{
return
""
,
err
}
if
!
allowed
{
return
""
,
fmt
.
Errorf
(
"pod with UID %q specified host networking, but is disallowed"
,
pod
.
UID
)
}
netNamespace
=
"host"
}
id
,
err
:=
kl
.
runContainer
(
pod
,
container
,
nil
,
netNamespace
,
""
)
id
,
err
:=
kl
.
runContainer
(
pod
,
container
,
nil
,
netNamespace
,
""
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
...
@@ -1364,9 +1359,26 @@ func (kl *Kubelet) computePodContainerChanges(pod *api.Pod, runningPod kubeconta
...
@@ -1364,9 +1359,26 @@ func (kl *Kubelet) computePodContainerChanges(pod *api.Pod, runningPod kubeconta
},
nil
},
nil
}
}
func
(
kl
*
Kubelet
)
canRunPod
(
pod
*
api
.
Pod
)
error
{
if
pod
.
Spec
.
HostNetwork
{
allowed
,
err
:=
allowHostNetwork
(
pod
)
if
err
!=
nil
{
return
err
}
if
!
allowed
{
return
fmt
.
Errorf
(
"pod with UID %q specified host networking, but is disallowed"
,
pod
.
UID
)
}
}
return
nil
}
func
(
kl
*
Kubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
)
error
{
func
(
kl
*
Kubelet
)
syncPod
(
pod
*
api
.
Pod
,
mirrorPod
*
api
.
Pod
,
runningPod
kubecontainer
.
Pod
)
error
{
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
uid
:=
pod
.
UID
uid
:=
pod
.
UID
err
:=
kl
.
canRunPod
(
pod
)
if
err
!=
nil
{
return
err
}
// Before returning, regenerate status and store it in the cache.
// Before returning, regenerate status and store it in the cache.
defer
func
()
{
defer
func
()
{
...
...
pkg/kubelet/kubelet_test.go
View file @
8183a480
...
@@ -3495,7 +3495,7 @@ func TestHostNetworkAllowed(t *testing.T) {
...
@@ -3495,7 +3495,7 @@ func TestHostNetworkAllowed(t *testing.T) {
HostNetwork
:
true
,
HostNetwork
:
true
,
},
},
}
}
_
,
err
:=
kubelet
.
createPodInfraContainer
(
pod
)
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{}
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"expected pod infra creation to succeed: %v"
,
err
)
t
.
Errorf
(
"expected pod infra creation to succeed: %v"
,
err
)
}
}
...
@@ -3524,7 +3524,7 @@ func TestHostNetworkDisallowed(t *testing.T) {
...
@@ -3524,7 +3524,7 @@ func TestHostNetworkDisallowed(t *testing.T) {
HostNetwork
:
true
,
HostNetwork
:
true
,
},
},
}
}
_
,
err
:=
kubelet
.
createPodInfraContainer
(
pod
)
err
:=
kubelet
.
syncPod
(
pod
,
nil
,
container
.
Pod
{}
)
if
err
==
nil
{
if
err
==
nil
{
t
.
Errorf
(
"expected pod infra creation to fail"
)
t
.
Errorf
(
"expected pod infra creation to fail"
)
}
}
...
...
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