Skip to content

Commit f518404

Browse files
deads2kbertinatto
authored andcommitted
UPSTREAM: <carry>: openshift-kube-apiserver: add kube-apiserver patches
UPSTREAM: <carry>: openshift-kube-apiserver: enabled conversion gen for admission configs UPSTREAM: <carry>: openshift-kube-apiserver/admission: fix featuregates resource name UPSTREAM: <carry>: openshift-kube-apiserver/admission: add missing FeatureSets UPSTREAM: <carry>: openshift-kube-apiserver: use github.com/openshift/apiserver-library-go/pkg/labelselector UPSTREAM: <carry>: openshift authenticator: don't allow old-style tokens UPSTREAM: <carry>: oauth-authn: support sha256 prefixed tokens UPSTREAM: <carry>: oauth-token-authn: switch to sha256~ prefix UPSTREAM: <carry>: oauth-token-authn: add sha256~ support to bootstrap authenticator UPSTREAM: <drop>: remove the openshift authenticator from the apiserver In 4.8, we moved the authenticator to be configured via webhookTokenAuthenticators to an endpoint in the oauth-apiserver, this should now be safe to remove. UPSTREAM: <carry>: set ResourceQuotaValidationOptions to true When PodAffinityNamespaceSelector goes to beta or GA this might affect how our ClusterResourceQuota might work UPSTREAM: <carry>: simplify the authorizer patch to allow the flags to function UPSTREAM: <carry>: eliminate unnecessary closure in openshift configuration wiring UPSTREAM: <carry>: add crdvalidation for apiserver.spec.tlsSecurityProfile UPSTREAM: <carry>: openshift-kube-apiserver: Add custom resource validation for network spec UPSTREAM: <carry>: stop overriding flags that are explicitly set UPSTREAM: <carry>: add readyz check for openshift apiserver availability UPSTREAM: <carry>: wait for oauth-apiserver accessibility UPSTREAM: <carry>: provide a new admission plugin to mutate management pods CPUs requests The ManagementCPUOverride admission plugin replaces pod container CPU requests with a new management resource. It applies to all pods that: 1. are in an allowed namespace 2. and have the workload annotation. It also sets the new management resource request and limit and set resource annotation that CRI-O can recognize and apply the relevant changes. For more information, see - openshift/enhancements#703 Conditions for CPUs requests deletion: 1. The namespace should have allowed annotation "workload.openshift.io/allowed": "management" 2. The pod should have management annotation: "workload.openshift.io/management": "{"effect": "PreferredDuringScheduling"}" 3. All nodes under the cluster should have new management resource - "management.workload.openshift.io/cores" 4. The CPU request deletion will not change the pod QoS class UPSTREAM: <carry>: Does not prevent pod creation because of no nodes reason when it runs under the regular cluster Check the `cluster` infrastructure resource status to be sure that we run on top of a SNO cluster and in case if the pod runs on top of regular cluster, exit before node existence check. UPSTREAM: <carry>: do not mutate pods when it has a container with both CPU request and limit Removing the CPU request from the container that has a CPU limit will result in the defaulter to set the CPU request back equals to the CPU limit. UPSTREAM: <carry>: Reject the pod creation when we can not decide the cluster type It is possible a race condition between pod creation and the update of the infrastructure resource status with correct values under Status.ControlPlaneTopology and Status.InfrastructureTopology. UPSTREAM: <carry>: add CRD validation for dnses Add an admission plugin that validates the dnses.operator.openshift.io custom resource. For now, the plugin only validates the DNS pod node-placement parameters. This commit fixes bug 1967745. https://bugzilla.redhat.com/show_bug.cgi?id=1967745 * openshift-kube-apiserver/admission/customresourcevalidation/attributes.go (init): Install operatorv1 into supportedObjectsScheme. * openshift-kube-apiserver/admission/customresourcevalidation/customresourcevalidationregistration/cr_validation_registration.go (AllCustomResourceValidators, RegisterCustomResourceValidation): Register the new plugin. * openshift-kube-apiserver/admission/customresourcevalidation/dns/validate_dns.go: New file. (PluginName): New const. (Register): New function. Register the plugin. (toDNSV1): New function. Convert a runtime object to a versioned DNS. (dnsV1): New type to represent a runtime object that is validated as a versioned DNS. (ValidateCreate, ValidateUpdate, ValidateStatusUpdate): New methods. Implement the ObjectValidator interface, using the validateDNSSpecCreate and validateDNSSpecUpdate helpers. (validateDNSSpecCreate, validateDNSSpecUpdate): New functions. Validate a DNS, using the validateDNSSpec helper. (validateDNSSpec): New function. Validate the spec field of a DNS, using the validateDNSNodePlacement helper. (validateDNSNodePlacement): New function. Validate the node selector and tolerations in a DNS's node-placement parameters, using validateTolerations. (validateTolerations): New function. Validate a slice of corev1.Toleration. * openshift-kube-apiserver/admission/customresourcevalidation/dns/validate_dns_test.go: New file. (TestFailValidateDNSSpec): Verify that validateDNSSpec rejects invalid DNS specs. (TestSucceedValidateDNSSpec): Verify that validateDNSSpec accepts valid DNS specs. * vendor/*: Regenerate. UPSTREAM: <carry>: prevent the kubecontrollermanager service-ca from getting less secure UPSTREAM: <carry>: allow SCC to be disabled on a per-namespace basis UPSTREAM: <carry>: verify required http2 cipher suites In the Apiserver admission, we need to return an error if the required http2 cipher suites are missing from a custom tlsSecurityProfile. Currently, custom cipher suites missing ECDHE_RSA_WITH_AES_128_GCM_SHA256 or ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 result in invalid http2 Server configuration causing the apiservers to crash. See: go/x/net/http2.ConfigureServer for futher information. UPSTREAM: <carry>: drop the warning to use --keep-annotations When a user runs the `oc debug` command for the pod with the management resource, we will inform him that he should pass `--keep-annotations` parameter to the debug command. UPSTREAM: <carry>: admission/managementcpusoverride: cover the roll-back case During the upgrade and roll-back flow 4.7->4.8->4.7, the topology related fields under the infrastructure can be empty because the old API does not support them. The code will equal the empty infrastructure section with the current one. When the status has some other non-empty field, and topology fields are empty, we assume that the cluster currently passes via roll-back and not via the clean install. UPSTREAM: <carry>: Remove pod warning annotation when workload partitioning is disabled UPSTREAM: <carry>: use new access token inactivity timeout field. UPSTREAM: <carry>: apirequestcount validation UPSTREAM: <carry>: Added config node object validation for extreme latency profiles UPSTREAM: <carry>: Add Upstream validation in the DNS admission check patches UPSTREAM: <carry>: Make RestrictedEndpointsAdmission check NotReadyAddresses UPSTREAM: <carry>: Make RestrictedEndpointsAdmission restrict EndpointSlices as well Moved SkipSystemMasterAuthorizers to the authorizer. UPSTREAM: <carry>: Add validation plugin for CRD-based route parity. UPSTREAM: <carry>: Add host assignment plugin for CRD-based routes. UPSTREAM: <carry>: Apply shared defaulters to CRD-based routes. Signed-off-by: Artyom Lukianov <[email protected]> Signed-off-by: Damien Grisonnet <[email protected]> Signed-off-by: Swarup Ghosh <[email protected]> OpenShift-Rebase-Source: 932411e OpenShift-Rebase-Source: 1899555 OpenShift-Rebase-Source: 453583e OpenShift-Rebase-Source: bf7e23e UPSTREAM: <carry>: STOR-829: Add CSIInlineVolumeSecurity admission plugin The CSIInlineVolumeSecurity admission plugin inspects inline CSI volumes on pod creation and compares the security.openshift.io/csi-ephemeral-volume-profile label on the CSIDriver object to the pod security profile on the namespace. OpenShift-Rebase-Source: a65c34b UPSTREAM: <carry>: add icsp,idms,itms validation reject creating icsp with idms/itms exist Reject icsp with idms.itms resources exists. According to the discuusion resolution https://docs.google.com/document/d/13h6IJn8wlzXdiPMvCWlMEHOXXqEZ9_GYOl02Wldb3z8/edit?usp=sharing, one of current icsp or new mirror setting crd should be rejected if a user tries to use them on the same cluster. Signed-off-by: Qi Wang <[email protected]> UPSTREAM: <carry>: node admission plugin for cpu partitioning The ManagedNode admission plugin makes the Infrastructure.Status.CPUPartitioning field authoritative. This validates that nodes that wish to join the cluster are first configured to properly handle workload pinning For more information see - openshift/enhancements#1213 Signed-off-by: ehila <[email protected]> UPSTREAM: <carry>: kube-apiserver: allow injection of kube-apiserver options UPSTREAM: <carry>: kube-apiserver: allow rewiring OpenShift-Rebase-Source: 56b49c9 OpenShift-Rebase-Source: bcf574c UPSTREAM: <carry>: openshift-kube-apiserver: add kube-apiserver patches UPSTREAM: <carry>: openshift-kube-apiserver: add kube-apiserver patches initialize DefaultComponentGlobalsRegistry after feature gates have been parsed from the config
1 parent 4174ae4 commit f518404

File tree

12 files changed

+180
-11
lines changed

12 files changed

+180
-11
lines changed

cmd/kube-apiserver/app/options/options.go

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ type Extra struct {
6060
EndpointReconcilerType string
6161

6262
MasterCount int
63+
64+
OpenShiftConfig string
6365
}
6466

6567
// NewServerRunOptions creates and returns ServerRunOptions according to the given featureGate and effectiveVersion of the server binary to run.
@@ -153,5 +155,9 @@ func (s *ServerRunOptions) Flags() (fss cliflag.NamedFlagSets) {
153155
"The number of apiservers running in the cluster, must be a positive number. (In use when --endpoint-reconciler-type=master-count is enabled.)")
154156
fs.MarkDeprecated("apiserver-count", "apiserver-count is deprecated and will be removed in a future version.")
155157

158+
fs.StringVar(&s.OpenShiftConfig, "openshift-config", s.OpenShiftConfig, "config for openshift")
159+
fs.MarkDeprecated("openshift-config", "to be removed")
160+
fs.MarkHidden("openshift-config")
161+
156162
return fss
157163
}

cmd/kube-apiserver/app/server.go

+37
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import (
2525
"net/url"
2626
"os"
2727

28+
"k8s.io/kubernetes/openshift-kube-apiserver/admission/admissionenablement"
29+
"k8s.io/kubernetes/openshift-kube-apiserver/enablement"
30+
"k8s.io/kubernetes/openshift-kube-apiserver/openshiftkubeapiserver"
31+
2832
"github.com/spf13/cobra"
2933
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3034
utilerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -98,6 +102,39 @@ cluster's shared state through which all other components interact.`,
98102
}
99103
cliflag.PrintFlags(fs)
100104

105+
if len(s.OpenShiftConfig) > 0 {
106+
// if we are running openshift, we modify the admission chain defaults accordingly
107+
admissionenablement.InstallOpenShiftAdmissionPlugins(s)
108+
109+
openshiftConfig, err := enablement.GetOpenshiftConfig(s.OpenShiftConfig)
110+
if err != nil {
111+
klog.Fatal(err)
112+
}
113+
enablement.ForceOpenShift(openshiftConfig)
114+
115+
args, err := openshiftkubeapiserver.ConfigToFlags(openshiftConfig)
116+
if err != nil {
117+
return err
118+
}
119+
120+
// hopefully this resets the flags?
121+
if err := cmd.ParseFlags(args); err != nil {
122+
return err
123+
}
124+
// initialize feature gates again with the new flags
125+
if err := s.GenericServerRunOptions.ComponentGlobalsRegistry.Set(); err != nil {
126+
return err
127+
}
128+
129+
// print merged flags (merged from OpenshiftConfig)
130+
cliflag.PrintFlags(cmd.Flags())
131+
132+
enablement.ForceGlobalInitializationForOpenShift()
133+
} else {
134+
// print default flags
135+
cliflag.PrintFlags(cmd.Flags())
136+
}
137+
101138
// set default options
102139
completedOptions, err := s.Complete(ctx)
103140
if err != nil {

pkg/controlplane/apiserver/config.go

+15
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import (
2525

2626
noopoteltrace "go.opentelemetry.io/otel/trace/noop"
2727

28+
"k8s.io/kubernetes/openshift-kube-apiserver/admission/admissionenablement"
29+
"k8s.io/kubernetes/openshift-kube-apiserver/enablement"
30+
"k8s.io/kubernetes/openshift-kube-apiserver/openshiftkubeapiserver"
31+
2832
"k8s.io/apimachinery/pkg/api/meta"
2933
"k8s.io/apimachinery/pkg/runtime"
3034
utilnet "k8s.io/apimachinery/pkg/util/net"
@@ -139,6 +143,8 @@ func BuildGenericConfig(
139143
// on a fast local network
140144
genericConfig.LoopbackClientConfig.DisableCompression = true
141145

146+
enablement.SetLoopbackClientConfig(genericConfig.LoopbackClientConfig)
147+
142148
kubeClientConfig := genericConfig.LoopbackClientConfig
143149
clientgoExternalClient, err := clientgoclientset.NewForConfig(kubeClientConfig)
144150
if err != nil {
@@ -364,6 +370,15 @@ func CreateConfig(
364370
if err != nil {
365371
return nil, nil, fmt.Errorf("failed to create real dynamic external client: %w", err)
366372
}
373+
374+
if err := openshiftkubeapiserver.OpenShiftKubeAPIServerConfigPatch(genericConfig, versionedInformers, &genericInitializers); err != nil {
375+
return nil, nil, fmt.Errorf("failed to patch: %v", err)
376+
}
377+
378+
if enablement.IsOpenShift() {
379+
admissionenablement.SetAdmissionDefaults(&opts, versionedInformers, clientgoExternalClient)
380+
}
381+
367382
err = opts.Admission.ApplyTo(
368383
genericConfig,
369384
versionedInformers,

pkg/kubeapiserver/authorizer/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
utilfeature "k8s.io/apiserver/pkg/util/feature"
3636
versionedinformers "k8s.io/client-go/informers"
3737
resourceinformers "k8s.io/client-go/informers/resource/v1beta1"
38+
"k8s.io/kubernetes/openshift-kube-apiserver/authorization/scopeauthorizer"
3839
"k8s.io/kubernetes/pkg/auth/authorizer/abac"
3940
"k8s.io/kubernetes/pkg/auth/nodeidentifier"
4041
"k8s.io/kubernetes/pkg/features"
@@ -126,6 +127,9 @@ func (config Config) New(ctx context.Context, serverID string) (authorizer.Autho
126127
&rbac.ClusterRoleGetter{Lister: config.VersionedInformerFactory.Rbac().V1().ClusterRoles().Lister()},
127128
&rbac.ClusterRoleBindingLister{Lister: config.VersionedInformerFactory.Rbac().V1().ClusterRoleBindings().Lister()},
128129
)
130+
case authzconfig.AuthorizerType(modes.ModeScope):
131+
// Wrap with an authorizer that detects unsafe requests and modifies verbs/resources appropriately so policy can address them separately
132+
r.scopeLimitedAuthorizer = scopeauthorizer.NewAuthorizer(config.VersionedInformerFactory.Rbac().V1().ClusterRoles().Lister())
129133
}
130134
}
131135

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package modes
2+
3+
var ModeScope = "Scope"
4+
var ModeSystemMasters = "SystemMasters"
5+
6+
func init() {
7+
AuthorizationModeChoices = append(AuthorizationModeChoices, ModeScope, ModeSystemMasters)
8+
}

pkg/kubeapiserver/authorizer/patch.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package authorizer
2+
3+
var skipSystemMastersAuthorizer = false
4+
5+
// SkipSystemMastersAuthorizer disable implicitly added system/master authz, and turn it into another authz mode "SystemMasters", to be added via authorization-mode
6+
func SkipSystemMastersAuthorizer() {
7+
skipSystemMastersAuthorizer = true
8+
}

pkg/kubeapiserver/authorizer/reload.go

+20-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import (
2727
"sync/atomic"
2828
"time"
2929

30+
"k8s.io/kubernetes/openshift-kube-apiserver/authorization/browsersafe"
31+
3032
"k8s.io/apimachinery/pkg/util/sets"
3133
authzconfig "k8s.io/apiserver/pkg/apis/apiserver"
3234
"k8s.io/apiserver/pkg/authentication/user"
@@ -58,10 +60,11 @@ type reloadableAuthorizerResolver struct {
5860
reloadInterval time.Duration
5961
requireNonWebhookTypes sets.Set[authzconfig.AuthorizerType]
6062

61-
nodeAuthorizer *node.NodeAuthorizer
62-
rbacAuthorizer *rbac.RBACAuthorizer
63-
abacAuthorizer abac.PolicyList
64-
compiler authorizationcel.Compiler // non-nil and shared across reloads.
63+
nodeAuthorizer *node.NodeAuthorizer
64+
rbacAuthorizer *rbac.RBACAuthorizer
65+
scopeLimitedAuthorizer authorizer.Authorizer
66+
abacAuthorizer abac.PolicyList
67+
compiler authorizationcel.Compiler // non-nil and shared across reloads.
6568

6669
lastLoadedLock sync.Mutex
6770
lastLoadedConfig *authzconfig.AuthorizationConfiguration
@@ -94,9 +97,11 @@ func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.Aut
9497
ruleResolvers []authorizer.RuleResolver
9598
)
9699

97-
// Add SystemPrivilegedGroup as an authorizing group
98-
superuserAuthorizer := authorizerfactory.NewPrivilegedGroups(user.SystemPrivilegedGroup)
99-
authorizers = append(authorizers, superuserAuthorizer)
100+
if !skipSystemMastersAuthorizer {
101+
// Add SystemPrivilegedGroup as an authorizing group
102+
superuserAuthorizer := authorizerfactory.NewPrivilegedGroups(user.SystemPrivilegedGroup)
103+
authorizers = append(authorizers, superuserAuthorizer)
104+
}
100105

101106
for _, configuredAuthorizer := range authzConfig.Authorizers {
102107
// Keep cases in sync with constant list in k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes/modes.go.
@@ -161,8 +166,15 @@ func (r *reloadableAuthorizerResolver) newForConfig(authzConfig *authzconfig.Aut
161166
if r.rbacAuthorizer == nil {
162167
return nil, nil, fmt.Errorf("authorizer type RBAC is not allowed if it was not enabled at initial server startup")
163168
}
164-
authorizers = append(authorizers, authorizationmetrics.InstrumentedAuthorizer(string(configuredAuthorizer.Type), configuredAuthorizer.Name, r.rbacAuthorizer))
169+
// Wrap with an authorizer that detects unsafe requests and modifies verbs/resources appropriately so policy can address them separately
170+
authorizers = append(authorizers, authorizationmetrics.InstrumentedAuthorizer(string(configuredAuthorizer.Type), configuredAuthorizer.Name, browsersafe.NewBrowserSafeAuthorizer(r.rbacAuthorizer, user.AllAuthenticated)))
165171
ruleResolvers = append(ruleResolvers, r.rbacAuthorizer)
172+
case authzconfig.AuthorizerType(modes.ModeScope):
173+
// Wrap with an authorizer that detects unsafe requests and modifies verbs/resources appropriately so policy can address them separately
174+
authorizers = append(authorizers, browsersafe.NewBrowserSafeAuthorizer(r.scopeLimitedAuthorizer, user.AllAuthenticated))
175+
case authzconfig.AuthorizerType(modes.ModeSystemMasters):
176+
// no browsersafeauthorizer here becase that rewrites the resources. This authorizer matches no matter which resource matches.
177+
authorizers = append(authorizers, authorizerfactory.NewPrivilegedGroups(user.SystemPrivilegedGroup))
166178
default:
167179
return nil, nil, fmt.Errorf("unknown authorization mode %s specified", configuredAuthorizer.Type)
168180
}

plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func buildControllerRoles() ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding)
160160
// resource that is owned by the service and sets blockOwnerDeletion=true in its ownerRef.
161161
rbacv1helpers.NewRule("update").Groups(legacyGroup).Resources("services/finalizers").RuleOrDie(),
162162
rbacv1helpers.NewRule("get", "list", "watch", "create", "update", "delete").Groups(discoveryGroup).Resources("endpointslices").RuleOrDie(),
163+
rbacv1helpers.NewRule("create").Groups(discoveryGroup).Resources("endpointslices/restricted").RuleOrDie(),
163164
eventsRule(),
164165
},
165166
})
@@ -176,6 +177,7 @@ func buildControllerRoles() ([]rbacv1.ClusterRole, []rbacv1.ClusterRoleBinding)
176177
// see https://github.com/openshift/kubernetes/blob/8691466059314c3f7d6dcffcbb76d14596ca716c/pkg/controller/endpointslicemirroring/utils.go#L87-L88
177178
rbacv1helpers.NewRule("update").Groups(legacyGroup).Resources("endpoints/finalizers").RuleOrDie(),
178179
rbacv1helpers.NewRule("get", "list", "watch", "create", "update", "delete").Groups(discoveryGroup).Resources("endpointslices").RuleOrDie(),
180+
rbacv1helpers.NewRule("create").Groups(discoveryGroup).Resources("endpointslices/restricted").RuleOrDie(),
179181
eventsRule(),
180182
},
181183
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package bootstrappolicy
2+
3+
import (
4+
rbacv1 "k8s.io/api/rbac/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
rbacv1helpers "k8s.io/kubernetes/pkg/apis/rbac/v1"
7+
)
8+
9+
var ClusterRoles = clusterRoles
10+
11+
func OpenshiftClusterRoles() []rbacv1.ClusterRole {
12+
const (
13+
// These are valid under the "nodes" resource
14+
NodeMetricsSubresource = "metrics"
15+
NodeStatsSubresource = "stats"
16+
NodeSpecSubresource = "spec"
17+
NodeLogSubresource = "log"
18+
)
19+
20+
roles := clusterRoles()
21+
roles = append(roles, []rbacv1.ClusterRole{
22+
{
23+
ObjectMeta: metav1.ObjectMeta{
24+
Name: "system:node-admin",
25+
},
26+
Rules: []rbacv1.PolicyRule{
27+
// Allow read-only access to the API objects
28+
rbacv1helpers.NewRule(Read...).Groups(legacyGroup).Resources("nodes").RuleOrDie(),
29+
// Allow all API calls to the nodes
30+
rbacv1helpers.NewRule("proxy").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
31+
rbacv1helpers.NewRule("*").Groups(legacyGroup).Resources("nodes/proxy", "nodes/"+NodeMetricsSubresource, "nodes/"+NodeSpecSubresource, "nodes/"+NodeStatsSubresource, "nodes/"+NodeLogSubresource).RuleOrDie(),
32+
},
33+
},
34+
{
35+
ObjectMeta: metav1.ObjectMeta{
36+
Name: "system:node-reader",
37+
},
38+
Rules: []rbacv1.PolicyRule{
39+
// Allow read-only access to the API objects
40+
rbacv1helpers.NewRule(Read...).Groups(legacyGroup).Resources("nodes").RuleOrDie(),
41+
// Allow read access to node metrics
42+
rbacv1helpers.NewRule("get").Groups(legacyGroup).Resources("nodes/"+NodeMetricsSubresource, "nodes/"+NodeSpecSubresource).RuleOrDie(),
43+
// Allow read access to stats
44+
// Node stats requests are submitted as POSTs. These creates are non-mutating
45+
rbacv1helpers.NewRule("get", "create").Groups(legacyGroup).Resources("nodes/" + NodeStatsSubresource).RuleOrDie(),
46+
// TODO: expose other things like /healthz on the node once we figure out non-resource URL policy across systems
47+
},
48+
},
49+
}...)
50+
51+
addClusterRoleLabel(roles)
52+
return roles
53+
}
54+
55+
var ClusterRoleBindings = clusterRoleBindings
56+
57+
func OpenshiftClusterRoleBindings() []rbacv1.ClusterRoleBinding {
58+
bindings := clusterRoleBindings()
59+
bindings = append(bindings, []rbacv1.ClusterRoleBinding{
60+
rbacv1helpers.NewClusterBinding("system:node-admin").Users("system:master", "system:kube-apiserver").Groups("system:node-admins").BindingOrDie(),
61+
}...)
62+
63+
addClusterRoleBindingLabel(bindings)
64+
return bindings
65+
}

plugin/pkg/auth/authorizer/rbac/bootstrappolicy/policy.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ func NodeRules() []rbacv1.PolicyRule {
275275
return nodePolicyRules
276276
}
277277

278-
// ClusterRoles returns the cluster roles to bootstrap an API server with
279-
func ClusterRoles() []rbacv1.ClusterRole {
278+
// clusterRoles returns the cluster roles to bootstrap an API server with
279+
func clusterRoles() []rbacv1.ClusterRole {
280280
monitoringRules := []rbacv1.PolicyRule{
281281
rbacv1helpers.NewRule("get").URLs(
282282
"/metrics", "/metrics/slis",
@@ -655,7 +655,7 @@ func ClusterRoles() []rbacv1.ClusterRole {
655655
const systemNodeRoleName = "system:node"
656656

657657
// ClusterRoleBindings return default rolebindings to the default roles
658-
func ClusterRoleBindings() []rbacv1.ClusterRoleBinding {
658+
func clusterRoleBindings() []rbacv1.ClusterRoleBinding {
659659
rolebindings := []rbacv1.ClusterRoleBinding{
660660
rbacv1helpers.NewClusterBinding("cluster-admin").Groups(user.SystemPrivilegedGroup).BindingOrDie(),
661661
rbacv1helpers.NewClusterBinding("system:monitoring").Groups(user.MonitoringGroup).BindingOrDie(),

plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/controller-roles.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ items:
520520
- list
521521
- update
522522
- watch
523+
- apiGroups:
524+
- discovery.k8s.io
525+
resources:
526+
- endpointslices/restricted
527+
verbs:
528+
- create
523529
- apiGroups:
524530
- ""
525531
- events.k8s.io
@@ -571,6 +577,12 @@ items:
571577
- list
572578
- update
573579
- watch
580+
- apiGroups:
581+
- discovery.k8s.io
582+
resources:
583+
- endpointslices/restricted
584+
verbs:
585+
- create
574586
- apiGroups:
575587
- ""
576588
- events.k8s.io
Binary file not shown.

0 commit comments

Comments
 (0)