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
78709456
Commit
78709456
authored
Jul 12, 2017
by
Casey Davenport
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TODO: rename podInfraContainerID to podSandboxID
parent
d9bf88ce
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
25 deletions
+22
-25
docker_streaming.go
pkg/kubelet/dockershim/docker_streaming.go
+2
-2
security_context.go
pkg/kubelet/dockershim/security_context.go
+7
-7
cni.go
pkg/kubelet/network/cni/cni.go
+8
-8
plugins.go
pkg/kubelet/network/plugins.go
+5
-8
No files found.
pkg/kubelet/dockershim/docker_streaming.go
View file @
78709456
...
@@ -159,8 +159,8 @@ func attachContainer(client libdocker.Interface, containerID string, stdin io.Re
...
@@ -159,8 +159,8 @@ func attachContainer(client libdocker.Interface, containerID string, stdin io.Re
return
client
.
AttachToContainer
(
containerID
,
opts
,
sopts
)
return
client
.
AttachToContainer
(
containerID
,
opts
,
sopts
)
}
}
func
portForward
(
client
libdocker
.
Interface
,
pod
InfraContainer
ID
string
,
port
int32
,
stream
io
.
ReadWriteCloser
)
error
{
func
portForward
(
client
libdocker
.
Interface
,
pod
Sandbox
ID
string
,
port
int32
,
stream
io
.
ReadWriteCloser
)
error
{
container
,
err
:=
client
.
InspectContainer
(
pod
InfraContainer
ID
)
container
,
err
:=
client
.
InspectContainer
(
pod
Sandbox
ID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubelet/dockershim/security_context.go
View file @
78709456
...
@@ -54,7 +54,7 @@ func applySandboxSecurityContext(lc *runtimeapi.LinuxPodSandboxConfig, config *d
...
@@ -54,7 +54,7 @@ func applySandboxSecurityContext(lc *runtimeapi.LinuxPodSandboxConfig, config *d
}
}
// applyContainerSecurityContext updates docker container options according to security context.
// applyContainerSecurityContext updates docker container options according to security context.
func
applyContainerSecurityContext
(
lc
*
runtimeapi
.
LinuxContainerConfig
,
s
andboxID
string
,
config
*
dockercontainer
.
Config
,
hc
*
dockercontainer
.
HostConfig
,
separator
rune
)
error
{
func
applyContainerSecurityContext
(
lc
*
runtimeapi
.
LinuxContainerConfig
,
podS
andboxID
string
,
config
*
dockercontainer
.
Config
,
hc
*
dockercontainer
.
HostConfig
,
separator
rune
)
error
{
if
lc
==
nil
{
if
lc
==
nil
{
return
nil
return
nil
}
}
...
@@ -63,7 +63,7 @@ func applyContainerSecurityContext(lc *runtimeapi.LinuxContainerConfig, sandboxI
...
@@ -63,7 +63,7 @@ func applyContainerSecurityContext(lc *runtimeapi.LinuxContainerConfig, sandboxI
if
err
:=
modifyHostConfig
(
lc
.
SecurityContext
,
hc
,
separator
);
err
!=
nil
{
if
err
:=
modifyHostConfig
(
lc
.
SecurityContext
,
hc
,
separator
);
err
!=
nil
{
return
err
return
err
}
}
modifyContainerNamespaceOptions
(
lc
.
SecurityContext
.
GetNamespaceOptions
(),
s
andboxID
,
hc
)
modifyContainerNamespaceOptions
(
lc
.
SecurityContext
.
GetNamespaceOptions
(),
podS
andboxID
,
hc
)
return
nil
return
nil
}
}
...
@@ -127,14 +127,14 @@ func modifySandboxNamespaceOptions(nsOpts *runtimeapi.NamespaceOption, hostConfi
...
@@ -127,14 +127,14 @@ func modifySandboxNamespaceOptions(nsOpts *runtimeapi.NamespaceOption, hostConfi
}
}
// modifyContainerNamespaceOptions apply namespace options for container
// modifyContainerNamespaceOptions apply namespace options for container
func
modifyContainerNamespaceOptions
(
nsOpts
*
runtimeapi
.
NamespaceOption
,
s
andboxID
string
,
hostConfig
*
dockercontainer
.
HostConfig
)
{
func
modifyContainerNamespaceOptions
(
nsOpts
*
runtimeapi
.
NamespaceOption
,
podS
andboxID
string
,
hostConfig
*
dockercontainer
.
HostConfig
)
{
hostNetwork
:=
false
hostNetwork
:=
false
if
nsOpts
!=
nil
{
if
nsOpts
!=
nil
{
hostNetwork
=
nsOpts
.
HostNetwork
hostNetwork
=
nsOpts
.
HostNetwork
}
}
hostConfig
.
PidMode
=
dockercontainer
.
PidMode
(
fmt
.
Sprintf
(
"container:%v"
,
s
andboxID
))
hostConfig
.
PidMode
=
dockercontainer
.
PidMode
(
fmt
.
Sprintf
(
"container:%v"
,
podS
andboxID
))
modifyCommonNamespaceOptions
(
nsOpts
,
hostConfig
)
modifyCommonNamespaceOptions
(
nsOpts
,
hostConfig
)
modifyHostNetworkOptionForContainer
(
hostNetwork
,
s
andboxID
,
hostConfig
)
modifyHostNetworkOptionForContainer
(
hostNetwork
,
podS
andboxID
,
hostConfig
)
}
}
// modifyCommonNamespaceOptions apply common namespace options for sandbox and container
// modifyCommonNamespaceOptions apply common namespace options for sandbox and container
...
@@ -172,8 +172,8 @@ func modifyHostNetworkOptionForSandbox(hostNetwork bool, network *knetwork.Plugi
...
@@ -172,8 +172,8 @@ func modifyHostNetworkOptionForSandbox(hostNetwork bool, network *knetwork.Plugi
}
}
// modifyHostNetworkOptionForContainer applies NetworkMode/UTSMode to container's dockercontainer.HostConfig.
// modifyHostNetworkOptionForContainer applies NetworkMode/UTSMode to container's dockercontainer.HostConfig.
func
modifyHostNetworkOptionForContainer
(
hostNetwork
bool
,
s
andboxID
string
,
hc
*
dockercontainer
.
HostConfig
)
{
func
modifyHostNetworkOptionForContainer
(
hostNetwork
bool
,
podS
andboxID
string
,
hc
*
dockercontainer
.
HostConfig
)
{
sandboxNSMode
:=
fmt
.
Sprintf
(
"container:%v"
,
s
andboxID
)
sandboxNSMode
:=
fmt
.
Sprintf
(
"container:%v"
,
podS
andboxID
)
hc
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
sandboxNSMode
)
hc
.
NetworkMode
=
dockercontainer
.
NetworkMode
(
sandboxNSMode
)
hc
.
IpcMode
=
dockercontainer
.
IpcMode
(
sandboxNSMode
)
hc
.
IpcMode
=
dockercontainer
.
IpcMode
(
sandboxNSMode
)
hc
.
UTSMode
=
""
hc
.
UTSMode
=
""
...
...
pkg/kubelet/network/cni/cni.go
View file @
78709456
...
@@ -280,8 +280,8 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
...
@@ -280,8 +280,8 @@ func (plugin *cniNetworkPlugin) GetPodNetworkStatus(namespace string, name strin
return
&
network
.
PodNetworkStatus
{
IP
:
ip
},
nil
return
&
network
.
PodNetworkStatus
{
IP
:
ip
},
nil
}
}
func
(
plugin
*
cniNetworkPlugin
)
addToNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
pod
InfraContainer
ID
kubecontainer
.
ContainerID
,
podNetnsPath
string
)
(
cnitypes
.
Result
,
error
)
{
func
(
plugin
*
cniNetworkPlugin
)
addToNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
pod
Sandbox
ID
kubecontainer
.
ContainerID
,
podNetnsPath
string
)
(
cnitypes
.
Result
,
error
)
{
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
pod
InfraContainer
ID
,
podNetnsPath
)
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
pod
Sandbox
ID
,
podNetnsPath
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error adding network when building cni runtime conf: %v"
,
err
)
glog
.
Errorf
(
"Error adding network when building cni runtime conf: %v"
,
err
)
return
nil
,
err
return
nil
,
err
...
@@ -298,8 +298,8 @@ func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string
...
@@ -298,8 +298,8 @@ func (plugin *cniNetworkPlugin) addToNetwork(network *cniNetwork, podName string
return
res
,
nil
return
res
,
nil
}
}
func
(
plugin
*
cniNetworkPlugin
)
deleteFromNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
pod
InfraContainer
ID
kubecontainer
.
ContainerID
,
podNetnsPath
string
)
error
{
func
(
plugin
*
cniNetworkPlugin
)
deleteFromNetwork
(
network
*
cniNetwork
,
podName
string
,
podNamespace
string
,
pod
Sandbox
ID
kubecontainer
.
ContainerID
,
podNetnsPath
string
)
error
{
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
pod
InfraContainer
ID
,
podNetnsPath
)
rt
,
err
:=
plugin
.
buildCNIRuntimeConf
(
podName
,
podNamespace
,
pod
Sandbox
ID
,
podNetnsPath
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"Error deleting network when building cni runtime conf: %v"
,
err
)
glog
.
Errorf
(
"Error deleting network when building cni runtime conf: %v"
,
err
)
return
err
return
err
...
@@ -315,25 +315,25 @@ func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName s
...
@@ -315,25 +315,25 @@ func (plugin *cniNetworkPlugin) deleteFromNetwork(network *cniNetwork, podName s
return
nil
return
nil
}
}
func
(
plugin
*
cniNetworkPlugin
)
buildCNIRuntimeConf
(
podName
string
,
podNs
string
,
pod
InfraContainer
ID
kubecontainer
.
ContainerID
,
podNetnsPath
string
)
(
*
libcni
.
RuntimeConf
,
error
)
{
func
(
plugin
*
cniNetworkPlugin
)
buildCNIRuntimeConf
(
podName
string
,
podNs
string
,
pod
Sandbox
ID
kubecontainer
.
ContainerID
,
podNetnsPath
string
)
(
*
libcni
.
RuntimeConf
,
error
)
{
glog
.
V
(
4
)
.
Infof
(
"Got netns path %v"
,
podNetnsPath
)
glog
.
V
(
4
)
.
Infof
(
"Got netns path %v"
,
podNetnsPath
)
glog
.
V
(
4
)
.
Infof
(
"Using netns path %v"
,
podNs
)
glog
.
V
(
4
)
.
Infof
(
"Using netns path %v"
,
podNs
)
rt
:=
&
libcni
.
RuntimeConf
{
rt
:=
&
libcni
.
RuntimeConf
{
ContainerID
:
pod
InfraContainer
ID
.
ID
,
ContainerID
:
pod
Sandbox
ID
.
ID
,
NetNS
:
podNetnsPath
,
NetNS
:
podNetnsPath
,
IfName
:
network
.
DefaultInterfaceName
,
IfName
:
network
.
DefaultInterfaceName
,
Args
:
[][
2
]
string
{
Args
:
[][
2
]
string
{
{
"IgnoreUnknown"
,
"1"
},
{
"IgnoreUnknown"
,
"1"
},
{
"K8S_POD_NAMESPACE"
,
podNs
},
{
"K8S_POD_NAMESPACE"
,
podNs
},
{
"K8S_POD_NAME"
,
podName
},
{
"K8S_POD_NAME"
,
podName
},
{
"K8S_POD_INFRA_CONTAINER_ID"
,
pod
InfraContainer
ID
.
ID
},
{
"K8S_POD_INFRA_CONTAINER_ID"
,
pod
Sandbox
ID
.
ID
},
},
},
}
}
// port mappings are a cni capability-based args, rather than parameters
// port mappings are a cni capability-based args, rather than parameters
// to a specific plugin
// to a specific plugin
portMappings
,
err
:=
plugin
.
host
.
GetPodPortMappings
(
pod
InfraContainer
ID
.
ID
)
portMappings
,
err
:=
plugin
.
host
.
GetPodPortMappings
(
pod
Sandbox
ID
.
ID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not retrieve port mappings: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"could not retrieve port mappings: %v"
,
err
)
}
}
...
...
pkg/kubelet/network/plugins.go
View file @
78709456
...
@@ -63,16 +63,13 @@ type NetworkPlugin interface {
...
@@ -63,16 +63,13 @@ type NetworkPlugin interface {
// SetUpPod is the method called after the infra container of
// SetUpPod is the method called after the infra container of
// the pod has been created but before the other containers of the
// the pod has been created but before the other containers of the
// pod are launched.
// pod are launched.
// TODO: rename podInfraContainerID to sandboxID
SetUpPod
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
SetUpPod
(
namespace
string
,
name
string
,
podInfraContainerID
kubecontainer
.
ContainerID
,
annotations
map
[
string
]
string
)
error
// TearDownPod is the method called before a pod's infra container will be deleted
// TearDownPod is the method called before a pod's infra container will be deleted
// TODO: rename podInfraContainerID to sandboxID
TearDownPod
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
)
error
TearDownPod
(
namespace
string
,
name
string
,
podInfraContainerID
kubecontainer
.
ContainerID
)
error
// GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the container
// GetPodNetworkStatus is the method called to obtain the ipv4 or ipv6 addresses of the container
// TODO: rename podInfraContainerID to sandboxID
GetPodNetworkStatus
(
namespace
string
,
name
string
,
podSandboxID
kubecontainer
.
ContainerID
)
(
*
PodNetworkStatus
,
error
)
GetPodNetworkStatus
(
namespace
string
,
name
string
,
podInfraContainerID
kubecontainer
.
ContainerID
)
(
*
PodNetworkStatus
,
error
)
// Status returns error if the network plugin is in error state
// Status returns error if the network plugin is in error state
Status
()
error
Status
()
error
...
@@ -136,7 +133,7 @@ type Host interface {
...
@@ -136,7 +133,7 @@ type Host interface {
}
}
// NamespaceGetter is an interface to retrieve namespace information for a given
// NamespaceGetter is an interface to retrieve namespace information for a given
//
s
andboxID. Typically implemented by runtime shims that are closely coupled to
//
podS
andboxID. Typically implemented by runtime shims that are closely coupled to
// CNI plugin wrappers like kubenet.
// CNI plugin wrappers like kubenet.
type
NamespaceGetter
interface
{
type
NamespaceGetter
interface
{
// GetNetNS returns network namespace information for the given containerID.
// GetNetNS returns network namespace information for the given containerID.
...
@@ -146,7 +143,7 @@ type NamespaceGetter interface {
...
@@ -146,7 +143,7 @@ type NamespaceGetter interface {
}
}
// PortMappingGetter is an interface to retrieve port mapping information for a given
// PortMappingGetter is an interface to retrieve port mapping information for a given
//
s
andboxID. Typically implemented by runtime shims that are closely coupled to
//
podS
andboxID. Typically implemented by runtime shims that are closely coupled to
// CNI plugin wrappers like kubenet.
// CNI plugin wrappers like kubenet.
type
PortMappingGetter
interface
{
type
PortMappingGetter
interface
{
// GetPodPortMappings returns sandbox port mappings information.
// GetPodPortMappings returns sandbox port mappings information.
...
...
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