Skip to content

Commit 8b7da17

Browse files
Auto-create openshift-node and given nodes read on node-config
Other config variants will be stored in this location. The new namespace ensures clean security isolation.
1 parent bf63246 commit 8b7da17

10 files changed

+90
-4
lines changed

pkg/cmd/server/bootstrappolicy/constants.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package bootstrappolicy
44
const (
55
DefaultOpenShiftSharedResourcesNamespace = "openshift"
66
DefaultOpenShiftInfraNamespace = "openshift-infra"
7+
DefaultOpenShiftNodeNamespace = "openshift-node"
78
)
89

910
// users
@@ -98,11 +99,13 @@ const (
9899

99100
OpenshiftSharedResourceViewRoleName = "shared-resource-viewer"
100101

101-
NodeBootstrapRoleName = "system:node-bootstrapper"
102+
NodeBootstrapRoleName = "system:node-bootstrapper"
103+
NodeConfigReaderRoleName = "system:node-config-reader"
102104
)
103105

104106
// RoleBindings
105107
const (
108+
// Legacy roles that must continue to have a plural form
106109
SelfAccessReviewerRoleBindingName = SelfAccessReviewerRoleName + "s"
107110
SelfProvisionerRoleBindingName = SelfProvisionerRoleName + "s"
108111
DeployerRoleBindingName = DeployerRoleName + "s"
@@ -128,10 +131,14 @@ const (
128131
RegistryViewerRoleBindingName = RegistryViewerRoleName + "s"
129132
RegistryEditorRoleBindingName = RegistryEditorRoleName + "s"
130133

134+
OpenshiftSharedResourceViewRoleBindingName = OpenshiftSharedResourceViewRoleName + "s"
135+
136+
// Roles beyond this point should not be pluralized
137+
NodeConfigReaderRoleBindingName = NodeConfigReaderRoleName
138+
139+
// Bindings
131140
BuildStrategyDockerRoleBindingName = BuildStrategyDockerRoleName + "-binding"
132141
BuildStrategyCustomRoleBindingName = BuildStrategyCustomRoleName + "-binding"
133142
BuildStrategySourceRoleBindingName = BuildStrategySourceRoleName + "-binding"
134143
BuildStrategyJenkinsPipelineRoleBindingName = BuildStrategyJenkinsPipelineRoleName + "-binding"
135-
136-
OpenshiftSharedResourceViewRoleBindingName = OpenshiftSharedResourceViewRoleName + "s"
137144
)

pkg/cmd/server/bootstrappolicy/namespace_policy.go

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func buildNamespaceRolesAndBindings() (map[string][]rbac.Role, map[string][]rbac
6767
DefaultOpenShiftSharedResourcesNamespace,
6868
newOriginRoleBinding(OpenshiftSharedResourceViewRoleBindingName, OpenshiftSharedResourceViewRoleName, DefaultOpenShiftSharedResourcesNamespace).Groups(AuthenticatedGroup).BindingOrDie())
6969

70+
addNamespaceRoleBinding(namespaceRoleBindings,
71+
DefaultOpenShiftNodeNamespace,
72+
newOriginRoleBinding(NodeConfigReaderRoleBindingName, NodeConfigReaderRoleName, DefaultOpenShiftNodeNamespace).Groups(NodesGroup).BindingOrDie())
73+
7074
return namespaceRoles, namespaceRoleBindings
7175
}
7276

pkg/cmd/server/bootstrappolicy/policy.go

