Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions pkg/daemons/control/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,15 @@ func apiServer(ctx context.Context, cfg *config.Control) error {
argsMap["cert-dir"] = certDir
argsMap["allow-privileged"] = "true"
argsMap["enable-bootstrap-token-auth"] = "true"
if authConfigFile := util.ArgValue("authorization-config", cfg.ExtraAPIArgs); authConfigFile == "" {
logrus.Warn("Not setting kube-apiserver 'authorization-mode' and 'anonymous-auth' flags due to user-provided 'authorization-config' file.")
if util.ArgValue("authorization-config", cfg.ExtraAPIArgs) == "" {
argsMap["authorization-mode"] = strings.Join([]string{modes.ModeNode, modes.ModeRBAC}, ",")
} else {
logrus.Warn("Not setting kube-apiserver 'authorization-mode' flag due to user-provided 'authorization-config' file.")
}
if util.ArgValue("authentication-config", cfg.ExtraAPIArgs) == "" {
argsMap["anonymous-auth"] = "false"
} else {
logrus.Warn("Not setting kube-apiserver 'anonymous-auth' flag due to user-provided 'authentication-config' file.")
}
argsMap["service-account-signing-key-file"] = runtime.ServiceCurrentKey
argsMap["service-cluster-ip-range"] = util.JoinIPNets(cfg.ServiceIPRanges)
Expand Down
7 changes: 4 additions & 3 deletions pkg/daemons/control/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func Test_UnitServer(t *testing.T) {
},
},
{
name: "ControlPlane+Kine with authorization-config",
name: "ControlPlane+Kine with auth config",
setup: func(ctx context.Context, t *testing.T) (*config.Control, error) {
control, err := mockControl(ctx, t, false)
if err != nil {
Expand All @@ -114,10 +114,11 @@ func Test_UnitServer(t *testing.T) {

executor := mock.NewExecutorWithEmbeddedETCD(t)

// authorization-mode and anonymous-auth should not be set when user sets --authorization-config
control.ExtraAPIArgs = []string{"authorization-config=/dev/null"}
// authorization-mode and anonymous-auth should not be set when user sets --authorization-config and --authentication-config
control.ExtraAPIArgs = []string{"authorization-config=/dev/null", "authentication-config=/dev/null"}
matchAuthArgs := mock.GM(And(
ContainElement(ContainSubstring("--authorization-config")),
ContainElement(ContainSubstring("--authentication-config")),
Not(ContainElement(ContainSubstring("--authorization-mode"))),
Not(ContainElement(ContainSubstring("--anonymous-auth"))),
))
Expand Down