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
daf7c8d6
Commit
daf7c8d6
authored
May 13, 2015
by
Yifan Gu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubelet/rkt: Use RunContainerOptions to get the arguments.
parent
2a87d561
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
23 deletions
+31
-23
rkt.go
pkg/kubelet/rkt/rkt.go
+31
-23
No files found.
pkg/kubelet/rkt/rkt.go
View file @
daf7c8d6
...
@@ -148,6 +148,7 @@ func New(config *Config,
...
@@ -148,6 +148,7 @@ func New(config *Config,
generator
:
generator
,
generator
:
generator
,
recorder
:
recorder
,
recorder
:
recorder
,
readinessManager
:
readinessManager
,
readinessManager
:
readinessManager
,
volumeGetter
:
volumeGetter
,
}
}
rkt
.
prober
=
prober
.
New
(
rkt
,
readinessManager
,
containerRefManager
,
recorder
)
rkt
.
prober
=
prober
.
New
(
rkt
,
readinessManager
,
containerRefManager
,
recorder
)
...
@@ -174,7 +175,7 @@ func (r *runtime) buildCommand(args ...string) *exec.Cmd {
...
@@ -174,7 +175,7 @@ func (r *runtime) buildCommand(args ...string) *exec.Cmd {
}
}
// runCommand invokes rkt binary with arguments and returns the result
// runCommand invokes rkt binary with arguments and returns the result
// from stdout in a list of strings.
// from stdout in a list of strings.
Each string in the list is a line.
func
(
r
*
runtime
)
runCommand
(
args
...
string
)
([]
string
,
error
)
{
func
(
r
*
runtime
)
runCommand
(
args
...
string
)
([]
string
,
error
)
{
glog
.
V
(
4
)
.
Info
(
"rkt: Run command:"
,
args
)
glog
.
V
(
4
)
.
Info
(
"rkt: Run command:"
,
args
)
...
@@ -285,7 +286,7 @@ func setIsolators(app *appctypes.App, c *api.Container) error {
...
@@ -285,7 +286,7 @@ func setIsolators(app *appctypes.App, c *api.Container) error {
// setApp overrides the app's fields if any of them are specified in the
// setApp overrides the app's fields if any of them are specified in the
// container's spec.
// container's spec.
func
setApp
(
app
*
appctypes
.
App
,
c
*
api
.
Container
)
error
{
func
setApp
(
app
*
appctypes
.
App
,
c
*
api
.
Container
,
opts
*
kubecontainer
.
RunContainerOptions
)
error
{
// Override the exec.
// Override the exec.
// TOOD(yifan): Revisit this for the overriding rule.
// TOOD(yifan): Revisit this for the overriding rule.
if
len
(
c
.
Command
)
>
0
||
len
(
c
.
Args
)
>
0
{
if
len
(
c
.
Command
)
>
0
||
len
(
c
.
Args
)
>
0
{
...
@@ -302,8 +303,7 @@ func setApp(app *appctypes.App, c *api.Container) error {
...
@@ -302,8 +303,7 @@ func setApp(app *appctypes.App, c *api.Container) error {
}
}
// Override the environment.
// Override the environment.
// TODO(yifan): Use RunContainerOptions.
if
len
(
opts
.
Envs
)
>
0
{
if
len
(
c
.
Env
)
>
0
{
app
.
Environment
=
[]
appctypes
.
EnvironmentVariable
{}
app
.
Environment
=
[]
appctypes
.
EnvironmentVariable
{}
}
}
for
_
,
env
:=
range
c
.
Env
{
for
_
,
env
:=
range
c
.
Env
{
...
@@ -314,30 +314,31 @@ func setApp(app *appctypes.App, c *api.Container) error {
...
@@ -314,30 +314,31 @@ func setApp(app *appctypes.App, c *api.Container) error {
}
}
// Override the mount points.
// Override the mount points.
if
len
(
c
.
Volume
Mounts
)
>
0
{
if
len
(
opts
.
Mounts
)
>
0
{
app
.
MountPoints
=
[]
appctypes
.
MountPoint
{}
app
.
MountPoints
=
[]
appctypes
.
MountPoint
{}
}
}
for
_
,
m
:=
range
c
.
Volume
Mounts
{
for
_
,
m
:=
range
opts
.
Mounts
{
mountPointName
,
err
:=
appctypes
.
NewACName
(
m
.
Name
)
mountPointName
,
err
:=
appctypes
.
NewACName
(
m
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
app
.
MountPoints
=
append
(
app
.
MountPoints
,
appctypes
.
MountPoint
{
app
.
MountPoints
=
append
(
app
.
MountPoints
,
appctypes
.
MountPoint
{
Name
:
*
mountPointName
,
Name
:
*
mountPointName
,
Path
:
m
.
Mount
Path
,
Path
:
m
.
Container
Path
,
ReadOnly
:
m
.
ReadOnly
,
ReadOnly
:
m
.
ReadOnly
,
})
})
}
}
// Override the ports.
// Override the ports.
if
len
(
c
.
Port
s
)
>
0
{
if
len
(
opts
.
PortMapping
s
)
>
0
{
app
.
Ports
=
[]
appctypes
.
Port
{}
app
.
Ports
=
[]
appctypes
.
Port
{}
}
}
for
_
,
p
:=
range
c
.
Port
s
{
for
_
,
p
:=
range
opts
.
PortMapping
s
{
portName
,
err
:=
appctypes
.
New
ACName
(
p
.
Name
)
name
,
err
:=
appctypes
.
Sanitize
ACName
(
p
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
portName
:=
appctypes
.
MustACName
(
name
)
app
.
Ports
=
append
(
app
.
Ports
,
appctypes
.
Port
{
app
.
Ports
=
append
(
app
.
Ports
,
appctypes
.
Port
{
Name
:
*
portName
,
Name
:
*
portName
,
Protocol
:
string
(
p
.
Protocol
),
Protocol
:
string
(
p
.
Protocol
),
...
@@ -360,7 +361,7 @@ func (r *runtime) getImageManifest(image string) (*appcschema.ImageManifest, err
...
@@ -360,7 +361,7 @@ func (r *runtime) getImageManifest(image string) (*appcschema.ImageManifest, err
return
nil
,
err
return
nil
,
err
}
}
if
len
(
output
)
!=
1
{
if
len
(
output
)
!=
1
{
return
nil
,
fmt
.
Errorf
(
"
no output"
)
return
nil
,
fmt
.
Errorf
(
"
invalid output: %v"
,
output
)
}
}
return
&
manifest
,
json
.
Unmarshal
([]
byte
(
output
[
0
]),
&
manifest
)
return
&
manifest
,
json
.
Unmarshal
([]
byte
(
output
[
0
]),
&
manifest
)
}
}
...
@@ -368,6 +369,7 @@ func (r *runtime) getImageManifest(image string) (*appcschema.ImageManifest, err
...
@@ -368,6 +369,7 @@ func (r *runtime) getImageManifest(image string) (*appcschema.ImageManifest, err
// makePodManifest transforms a kubelet pod spec to the rkt pod manifest.
// makePodManifest transforms a kubelet pod spec to the rkt pod manifest.
// TODO(yifan): Use the RunContainerOptions generated by GenerateRunContainerOptions().
// TODO(yifan): Use the RunContainerOptions generated by GenerateRunContainerOptions().
func
(
r
*
runtime
)
makePodManifest
(
pod
*
api
.
Pod
)
(
*
appcschema
.
PodManifest
,
error
)
{
func
(
r
*
runtime
)
makePodManifest
(
pod
*
api
.
Pod
)
(
*
appcschema
.
PodManifest
,
error
)
{
var
globalPortMappings
[]
kubecontainer
.
PortMapping
manifest
:=
appcschema
.
BlankPodManifest
()
manifest
:=
appcschema
.
BlankPodManifest
()
for
_
,
c
:=
range
pod
.
Spec
.
Containers
{
for
_
,
c
:=
range
pod
.
Spec
.
Containers
{
...
@@ -389,9 +391,17 @@ func (r *runtime) makePodManifest(pod *api.Pod) (*appcschema.PodManifest, error)
...
@@ -389,9 +391,17 @@ func (r *runtime) makePodManifest(pod *api.Pod) (*appcschema.PodManifest, error)
return
nil
,
err
return
nil
,
err
}
}
if
err
:=
setApp
(
imgManifest
.
App
,
&
c
);
err
!=
nil
{
opts
,
err
:=
r
.
generator
.
GenerateRunContainerOptions
(
pod
,
&
c
)
if
err
!=
nil
{
return
nil
,
err
}
globalPortMappings
=
append
(
globalPortMappings
,
opts
.
PortMappings
...
)
if
err
:=
setApp
(
imgManifest
.
App
,
&
c
,
opts
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
manifest
.
Apps
=
append
(
manifest
.
Apps
,
appcschema
.
RuntimeApp
{
manifest
.
Apps
=
append
(
manifest
.
Apps
,
appcschema
.
RuntimeApp
{
// TODO(yifan): We should allow app name to be different with
// TODO(yifan): We should allow app name to be different with
// image name. See https://github.com/coreos/rkt/pull/640.
// image name. See https://github.com/coreos/rkt/pull/640.
...
@@ -420,17 +430,16 @@ func (r *runtime) makePodManifest(pod *api.Pod) (*appcschema.PodManifest, error)
...
@@ -420,17 +430,16 @@ func (r *runtime) makePodManifest(pod *api.Pod) (*appcschema.PodManifest, error)
}
}
// Set global ports.
// Set global ports.
for
_
,
c
:=
range
pod
.
Spec
.
Containers
{
for
_
,
port
:=
range
globalPortMappings
{
for
_
,
port
:=
range
c
.
Ports
{
name
,
err
:=
appctypes
.
SanitizeACName
(
port
.
Name
)
portName
,
err
:=
appctypes
.
NewACName
(
port
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"cannot use the port's name %q as ACName: %v"
,
port
.
Name
,
err
)
return
nil
,
fmt
.
Errorf
(
"cannot use the port's name %q as ACName: %v"
,
port
.
Name
,
err
)
}
manifest
.
Ports
=
append
(
manifest
.
Ports
,
appctypes
.
ExposedPort
{
Name
:
*
portName
,
HostPort
:
uint
(
port
.
HostPort
),
})
}
}
portName
:=
appctypes
.
MustACName
(
name
)
manifest
.
Ports
=
append
(
manifest
.
Ports
,
appctypes
.
ExposedPort
{
Name
:
*
portName
,
HostPort
:
uint
(
port
.
HostPort
),
})
}
}
// TODO(yifan): Set pod-level isolators once it's supported in kubernetes.
// TODO(yifan): Set pod-level isolators once it's supported in kubernetes.
return
manifest
,
nil
return
manifest
,
nil
...
@@ -811,7 +820,6 @@ func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
...
@@ -811,7 +820,6 @@ func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
podFullName
:=
kubecontainer
.
GetPodFullName
(
pod
)
if
len
(
runningPod
.
Containers
)
==
0
{
if
len
(
runningPod
.
Containers
)
==
0
{
glog
.
V
(
4
)
.
Infof
(
"Pod %q is not running, will start it"
,
podFullName
)
glog
.
V
(
4
)
.
Infof
(
"Pod %q is not running, will start it"
,
podFullName
)
// TODO(yifan): Use RunContainerOptionsGeneratior to get volumeMaps, etc.
return
r
.
RunPod
(
pod
)
return
r
.
RunPod
(
pod
)
}
}
...
...
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