+9
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,15 @@ func GetOpenshiftBootstrapClusterRoles() []rbac.ClusterRole {
664664
// TODO: expose other things like /healthz on the node once we figure out non-resource URL policy across systems
665665
},
666666
},
667+
{
668+
ObjectMeta: metav1.ObjectMeta{
669+
Name: NodeConfigReaderRoleName,
670+
},
671+
Rules: []rbac.PolicyRule{
672+
// Allow the reader to read config maps in a given namespace with a given name.
673+
rbac.NewRule("get").Groups(kapiGroup).Resources("configmaps").RuleOrDie(),
674+
},
675+
},
667676
{
668677
ObjectMeta: metav1.ObjectMeta{
669678
Name: NodeRoleName,

pkg/cmd/server/bootstrappolicy/web_console_role_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var rolesToHide = sets.NewString(
4242
"system:node",
4343
"system:node-admin",
4444
"system:node-bootstrapper",
45+
"system:node-config-reader",
4546
"system:node-problem-detector",
4647
"system:node-proxier",
4748
"system:node-reader",

pkg/cmd/server/start/bootstrap_node.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func (o NodeOptions) loadBootstrap(hostnames []string, nodeConfigDir string) err
278278
}
279279

280280
// if there is no node-config.yaml and no server config map, generate one
281-
glog.V(2).Infof("Generating a local configuration since no server config available")
281+
glog.V(2).Infof("Generating a local configuration since no server config or cached config available")
282282
nodeConfig, err := o.NodeArgs.BuildSerializeableNodeConfig()
283283
if err != nil {
284284
return err

test/integration/front_proxy_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func TestFrontProxy(t *testing.T) {
158158
"kube-system",
159159
"openshift",
160160
"openshift-infra",
161+
"openshift-node",
161162
),
162163
},
163164
} {

test/integration/master_routes_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ var expectedIndex = []string{
100100
// "/healthz/poststarthook/extensions/third-party-resources", // Do not enable this controller, we do not support it
101101
"/healthz/poststarthook/generic-apiserver-start-informers",
102102
"/healthz/poststarthook/kube-apiserver-autoregistration",
103+
"/healthz/poststarthook/node.openshift.io-sharednamespace",
103104
"/healthz/poststarthook/oauth.openshift.io-EnsureBootstrapOAuthClients",
104105
"/healthz/poststarthook/project.openshift.io-projectauthorizationcache",
105106
"/healthz/poststarthook/project.openshift.io-projectcache",

test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,21 @@ items:
21772177
verbs:
21782178
- create
21792179
- get
2180+
- apiVersion: rbac.authorization.k8s.io/v1beta1
2181+
kind: ClusterRole
2182+
metadata:
2183+
annotations:
2184+
authorization.openshift.io/system-only: "true"
2185+
rbac.authorization.kubernetes.io/autoupdate: "true"
2186+
creationTimestamp: null
2187+
name: system:node-config-reader
2188+
rules:
2189+
- apiGroups:
2190+
- ""
2191+
resources:
2192+
- configmaps
2193+
verbs:
2194+
- get
21802195
- apiVersion: rbac.authorization.k8s.io/v1beta1
21812196
kind: ClusterRole
21822197
metadata:

test/testdata/bootstrappolicy/bootstrap_namespace_role_bindings.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,20 @@ items:
123123
subjects:
124124
- kind: Group
125125
name: system:authenticated
126+
- apiVersion: rbac.authorization.k8s.io/v1beta1
127+
kind: RoleBinding
128+
metadata:
129+
annotations:
130+
rbac.authorization.kubernetes.io/autoupdate: "true"
131+
creationTimestamp: null
132+
name: system:node-config-reader
133+
namespace: openshift-node
134+
roleRef:
135+
apiGroup: rbac.authorization.k8s.io
136+
kind: Role
137+
name: system:node-config-reader
138+
subjects:
139+
- kind: Group
140+
name: system:nodes
126141
kind: List
127142
metadata: {}

test/testdata/bootstrappolicy/bootstrap_policy_file.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,22 @@ items:
23792379
verbs:
23802380
- create
23812381
- get
2382+
- apiVersion: v1
2383+
kind: ClusterRole
2384+
metadata:
2385+
annotations:
2386+
authorization.openshift.io/system-only: "true"
2387+
openshift.io/reconcile-protect: "false"
2388+
creationTimestamp: null
2389+
name: system:node-config-reader
2390+
rules:
2391+
- apiGroups:
2392+
- ""
2393+
attributeRestrictions: null
2394+
resources:
2395+
- configmaps
2396+
verbs:
2397+
- get
23822398
- apiVersion: v1
23832399
kind: ClusterRole
23842400
metadata:
@@ -7271,5 +7287,22 @@ items:
72717287
- kind: SystemGroup
72727288
name: system:authenticated
72737289
userNames: null
7290+
- apiVersion: v1
7291+
groupNames:
7292+
- system:nodes
7293+
kind: RoleBinding
7294+
metadata:
7295+
annotations:
7296+
openshift.io/reconcile-protect: "false"
7297+
creationTimestamp: null
7298+
name: system:node-config-reader
7299+
namespace: openshift-node
7300+
roleRef:
7301+
name: system:node-config-reader
7302+
namespace: openshift-node
7303+
subjects:
7304+
- kind: SystemGroup
7305+
name: system:nodes
7306+
userNames: null
72747307
kind: List
72757308
metadata: {}

0 commit comments

Comments
 (0)