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
0022223d
Commit
0022223d
authored
May 02, 2017
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose kubelet authentication and authorization builders
parent
2689f033
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
auth.go
cmd/kubelet/app/auth.go
+8
-5
server.go
cmd/kubelet/app/server.go
+1
-1
No files found.
cmd/kubelet/app/auth.go
View file @
0022223d
...
@@ -34,7 +34,8 @@ import (
...
@@ -34,7 +34,8 @@ import (
"k8s.io/kubernetes/pkg/kubelet/server"
"k8s.io/kubernetes/pkg/kubelet/server"
)
)
func
buildAuth
(
nodeName
types
.
NodeName
,
client
clientset
.
Interface
,
config
componentconfig
.
KubeletConfiguration
)
(
server
.
AuthInterface
,
error
)
{
// BuildAuth creates an authenticator, an authorizer, and a matching authorizer attributes getter compatible with the kubelet's needs
func
BuildAuth
(
nodeName
types
.
NodeName
,
client
clientset
.
Interface
,
config
componentconfig
.
KubeletConfiguration
)
(
server
.
AuthInterface
,
error
)
{
// Get clients, if provided
// Get clients, if provided
var
(
var
(
tokenClient
authenticationclient
.
TokenReviewInterface
tokenClient
authenticationclient
.
TokenReviewInterface
...
@@ -45,14 +46,14 @@ func buildAuth(nodeName types.NodeName, client clientset.Interface, config compo
...
@@ -45,14 +46,14 @@ func buildAuth(nodeName types.NodeName, client clientset.Interface, config compo
sarClient
=
client
.
AuthorizationV1beta1
()
.
SubjectAccessReviews
()
sarClient
=
client
.
AuthorizationV1beta1
()
.
SubjectAccessReviews
()
}
}
authenticator
,
err
:=
b
uildAuthn
(
tokenClient
,
config
.
Authentication
)
authenticator
,
err
:=
B
uildAuthn
(
tokenClient
,
config
.
Authentication
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
attributes
:=
server
.
NewNodeAuthorizerAttributesGetter
(
nodeName
)
attributes
:=
server
.
NewNodeAuthorizerAttributesGetter
(
nodeName
)
authorizer
,
err
:=
b
uildAuthz
(
sarClient
,
config
.
Authorization
)
authorizer
,
err
:=
B
uildAuthz
(
sarClient
,
config
.
Authorization
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -60,7 +61,8 @@ func buildAuth(nodeName types.NodeName, client clientset.Interface, config compo
...
@@ -60,7 +61,8 @@ func buildAuth(nodeName types.NodeName, client clientset.Interface, config compo
return
server
.
NewKubeletAuth
(
authenticator
,
attributes
,
authorizer
),
nil
return
server
.
NewKubeletAuth
(
authenticator
,
attributes
,
authorizer
),
nil
}
}
func
buildAuthn
(
client
authenticationclient
.
TokenReviewInterface
,
authn
componentconfig
.
KubeletAuthentication
)
(
authenticator
.
Request
,
error
)
{
// BuildAuthn creates an authenticator compatible with the kubelet's needs
func
BuildAuthn
(
client
authenticationclient
.
TokenReviewInterface
,
authn
componentconfig
.
KubeletAuthentication
)
(
authenticator
.
Request
,
error
)
{
authenticatorConfig
:=
authenticatorfactory
.
DelegatingAuthenticatorConfig
{
authenticatorConfig
:=
authenticatorfactory
.
DelegatingAuthenticatorConfig
{
Anonymous
:
authn
.
Anonymous
.
Enabled
,
Anonymous
:
authn
.
Anonymous
.
Enabled
,
CacheTTL
:
authn
.
Webhook
.
CacheTTL
.
Duration
,
CacheTTL
:
authn
.
Webhook
.
CacheTTL
.
Duration
,
...
@@ -78,7 +80,8 @@ func buildAuthn(client authenticationclient.TokenReviewInterface, authn componen
...
@@ -78,7 +80,8 @@ func buildAuthn(client authenticationclient.TokenReviewInterface, authn componen
return
authenticator
,
err
return
authenticator
,
err
}
}
func
buildAuthz
(
client
authorizationclient
.
SubjectAccessReviewInterface
,
authz
componentconfig
.
KubeletAuthorization
)
(
authorizer
.
Authorizer
,
error
)
{
// BuildAuthz creates an authorizer compatible with the kubelet's needs
func
BuildAuthz
(
client
authorizationclient
.
SubjectAccessReviewInterface
,
authz
componentconfig
.
KubeletAuthorization
)
(
authorizer
.
Authorizer
,
error
)
{
switch
authz
.
Mode
{
switch
authz
.
Mode
{
case
componentconfig
.
KubeletAuthorizationModeAlwaysAllow
:
case
componentconfig
.
KubeletAuthorizationModeAlwaysAllow
:
return
authorizerfactory
.
NewAlwaysAllowAuthorizer
(),
nil
return
authorizerfactory
.
NewAlwaysAllowAuthorizer
(),
nil
...
...
cmd/kubelet/app/server.go
View file @
0022223d
...
@@ -489,7 +489,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.KubeletDeps) (err error) {
...
@@ -489,7 +489,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.KubeletDeps) (err error) {
}
}
if
kubeDeps
.
Auth
==
nil
{
if
kubeDeps
.
Auth
==
nil
{
auth
,
err
:=
b
uildAuth
(
nodeName
,
kubeDeps
.
ExternalKubeClient
,
s
.
KubeletConfiguration
)
auth
,
err
:=
B
uildAuth
(
nodeName
,
kubeDeps
.
ExternalKubeClient
,
s
.
KubeletConfiguration
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
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