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
7cf7b093
Commit
7cf7b093
authored
May 04, 2015
by
Yu-Ju Hong
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7659 from vmarmol/runtime-switch
Have rkt implement the container Runtime interface
parents
36977ecb
ba7e940a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
8 deletions
+25
-8
runtime.go
pkg/kubelet/container/runtime.go
+2
-1
manager.go
pkg/kubelet/dockertools/manager.go
+1
-1
kubelet.go
pkg/kubelet/kubelet.go
+6
-1
log.go
pkg/kubelet/rkt/log.go
+3
-3
pull.go
pkg/kubelet/rkt/pull.go
+9
-0
rkt.go
pkg/kubelet/rkt/rkt.go
+2
-0
runner.go
pkg/kubelet/rkt/runner.go
+2
-2
No files found.
pkg/kubelet/container/runtime.go
View file @
7cf7b093
...
...
@@ -69,11 +69,12 @@ type Runtime interface {
ListImages
()
([]
Image
,
error
)
// Removes the specified image.
RemoveImage
(
image
string
)
error
// TODO(vmarmol): Unify pod and containerID args.
// GetContainerLogs returns logs of a specific container. By
// default, it returns a snapshot of the container log. Set 'follow' to true to
// stream the log. Set 'follow' to false and specify the number of lines (e.g.
// "100" or "all") to tail the log.
GetContainerLogs
(
containerID
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
(
err
error
)
GetContainerLogs
(
pod
*
api
.
Pod
,
containerID
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
(
err
error
)
}
// Customizable hooks injected into container runtimes.
...
...
pkg/kubelet/dockertools/manager.go
View file @
7cf7b093
...
...
@@ -209,7 +209,7 @@ func (sc *stringCache) Get(uid types.UID, name string) (string, bool) {
// stream the log. Set 'follow' to false and specify the number of lines (e.g.
// "100" or "all") to tail the log.
// TODO: Make 'RawTerminal' option flagable.
func
(
dm
*
DockerManager
)
GetContainerLogs
(
containerID
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
(
err
error
)
{
func
(
dm
*
DockerManager
)
GetContainerLogs
(
pod
*
api
.
Pod
,
containerID
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
(
err
error
)
{
opts
:=
docker
.
LogsOptions
{
Container
:
containerID
,
Stdout
:
true
,
...
...
pkg/kubelet/kubelet.go
View file @
7cf7b093
...
...
@@ -1369,6 +1369,7 @@ func (kl *Kubelet) validateContainerStatus(podStatus *api.PodStatus, containerNa
// TODO: this method is returning logs of random container attempts, when it should be returning the most recent attempt
// or all of them.
func
(
kl
*
Kubelet
)
GetKubeletContainerLogs
(
podFullName
,
containerName
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
error
{
// TODO(vmarmol): Refactor to not need the pod status and verification.
podStatus
,
err
:=
kl
.
GetPodStatus
(
podFullName
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to get status for pod %q - %v"
,
podFullName
,
err
)
...
...
@@ -1383,7 +1384,11 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
// waiting state.
return
err
}
return
kl
.
containerRuntime
.
GetContainerLogs
(
containerID
,
tail
,
follow
,
stdout
,
stderr
)
pod
,
ok
:=
kl
.
GetPodByFullName
(
podFullName
)
if
!
ok
{
return
fmt
.
Errorf
(
"unable to get logs for container %q in pod %q: unable to find pod"
,
containerName
,
podFullName
)
}
return
kl
.
containerRuntime
.
GetContainerLogs
(
pod
,
containerID
,
tail
,
follow
,
stdout
,
stderr
)
}
// GetHostname Returns the hostname as the kubelet sees it.
...
...
pkg/kubelet/rkt/log.go
View file @
7cf7b093
...
...
@@ -21,7 +21,7 @@ import (
"os/exec"
"strconv"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api
"
)
// GetContainerLogs uses journalctl to get the logs of the container.
...
...
@@ -31,8 +31,8 @@ import (
// TODO(yifan): Currently, it fetches all the containers' log within a pod. We will
// be able to fetch individual container's log once https://github.com/coreos/rkt/pull/841
// landed.
func
(
r
*
Runtime
)
GetContainerLogs
(
pod
kubecontainer
.
Pod
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
error
{
unitName
:=
makePodServiceFileName
(
pod
.
ID
)
func
(
r
*
Runtime
)
GetContainerLogs
(
pod
*
api
.
Pod
,
containerID
string
,
tail
string
,
follow
bool
,
stdout
,
stderr
io
.
Writer
)
error
{
unitName
:=
makePodServiceFileName
(
pod
.
U
ID
)
cmd
:=
exec
.
Command
(
"journalctl"
,
"-u"
,
unitName
)
if
follow
{
cmd
.
Args
=
append
(
cmd
.
Args
,
"-f"
)
...
...
pkg/kubelet/rkt/pull.go
View file @
7cf7b093
...
...
@@ -22,6 +22,7 @@ import (
"path"
"strings"
kubecontainer
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/container"
"github.com/docker/docker/pkg/parsers"
docker
"github.com/fsouza/go-dockerclient"
"github.com/golang/glog"
...
...
@@ -108,3 +109,11 @@ func (r *Runtime) IsImagePresent(img string) (bool, error) {
}
return
true
,
nil
}
func
(
r
*
Runtime
)
ListImages
()
([]
kubecontainer
.
Image
,
error
)
{
return
[]
kubecontainer
.
Image
{},
fmt
.
Errorf
(
"rkt: ListImages unimplemented"
)
}
func
(
r
*
Runtime
)
RemoveImage
(
image
string
)
error
{
return
fmt
.
Errorf
(
"rkt: RemoveImages unimplemented"
)
}
pkg/kubelet/rkt/rkt.go
View file @
7cf7b093
...
...
@@ -81,6 +81,8 @@ type Runtime struct {
dockerKeyring
credentialprovider
.
DockerKeyring
}
var
_
kubecontainer
.
Runtime
=
&
Runtime
{}
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
...
...
pkg/kubelet/rkt/runner.go
View file @
7cf7b093
...
...
@@ -107,7 +107,7 @@ func (r *Runtime) ExecInContainer(containerID string, cmd []string, stdin io.Rea
// findRktID returns the rkt uuid for the pod.
// TODO(yifan): This is unefficient which require us to list
// all the unit files.
func
(
r
*
Runtime
)
findRktID
(
pod
kubecontainer
.
Pod
)
(
string
,
error
)
{
func
(
r
*
Runtime
)
findRktID
(
pod
*
kubecontainer
.
Pod
)
(
string
,
error
)
{
units
,
err
:=
r
.
systemd
.
ListUnits
()
if
err
!=
nil
{
return
""
,
err
...
...
@@ -150,7 +150,7 @@ func (r *Runtime) findRktID(pod kubecontainer.Pod) (string, error) {
// - should we support nsenter + socat in a container, running with elevated privs and --pid=host?
//
// TODO(yifan): Merge with the same function in dockertools.
func
(
r
*
Runtime
)
PortForward
(
pod
kubecontainer
.
Pod
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
{
func
(
r
*
Runtime
)
PortForward
(
pod
*
kubecontainer
.
Pod
,
port
uint16
,
stream
io
.
ReadWriteCloser
)
error
{
glog
.
V
(
4
)
.
Infof
(
"Rkt port forwarding in container."
)
podInfos
,
err
:=
r
.
getPodInfos
()
...
...
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