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
709e6546
Commit
709e6546
authored
Aug 24, 2015
by
Paul Weil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use privileged source object
parent
4c88aeed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
11 deletions
+31
-11
server.go
cmd/kube-apiserver/app/server.go
+3
-1
server.go
cmd/kubelet/app/server.go
+5
-1
capabilities.go
pkg/capabilities/capabilities.go
+16
-6
kubelet_test.go
pkg/kubelet/kubelet_test.go
+6
-2
util.go
pkg/kubelet/util.go
+1
-1
No files found.
cmd/kube-apiserver/app/server.go
View file @
709e6546
...
...
@@ -294,7 +294,9 @@ func (s *APIServer) Run(_ []string) error {
capabilities
.
Initialize
(
capabilities
.
Capabilities
{
AllowPrivileged
:
s
.
AllowPrivileged
,
// TODO(vmarmol): Implement support for HostNetworkSources.
HostNetworkSources
:
[]
string
{},
PrivilegedSources
:
capabilities
.
PrivilegedSources
{
HostNetworkSources
:
[]
string
{},
},
PerConnectionBandwidthLimitBytesPerSec
:
s
.
MaxConnectionBytesPerSec
,
})
...
...
cmd/kubelet/app/server.go
View file @
709e6546
...
...
@@ -642,7 +642,11 @@ func RunKubelet(kcfg *KubeletConfig, builder KubeletBuilder) error {
}
else
{
glog
.
Warning
(
"No api server defined - no events will be sent to API server."
)
}
capabilities
.
Setup
(
kcfg
.
AllowPrivileged
,
kcfg
.
HostNetworkSources
,
0
)
privilegedSources
:=
capabilities
.
PrivilegedSources
{
HostNetworkSources
:
kcfg
.
HostNetworkSources
,
}
capabilities
.
Setup
(
kcfg
.
AllowPrivileged
,
privilegedSources
,
0
)
credentialprovider
.
SetPreferredDockercfgPath
(
kcfg
.
RootDirectory
)
...
...
pkg/capabilities/capabilities.go
View file @
709e6546
...
...
@@ -25,13 +25,21 @@ import (
type
Capabilities
struct
{
AllowPrivileged
bool
// List of pod sources for which using host network is allowed.
HostNetworkSources
[]
string
// Pod sources from which to allow privileged capabilities like host networking, sharing the host
// IPC namespace, and sharing the host PID namespace.
PrivilegedSources
PrivilegedSources
// PerConnectionBandwidthLimitBytesPerSec limits the throughput of each connection (currently only used for proxy, exec, attach)
PerConnectionBandwidthLimitBytesPerSec
int64
}
// PrivilegedSources defines the pod sources allowed to make privileged requests for certain types
// of capabilities like host networking, sharing the host IPC namespace, and sharing the host PID namespace.
type
PrivilegedSources
struct
{
// List of pod sources for which using host network is allowed.
HostNetworkSources
[]
string
}
// TODO: Clean these up into a singleton
var
once
sync
.
Once
var
lock
sync
.
Mutex
...
...
@@ -46,10 +54,10 @@ func Initialize(c Capabilities) {
}
// Setup the capability set. It wraps Initialize for improving usibility.
func
Setup
(
allowPrivileged
bool
,
hostNetworkSources
[]
string
,
perConnectionBytesPerSec
int64
)
{
func
Setup
(
allowPrivileged
bool
,
privilegedSources
PrivilegedSources
,
perConnectionBytesPerSec
int64
)
{
Initialize
(
Capabilities
{
AllowPrivileged
:
allowPrivileged
,
HostNetworkSources
:
hostNetwork
Sources
,
PrivilegedSources
:
privileged
Sources
,
PerConnectionBandwidthLimitBytesPerSec
:
perConnectionBytesPerSec
,
})
}
...
...
@@ -68,8 +76,10 @@ func Get() Capabilities {
// This check prevents clobbering of capabilities that might've been set via SetForTests
if
capabilities
==
nil
{
Initialize
(
Capabilities
{
AllowPrivileged
:
false
,
HostNetworkSources
:
[]
string
{},
AllowPrivileged
:
false
,
PrivilegedSources
:
PrivilegedSources
{
HostNetworkSources
:
[]
string
{},
},
})
}
return
*
capabilities
...
...
pkg/kubelet/kubelet_test.go
View file @
709e6546
...
...
@@ -2828,7 +2828,9 @@ func TestHostNetworkAllowed(t *testing.T) {
kubelet
:=
testKubelet
.
kubelet
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
HostNetworkSources
:
[]
string
{
ApiserverSource
,
FileSource
},
PrivilegedSources
:
capabilities
.
PrivilegedSources
{
HostNetworkSources
:
[]
string
{
ApiserverSource
,
FileSource
},
},
})
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
@@ -2858,7 +2860,9 @@ func TestHostNetworkDisallowed(t *testing.T) {
kubelet
:=
testKubelet
.
kubelet
capabilities
.
SetForTests
(
capabilities
.
Capabilities
{
HostNetworkSources
:
[]
string
{},
PrivilegedSources
:
capabilities
.
PrivilegedSources
{
HostNetworkSources
:
[]
string
{},
},
})
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
...
...
pkg/kubelet/util.go
View file @
709e6546
...
...
@@ -66,7 +66,7 @@ func allowHostNetwork(pod *api.Pod) (bool, error) {
if
err
!=
nil
{
return
false
,
err
}
for
_
,
source
:=
range
capabilities
.
Get
()
.
HostNetworkSources
{
for
_
,
source
:=
range
capabilities
.
Get
()
.
PrivilegedSources
.
HostNetworkSources
{
if
source
==
podSource
{
return
true
,
nil
}
...
...
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