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
d95c7779
Commit
d95c7779
authored
May 15, 2018
by
lalyos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: APIServerExtraArgs should override defaultArguments
parent
6187898b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
25 deletions
+23
-25
BUILD
cmd/kubeadm/app/phases/controlplane/BUILD
+2
-0
manifests.go
cmd/kubeadm/app/phases/controlplane/manifests.go
+21
-25
manifests_test.go
cmd/kubeadm/app/phases/controlplane/manifests_test.go
+0
-0
No files found.
cmd/kubeadm/app/phases/controlplane/BUILD
View file @
d95c7779
...
...
@@ -19,9 +19,11 @@ go_test(
"//cmd/kubeadm/app/features:go_default_library",
"//cmd/kubeadm/app/phases/certs:go_default_library",
"//cmd/kubeadm/test:go_default_library",
"//pkg/kubeapiserver/authorizer/modes:go_default_library",
"//pkg/util/pointer:go_default_library",
"//pkg/util/version:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
],
)
...
...
cmd/kubeadm/app/phases/controlplane/manifests.go
View file @
d95c7779
...
...
@@ -27,7 +27,6 @@ import (
"github.com/golang/glog"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapiv1alpha2
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha2"
kubeadmconstants
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
...
...
@@ -217,13 +216,32 @@ func getAPIServerCommand(cfg *kubeadmapi.MasterConfiguration) []string {
defaultArguments
[
"audit-log-maxage"
]
=
fmt
.
Sprintf
(
"%d"
,
*
cfg
.
AuditPolicyConfiguration
.
LogMaxAge
)
}
}
if
cfg
.
APIServerExtraArgs
==
nil
{
cfg
.
APIServerExtraArgs
=
map
[
string
]
string
{}
}
cfg
.
APIServerExtraArgs
[
"authorization-mode"
]
=
getAuthzModes
(
cfg
.
APIServerExtraArgs
[
"authorization-mode"
])
command
=
append
(
command
,
kubeadmutil
.
BuildArgumentListFromMap
(
defaultArguments
,
cfg
.
APIServerExtraArgs
)
...
)
command
=
append
(
command
,
getAuthzParameters
(
cfg
.
AuthorizationModes
)
...
)
return
command
}
// getAuthzModes gets the authorization-related parameters to the api server
// Node,RBAC should be fixed in this order at the beginning
// AlwaysAllow and AlwaysDeny is ignored as they are only for testing
func
getAuthzModes
(
authzModeExtraArgs
string
)
string
{
modes
:=
[]
string
{
authzmodes
.
ModeNode
,
authzmodes
.
ModeRBAC
,
}
if
strings
.
Contains
(
authzModeExtraArgs
,
authzmodes
.
ModeABAC
)
{
modes
=
append
(
modes
,
authzmodes
.
ModeABAC
)
}
if
strings
.
Contains
(
authzModeExtraArgs
,
authzmodes
.
ModeWebhook
)
{
modes
=
append
(
modes
,
authzmodes
.
ModeWebhook
)
}
return
strings
.
Join
(
modes
,
","
)
}
// calcNodeCidrSize determines the size of the subnets used on each node, based
// on the pod subnet provided. For IPv4, we assume that the pod subnet will
// be /16 and use /24. If the pod subnet cannot be parsed, the IPv4 value will
...
...
@@ -335,25 +353,3 @@ func getProxyEnvVars() []v1.EnvVar {
}
return
envs
}
// getAuthzParameters gets the authorization-related parameters to the api server
// At this point, we can assume the list of authorization modes is valid (due to that it has been validated in the API machinery code already)
// If the list is empty; it's defaulted (mostly for unit testing)
func
getAuthzParameters
(
modes
[]
string
)
[]
string
{
command
:=
[]
string
{}
strset
:=
sets
.
NewString
(
modes
...
)
if
len
(
modes
)
==
0
{
return
[]
string
{
fmt
.
Sprintf
(
"--authorization-mode=%s"
,
kubeadmapiv1alpha2
.
DefaultAuthorizationModes
)}
}
if
strset
.
Has
(
authzmodes
.
ModeABAC
)
{
command
=
append
(
command
,
"--authorization-policy-file="
+
kubeadmconstants
.
AuthorizationPolicyPath
)
}
if
strset
.
Has
(
authzmodes
.
ModeWebhook
)
{
command
=
append
(
command
,
"--authorization-webhook-config-file="
+
kubeadmconstants
.
AuthorizationWebhookConfigPath
)
}
command
=
append
(
command
,
"--authorization-mode="
+
strings
.
Join
(
modes
,
","
))
return
command
}
cmd/kubeadm/app/phases/controlplane/manifests_test.go
View file @
d95c7779
This diff is collapsed.
Click to expand it.
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