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
5936e81b
Commit
5936e81b
authored
Jun 02, 2017
by
Dong Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add determinePodIPBySandboxID.
parent
6d07fc2f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
3 deletions
+57
-3
docker_sandbox.go
pkg/kubelet/dockershim/docker_sandbox.go
+9
-3
helpers_linux.go
pkg/kubelet/dockershim/helpers_linux.go
+4
-0
helpers_unsupported.go
pkg/kubelet/dockershim/helpers_unsupported.go
+5
-0
helpers_windows.go
pkg/kubelet/dockershim/helpers_windows.go
+39
-0
No files found.
pkg/kubelet/dockershim/docker_sandbox.go
View file @
5936e81b
...
@@ -317,9 +317,15 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS
...
@@ -317,9 +317,15 @@ func (ds *dockerService) PodSandboxStatus(podSandboxID string) (*runtimeapi.PodS
if
r
.
State
.
Running
{
if
r
.
State
.
Running
{
state
=
runtimeapi
.
PodSandboxState_SANDBOX_READY
state
=
runtimeapi
.
PodSandboxState_SANDBOX_READY
}
}
IP
,
err
:=
ds
.
getIP
(
r
)
if
err
!=
nil
{
var
IP
string
return
nil
,
err
// TODO: Remove this when sandbox is available on windows
// This is a workaround for windows, where sandbox is not in use, and pod IP is determined through containers belonging to the Pod.
if
IP
=
ds
.
determinePodIPBySandboxID
(
podSandboxID
);
IP
==
""
{
IP
,
err
=
ds
.
getIP
(
r
)
if
err
!=
nil
{
return
nil
,
err
}
}
}
network
:=
&
runtimeapi
.
PodSandboxNetworkStatus
{
Ip
:
IP
}
network
:=
&
runtimeapi
.
PodSandboxNetworkStatus
{
Ip
:
IP
}
hostNetwork
:=
sharesHostNetwork
(
r
)
hostNetwork
:=
sharesHostNetwork
(
r
)
...
...
pkg/kubelet/dockershim/helpers_linux.go
View file @
5936e81b
...
@@ -82,3 +82,7 @@ func (ds *dockerService) updateCreateConfig(
...
@@ -82,3 +82,7 @@ func (ds *dockerService) updateCreateConfig(
return
nil
return
nil
}
}
func
(
ds
*
dockerService
)
determinePodIPBySandboxID
(
uid
string
)
string
{
return
""
}
pkg/kubelet/dockershim/helpers_unsupported.go
View file @
5936e81b
...
@@ -42,3 +42,8 @@ func (ds *dockerService) updateCreateConfig(
...
@@ -42,3 +42,8 @@ func (ds *dockerService) updateCreateConfig(
glog
.
Warningf
(
"updateCreateConfig is unsupported in this build"
)
glog
.
Warningf
(
"updateCreateConfig is unsupported in this build"
)
return
nil
return
nil
}
}
func
(
ds
*
dockerService
)
determinePodIPBySandboxID
(
uid
string
)
string
{
glog
.
Warningf
(
"determinePodIPBySandboxID is unsupported in this build"
)
return
""
}
pkg/kubelet/dockershim/helpers_windows.go
View file @
5936e81b
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"github.com/blang/semver"
"github.com/blang/semver"
dockertypes
"github.com/docker/engine-api/types"
dockertypes
"github.com/docker/engine-api/types"
dockercontainer
"github.com/docker/engine-api/types/container"
dockercontainer
"github.com/docker/engine-api/types/container"
dockerfilters
"github.com/docker/engine-api/types/filters"
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
...
@@ -60,3 +61,41 @@ func (ds *dockerService) updateCreateConfig(
...
@@ -60,3 +61,41 @@ func (ds *dockerService) updateCreateConfig(
return
nil
return
nil
}
}
func
(
ds
*
dockerService
)
determinePodIPBySandboxID
(
sandboxID
string
)
string
{
opts
:=
dockertypes
.
ContainerListOptions
{
All
:
true
,
Filter
:
dockerfilters
.
NewArgs
(),
}
f
:=
newDockerFilter
(
&
opts
.
Filter
)
f
.
AddLabel
(
containerTypeLabelKey
,
containerTypeLabelContainer
)
f
.
AddLabel
(
sandboxIDLabelKey
,
sandboxID
)
containers
,
err
:=
ds
.
client
.
ListContainers
(
opts
)
if
err
!=
nil
{
return
""
}
for
_
,
c
:=
range
containers
{
r
,
err
:=
ds
.
client
.
InspectContainer
(
c
.
ID
)
if
err
!=
nil
{
continue
}
if
containerIP
:=
getContainerIP
(
r
);
containerIP
!=
""
{
return
containerIP
}
}
return
""
}
func
getContainerIP
(
container
*
dockertypes
.
ContainerJSON
)
string
{
if
container
.
NetworkSettings
!=
nil
{
for
_
,
network
:=
range
container
.
NetworkSettings
.
Networks
{
if
network
.
IPAddress
!=
""
{
return
network
.
IPAddress
}
}
}
return
""
}
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