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
5e39b3d9
Commit
5e39b3d9
authored
Dec 27, 2016
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up exec network plugin
parent
9ce8f10a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
0 additions
and
297 deletions
+0
-297
BUILD
cmd/kubelet/app/BUILD
+0
-1
plugins.go
cmd/kubelet/app/plugins.go
+0
-2
bindata.go
pkg/generated/bindata.go
+0
-0
BUILD
pkg/kubelet/network/exec/BUILD
+0
-41
exec.go
pkg/kubelet/network/exec/exec.go
+0
-203
exec_test.go
pkg/kubelet/network/exec/exec_test.go
+0
-0
exec_unix.go
pkg/kubelet/network/exec/exec_unix.go
+0
-27
exec_unsupported.go
pkg/kubelet/network/exec/exec_unsupported.go
+0
-23
No files found.
cmd/kubelet/app/BUILD
View file @
5e39b3d9
...
...
@@ -56,7 +56,6 @@ go_library(
"//pkg/kubelet/dockertools:go_default_library",
"//pkg/kubelet/network:go_default_library",
"//pkg/kubelet/network/cni:go_default_library",
"//pkg/kubelet/network/exec:go_default_library",
"//pkg/kubelet/network/kubenet:go_default_library",
"//pkg/kubelet/server:go_default_library",
"//pkg/kubelet/types:go_default_library",
...
...
cmd/kubelet/app/plugins.go
View file @
5e39b3d9
...
...
@@ -25,7 +25,6 @@ import (
// Network plugins
"k8s.io/kubernetes/pkg/kubelet/network"
"k8s.io/kubernetes/pkg/kubelet/network/cni"
"k8s.io/kubernetes/pkg/kubelet/network/exec"
"k8s.io/kubernetes/pkg/kubelet/network/kubenet"
// Volume plugins
"k8s.io/kubernetes/pkg/volume"
...
...
@@ -101,7 +100,6 @@ func ProbeNetworkPlugins(pluginDir, cniConfDir, cniBinDir string) []network.Netw
cniConfDir
=
pluginDir
}
// for each existing plugin, add to the list
allPlugins
=
append
(
allPlugins
,
exec
.
ProbeNetworkPlugins
(
pluginDir
)
...
)
allPlugins
=
append
(
allPlugins
,
cni
.
ProbeNetworkPlugins
(
cniConfDir
,
cniBinDir
)
...
)
allPlugins
=
append
(
allPlugins
,
kubenet
.
NewPlugin
(
pluginDir
))
...
...
pkg/generated/bindata.go
View file @
5e39b3d9
This diff is collapsed.
Click to expand it.
pkg/kubelet/network/exec/BUILD
deleted
100644 → 0
View file @
9ce8f10a
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = [
"exec.go",
"exec_unix.go",
],
tags = ["automanaged"],
deps = [
"//pkg/apis/componentconfig:go_default_library",
"//pkg/apis/meta/v1:go_default_library",
"//pkg/kubelet/container:go_default_library",
"//pkg/kubelet/network:go_default_library",
"//pkg/util/exec:go_default_library",
"//vendor:github.com/golang/glog",
],
)
go_test(
name = "go_default_test",
srcs = ["exec_test.go"],
library = "go_default_library",
tags = ["automanaged"],
deps = [
"//pkg/apis/componentconfig:go_default_library",
"//pkg/kubelet/container:go_default_library",
"//pkg/kubelet/network:go_default_library",
"//pkg/kubelet/network/testing:go_default_library",
"//pkg/util/sets:go_default_library",
"//pkg/util/testing:go_default_library",
],
)
pkg/kubelet/network/exec/exec.go
deleted
100644 → 0
View file @
9ce8f10a
/*
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package exec scans and loads networking plugins that are installed
// under /usr/libexec/kubernetes/kubelet-plugins/net/exec/
// The layout convention for a plugin is:
// plugin-name/ (plugins have to be directories first)
// plugin-name/plugin-name (executable that will be called out, see Vendoring Note for more nuances)
// plugin-name/<other-files>
// where, 'executable' has the following requirements:
// - should have exec permissions
// - should give non-zero exit code on failure, and zero on success
// - the arguments will be <action> <pod_namespace> <pod_name> <docker_id_of_infra_container>
// whereupon, <action> will be one of:
// - init, called when the kubelet loads the plugin
// - setup, called after the infra container of a pod is
// created, but before other containers of the pod are created
// - teardown, called before the pod infra container is killed
// - status, called at regular intervals and is supposed to return a json
// formatted output indicating the pod's IPAddress(v4/v6). An empty string value or an erroneous output
// will mean the container runtime (docker) will be asked for the PodIP
// e.g. {
// "apiVersion" : "v1beta1",
// "kind" : "PodNetworkStatus",
// "ip" : "10.20.30.40"
// }
// The fields "apiVersion" and "kind" are optional in version v1beta1
// As the executables are called, the file-descriptors stdin, stdout, stderr
// remain open. The combined output of stdout/stderr is captured and logged.
//
// Note: If the pod infra container self-terminates (e.g. crashes or is killed),
// the entire pod lifecycle will be restarted, but teardown will not be called.
//
// Vendoring Note:
// Plugin Names can be vendored also. Use '~' as the escaped name for plugin directories.
// And expect command line argument to call vendored plugins as 'vendor/pluginName'
// e.g. pluginName = mysdn
// vendorname = mycompany
// then, plugin layout should be
// mycompany~mysdn/
// mycompany~mysdn/mysdn (this becomes the executable)
// mycompany~mysdn/<other-files>
// and, call the kubelet with '--network-plugin=mycompany/mysdn'
package
exec
import
(
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"path"
"strings"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/apis/componentconfig"
metav1
"k8s.io/kubernetes/pkg/apis/meta/v1"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/network"
utilexec
"k8s.io/kubernetes/pkg/util/exec"
)
type
execNetworkPlugin
struct
{
network
.
NoopNetworkPlugin
execName
string
execPath
string
host
network
.
Host
}
const
(
initCmd
=
"init"
setUpCmd
=
"setup"
tearDownCmd
=
"teardown"
statusCmd
=
"status"
defaultDir
=
"/usr/libexec/kubernetes/kubelet-plugins/net/exec/"
)
func
ProbeNetworkPlugins
(
pluginDir
string
)
[]
network
.
NetworkPlugin
{
execPlugins
:=
[]
network
.
NetworkPlugin
{}
if
pluginDir
==
""
{
pluginDir
=
defaultDir
}
files
,
_
:=
ioutil
.
ReadDir
(
pluginDir
)
for
_
,
f
:=
range
files
{
// only directories are counted as plugins
// and pluginDir/dirname/dirname should be an executable
// unless dirname contains '~' for escaping namespace
// e.g. dirname = vendor~ipvlan
// then, executable will be pluginDir/dirname/ipvlan
if
f
.
IsDir
()
{
execPath
:=
path
.
Join
(
pluginDir
,
f
.
Name
())
execPlugins
=
append
(
execPlugins
,
&
execNetworkPlugin
{
execName
:
network
.
UnescapePluginName
(
f
.
Name
()),
execPath
:
execPath
})
}
}
return
execPlugins
}
func
(
plugin
*
execNetworkPlugin
)
Init
(
host
network
.
Host
,
hairpinMode
componentconfig
.
HairpinMode
,
nonMasqueradeCIDR
string
,
mtu
int
)
error
{
err
:=
plugin
.
validate
()
if
err
!=
nil
{
return
err
}
plugin
.
host
=
host
// call the init script
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
initCmd
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
V
(
5
)
.
Infof
(
"Init 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
}
else
{
glog
.
V
(
5
)
.
Infof
(
"Init 'exec' network plugin output: %s"
,
string
(
out
))
}
return
err
}
func
(
plugin
*
execNetworkPlugin
)
getExecutable
()
string
{
parts
:=
strings
.
Split
(
plugin
.
execName
,
"/"
)
execName
:=
parts
[
len
(
parts
)
-
1
]
return
path
.
Join
(
plugin
.
execPath
,
execName
)
}
func
(
plugin
*
execNetworkPlugin
)
Name
()
string
{
return
plugin
.
execName
}
func
(
plugin
*
execNetworkPlugin
)
validate
()
error
{
if
!
isExecutable
(
plugin
.
getExecutable
())
{
errStr
:=
fmt
.
Sprintf
(
"Invalid exec plugin. Executable '%s' does not have correct permissions."
,
plugin
.
execName
)
return
errors
.
New
(
errStr
)
}
return
nil
}
func
(
plugin
*
execNetworkPlugin
)
SetUpPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
)
error
{
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
setUpCmd
,
namespace
,
name
,
id
.
ID
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
V
(
5
)
.
Infof
(
"SetUpPod 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
}
else
{
glog
.
V
(
5
)
.
Infof
(
"SetUpPod 'exec' network plugin output: %s"
,
string
(
out
))
}
return
err
}
func
(
plugin
*
execNetworkPlugin
)
TearDownPod
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
)
error
{
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
tearDownCmd
,
namespace
,
name
,
id
.
ID
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
V
(
5
)
.
Infof
(
"TearDownPod 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
}
else
{
glog
.
V
(
5
)
.
Infof
(
"TearDownPod 'exec' network plugin output: %s"
,
string
(
out
))
}
return
err
}
func
(
plugin
*
execNetworkPlugin
)
GetPodNetworkStatus
(
namespace
string
,
name
string
,
id
kubecontainer
.
ContainerID
)
(
*
network
.
PodNetworkStatus
,
error
)
{
out
,
err
:=
utilexec
.
New
()
.
Command
(
plugin
.
getExecutable
(),
statusCmd
,
namespace
,
name
,
id
.
ID
)
.
CombinedOutput
()
if
err
!=
nil
{
glog
.
V
(
5
)
.
Infof
(
"Status 'exec' network plugin output: %s, %v"
,
string
(
out
),
err
)
return
nil
,
err
}
else
{
glog
.
V
(
5
)
.
Infof
(
"Status 'exec' network plugin output: %s"
,
string
(
out
))
}
if
string
(
out
)
==
""
{
return
nil
,
nil
}
findVersion
:=
struct
{
metav1
.
TypeMeta
`json:",inline"`
}{}
err
=
json
.
Unmarshal
(
out
,
&
findVersion
)
if
err
!=
nil
{
return
nil
,
err
}
// check kind and version
if
findVersion
.
Kind
!=
""
&&
findVersion
.
Kind
!=
"PodNetworkStatus"
{
errStr
:=
fmt
.
Sprintf
(
"Invalid 'kind' returned in network status for pod '%s'. Valid value is 'PodNetworkStatus', got '%s'."
,
name
,
findVersion
.
Kind
)
return
nil
,
errors
.
New
(
errStr
)
}
switch
findVersion
.
APIVersion
{
case
""
:
fallthrough
case
"v1beta1"
:
networkStatus
:=
&
network
.
PodNetworkStatus
{}
err
=
json
.
Unmarshal
(
out
,
networkStatus
)
return
networkStatus
,
err
}
errStr
:=
fmt
.
Sprintf
(
"Unknown version '%s' in network status for pod '%s'."
,
findVersion
.
APIVersion
,
name
)
return
nil
,
errors
.
New
(
errStr
)
}
pkg/kubelet/network/exec/exec_test.go
deleted
100644 → 0
View file @
9ce8f10a
This diff is collapsed.
Click to expand it.
pkg/kubelet/network/exec/exec_unix.go
deleted
100644 → 0
View file @
9ce8f10a
// +build !windows
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
exec
import
"syscall"
const
X_OK
=
0x1
func
isExecutable
(
path
string
)
bool
{
return
syscall
.
Access
(
path
,
X_OK
)
==
nil
}
pkg/kubelet/network/exec/exec_unsupported.go
deleted
100644 → 0
View file @
9ce8f10a
// +build windows
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
exec
func
isExecutable
(
path
string
)
bool
{
return
false
}
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