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
d3991aa7
Unverified
Commit
d3991aa7
authored
Nov 03, 2016
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup auth logging, allow starting secured kubelet in local-up-cluster.sh
parent
c4eb04af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
7 deletions
+31
-7
local-up-cluster.sh
hack/local-up-cluster.sh
+24
-0
authz.go
pkg/genericapiserver/authorizer/authz.go
+1
-1
server.go
pkg/kubelet/server/server.go
+3
-3
accessreview_test.go
test/integration/auth/accessreview_test.go
+3
-3
No files found.
hack/local-up-cluster.sh
View file @
d3991aa7
...
...
@@ -340,6 +340,10 @@ function start_apiserver {
if
[[
-n
"
${
RUNTIME_CONFIG
}
"
]]
;
then
runtime_config
=
"--runtime-config=
${
RUNTIME_CONFIG
}
"
fi
client_ca_file_arg
=
""
if
[[
-n
"
${
CLIENT_CA_FILE
:-}
"
]]
;
then
client_ca_file_arg
=
"--client-ca-file=
${
CLIENT_CA_FILE
}
"
fi
# Let the API server pick a default address when API_HOST
# is set to 127.0.0.1
...
...
@@ -354,6 +358,7 @@ function start_apiserver {
APISERVER_LOG
=
/tmp/kube-apiserver.log
sudo
-E
"
${
GO_OUT
}
/hyperkube"
apiserver
${
anytoken_arg
}
${
authorizer_arg
}
${
priv_arg
}
${
runtime_config
}
\
${
client_ca_file_arg
}
\
${
advertise_address
}
\
--v
=
${
LOG_LEVEL
}
\
--cert-dir
=
"
${
CERT_DIR
}
"
\
...
...
@@ -382,9 +387,16 @@ clusters:
certificate-authority:
${
ROOT_CA_FILE
}
server: https://
${
API_HOST
}
:
${
API_SECURE_PORT
}
/
name: local-up-cluster
users:
- user:
token:
${
KUBECONFIG_TOKEN
:-}
client-certificate:
${
KUBECONFIG_CLIENT_CERTIFICATE
:-}
client-key:
${
KUBECONFIG_CLIENT_KEY
:-}
name: local-up-cluster
contexts:
- context:
cluster: local-up-cluster
user: local-up-cluster
name: service-to-apiserver
current-context: service-to-apiserver
EOF
...
...
@@ -441,6 +453,17 @@ function start_kubelet {
net_plugin_args
=
"--network-plugin=
${
NET_PLUGIN
}
"
fi
auth_args
=
""
if
[[
-n
"
${
KUBELET_AUTHORIZATION_WEBHOOK
}
"
]]
;
then
auth_args
=
"
${
auth_args
}
--authorization-mode=Webhook"
fi
if
[[
-n
"
${
KUBELET_AUTHENTICATION_WEBHOOK
}
"
]]
;
then
auth_args
=
"
${
auth_args
}
--authentication-token-webhook"
fi
if
[[
-n
"
${
CLIENT_CA_FILE
:-}
"
]]
;
then
auth_args
=
"
${
auth_args
}
--client-ca-file=
${
CLIENT_CA_FILE
}
"
fi
net_plugin_dir_args
=
""
if
[[
-n
"
${
NET_PLUGIN_DIR
}
"
]]
;
then
net_plugin_dir_args
=
"--network-plugin-dir=
${
NET_PLUGIN_DIR
}
"
...
...
@@ -475,6 +498,7 @@ function start_kubelet {
--cgroups-per-qos
=
${
CGROUPS_PER_QOS
}
\
--cgroup-driver
=
${
CGROUP_DRIVER
}
\
--cgroup-root
=
${
CGROUP_ROOT
}
\
${
auth_args
}
\
${
dns_args
}
\
${
net_plugin_dir_args
}
\
${
net_plugin_args
}
\
...
...
pkg/genericapiserver/authorizer/authz.go
View file @
d3991aa7
...
...
@@ -84,7 +84,7 @@ func (r *privilegedGroupAuthorizer) Authorize(attr authorizer.Attributes) (bool,
}
}
}
return
false
,
"
Not in privileged list.
"
,
nil
return
false
,
""
,
nil
}
// NewPrivilegedGroups is for use in loopback scenarios
...
...
pkg/kubelet/server/server.go
View file @
d3991aa7
...
...
@@ -223,15 +223,15 @@ func (s *Server) InstallAuthFilter() {
attrs
:=
s
.
auth
.
GetRequestAttributes
(
u
,
req
.
Request
)
// Authorize
authorized
,
reason
,
err
:=
s
.
auth
.
Authorize
(
attrs
)
authorized
,
_
,
err
:=
s
.
auth
.
Authorize
(
attrs
)
if
err
!=
nil
{
msg
:=
fmt
.
Sprintf
(
"
Error (user=%s, verb=%s, namespace=%s, resource=%s)"
,
u
.
GetName
(),
attrs
.
GetVerb
(),
attrs
.
GetNamespace
(),
attrs
.
GetR
esource
())
msg
:=
fmt
.
Sprintf
(
"
Authorization error (user=%s, verb=%s, resource=%s, subresource=%s)"
,
u
.
GetName
(),
attrs
.
GetVerb
(),
attrs
.
GetResource
(),
attrs
.
GetSubr
esource
())
glog
.
Errorf
(
msg
,
err
)
resp
.
WriteErrorString
(
http
.
StatusInternalServerError
,
msg
)
return
}
if
!
authorized
{
msg
:=
fmt
.
Sprintf
(
"Forbidden (
reason=%s, user=%s, verb=%s, namespace=%s, resource=%s)"
,
reason
,
u
.
GetName
(),
attrs
.
GetVerb
(),
attrs
.
GetNamespace
(),
attrs
.
GetR
esource
())
msg
:=
fmt
.
Sprintf
(
"Forbidden (
user=%s, verb=%s, resource=%s, subresource=%s)"
,
u
.
GetName
(),
attrs
.
GetVerb
(),
attrs
.
GetResource
(),
attrs
.
GetSubr
esource
())
glog
.
V
(
2
)
.
Info
(
msg
)
resp
.
WriteErrorString
(
http
.
StatusForbidden
,
msg
)
return
...
...
test/integration/auth/accessreview_test.go
View file @
d3991aa7
...
...
@@ -103,7 +103,7 @@ func TestSubjectAccessReview(t *testing.T) {
},
expectedStatus
:
authorizationapi
.
SubjectAccessReviewStatus
{
Allowed
:
false
,
Reason
:
"
Not in privileged list.
\n
no"
,
Reason
:
"no"
,
EvaluationError
:
"I'm sorry, Dave"
,
},
},
...
...
@@ -198,7 +198,7 @@ func TestSelfSubjectAccessReview(t *testing.T) {
},
expectedStatus
:
authorizationapi
.
SubjectAccessReviewStatus
{
Allowed
:
false
,
Reason
:
"
Not in privileged list.
\n
no"
,
Reason
:
"no"
,
EvaluationError
:
"I'm sorry, Dave"
,
},
},
...
...
@@ -284,7 +284,7 @@ func TestLocalSubjectAccessReview(t *testing.T) {
},
expectedStatus
:
authorizationapi
.
SubjectAccessReviewStatus
{
Allowed
:
false
,
Reason
:
"
Not in privileged list.
\n
no"
,
Reason
:
"no"
,
EvaluationError
:
"I'm sorry, Dave"
,
},
},
...
...
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