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
73f30b18
Commit
73f30b18
authored
Sep 15, 2016
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dockershim: support filter containers by sandbox ID
parent
2f60b72d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
docker_container.go
pkg/kubelet/dockershim/docker_container.go
+3
-1
docker_service.go
pkg/kubelet/dockershim/docker_service.go
+3
-0
helpers.go
pkg/kubelet/dockershim/helpers.go
+12
-3
No files found.
pkg/kubelet/dockershim/docker_container.go
View file @
73f30b18
...
...
@@ -48,7 +48,7 @@ func (ds *dockerService) ListContainers(filter *runtimeApi.ContainerFilter) ([]*
f
.
Add
(
"status"
,
toDockerContainerStatus
(
filter
.
GetState
()))
}
if
filter
.
PodSandboxId
!=
nil
{
// TODO: implement this after sandbox functions are implemented.
f
.
AddLabel
(
sandboxIDLabelKey
,
*
filter
.
PodSandboxId
)
}
if
filter
.
LabelSelector
!=
nil
{
...
...
@@ -91,6 +91,8 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeApi
labels
:=
makeLabels
(
config
.
GetLabels
(),
config
.
GetAnnotations
())
// Apply a the container type label.
labels
[
containerTypeLabelKey
]
=
containerTypeLabelContainer
// Write the sandbox ID in the labels.
labels
[
sandboxIDLabelKey
]
=
podSandboxID
image
:=
""
if
iSpec
:=
config
.
GetImage
();
iSpec
!=
nil
{
...
...
pkg/kubelet/dockershim/docker_service.go
View file @
73f30b18
...
...
@@ -47,8 +47,11 @@ const (
containerTypeLabelKey
=
"io.kubernetes.docker.type"
containerTypeLabelSandbox
=
"podsandbox"
containerTypeLabelContainer
=
"container"
sandboxIDLabelKey
=
"io.kubernetes.sandbox.id"
)
var
internalLabelKeys
[]
string
=
[]
string
{
containerTypeLabelKey
,
sandboxIDLabelKey
}
func
NewDockerService
(
client
dockertools
.
DockerInterface
)
DockerLegacyService
{
return
&
dockerService
{
client
:
dockertools
.
NewInstrumentedDockerInterface
(
client
),
...
...
pkg/kubelet/dockershim/helpers.go
View file @
73f30b18
...
...
@@ -84,11 +84,20 @@ func extractLabels(input map[string]string) (map[string]string, map[string]strin
annotations
:=
make
(
map
[
string
]
string
)
for
k
,
v
:=
range
input
{
// Check if the key is used internally by the shim.
// TODO: containerTypeLabelKey is the only internal label the shim uses
// right now. Expand this to a list later.
if
k
==
containerTypeLabelKey
{
internal
:=
false
for
_
,
internalKey
:=
range
internalLabelKeys
{
// TODO: containerTypeLabelKey is the only internal label the shim uses
// right now. Expand this to a list later.
if
k
==
internalKey
{
internal
=
true
break
}
}
if
internal
{
continue
}
// Check if the label should be treated as an annotation.
if
strings
.
HasPrefix
(
k
,
annotationPrefix
)
{
annotations
[
strings
.
TrimPrefix
(
k
,
annotationPrefix
)]
=
v
continue
...
...
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