Skip to content

Commit 0e78d80

Browse files
committed
targetconfigcontroller: inject authorization-mode just in case observer doesn't run
Signed-off-by: Peter Hunt <[email protected]>
1 parent 386c3c6 commit 0e78d80

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pkg/operator/configobservation/node/observe_authorization_mode.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ var defaultAuthenticationModes = []string{
1616
"RBAC",
1717
"Node",
1818
}
19+
20+
var authenticationModesWithMinimumKubeletVersion = []string{
21+
"Scope",
22+
"SystemMasters",
23+
"RBAC",
24+
ModeMinimumKubeletVersion, // before "Node" to have a chance to deny a node
25+
"Node",
26+
}
1927
var (
2028
authModeFlag = "authorization-mode"
2129
apiServerArgs = "apiServerArguments"
@@ -65,7 +73,7 @@ func (o *authorizationModeObserver) ObserveAuthorizationMode(genericListers conf
6573
func AddAuthorizationModes(observedConfig map[string]interface{}, isMinimumKubeletVersionEnabled bool) error {
6674
modes := defaultAuthenticationModes
6775
if isMinimumKubeletVersionEnabled {
68-
modes = append(modes, ModeMinimumKubeletVersion)
76+
modes = authenticationModesWithMinimumKubeletVersion
6977
}
7078

7179
unstructured.RemoveNestedField(observedConfig, authModePath...)

pkg/operator/targetconfigcontroller/targetconfigcontroller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
1818
operatorv1 "github.com/openshift/api/operator/v1"
1919
"github.com/openshift/cluster-kube-apiserver-operator/bindata"
20+
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation/node"
2021
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/operatorclient"
2122
"github.com/openshift/cluster-kube-apiserver-operator/pkg/version"
2223
"github.com/openshift/library-go/pkg/controller/factory"
@@ -228,12 +229,21 @@ func manageKubeAPIServerConfig(ctx context.Context, client coreclientv1.ConfigMa
228229
configOverrides := bindata.MustAsset("assets/config/config-overrides.yaml")
229230
specialMergeRules := map[string]resourcemerge.MergeFunc{}
230231

232+
// Guarantee the authorization-mode will be present in the base config, regardless of whether the observer is running
233+
authModeOverride := map[string]interface{}{}
234+
node.AddAuthorizationModes(authModeOverride, false)
235+
authModeOverrideJSON, err := json.Marshal(authModeOverride)
236+
if err != nil {
237+
return nil, false, err
238+
}
239+
231240
requiredConfigMap, _, err := resourcemerge.MergePrunedConfigMap(
232241
&kubecontrolplanev1.KubeAPIServerConfig{},
233242
configMap,
234243
"config.yaml",
235244
specialMergeRules,
236245
defaultConfig,
246+
authModeOverrideJSON,
237247
configOverrides,
238248
operatorSpec.ObservedConfig.Raw,
239249
operatorSpec.UnsupportedConfigOverrides.Raw,

0 commit comments

Comments
 (0)