Skip to content

Commit 7727139

Browse files
committed
(feature): update cao to manage rolebindingrestriction CRD
Signed-off-by: Bryce Palmer <[email protected]>
1 parent 75c7842 commit 7727139

File tree

205 files changed

+6436
-3449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+6436
-3449
lines changed

Makefile

+14-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
1515
#
1616
# Example:
1717
# make check
18-
check: | verify test-unit
18+
check: | verify verify-bindata test-unit
1919
.PHONY: check
2020

2121
IMAGE_REGISTRY?=registry.svc.ci.openshift.org
@@ -86,3 +86,16 @@ export TP_CMD_PATH ?=./cmd/authentication-operator
8686
export TP_CMD_ARGS ?=operator --config=/var/run/configmaps/config/operator-config.yaml --v=2 --terminate-on-files=/var/run/configmaps/trusted-ca-bundle/ca-bundle.crt
8787
export TP_LOCK_CONFIGMAP ?=cluster-authentication-operator-lock
8888
export TP_BUILD_FLAGS ?=-tags ocp
89+
90+
# ensure the rolebindingrestriction CRD is included in bindata
91+
RBR_CRD_SOURCE := vendor/github.com/openshift/api/authorization/v1/zz_generated.crd-manifests/0000_03_config-operator_01_rolebindingrestrictions.crd.yaml
92+
RBR_CRD_TARGET := bindata/oauth-openshift/authorization.openshift.io_rolebindingrestrictions.yaml
93+
update-bindata: $(RBR_CRD_TARGET)
94+
$(RBR_CRD_TARGET): $(RBR_CRD_SOURCE)
95+
cp $< $@
96+
97+
verify-bindata: verify-rbr-crd
98+
.PHONY: verify-bindata
99+
100+
verify-rbr-crd:
101+
diff -Naup $(RBR_CRD_SOURCE) $(RBR_CRD_TARGET)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
api-approved.openshift.io: https://github.com/openshift/api/pull/470
6+
api.openshift.io/merged-by-featuregates: "true"
7+
include.release.openshift.io/ibm-cloud-managed: "true"
8+
include.release.openshift.io/self-managed-high-availability: "true"
9+
release.openshift.io/bootstrap-required: "true"
10+
name: rolebindingrestrictions.authorization.openshift.io
11+
spec:
12+
group: authorization.openshift.io
13+
names:
14+
kind: RoleBindingRestriction
15+
listKind: RoleBindingRestrictionList
16+
plural: rolebindingrestrictions
17+
singular: rolebindingrestriction
18+
scope: Namespaced
19+
versions:
20+
- name: v1
21+
schema:
22+
openAPIV3Schema:
23+
description: |-
24+
RoleBindingRestriction is an object that can be matched against a subject
25+
(user, group, or service account) to determine whether rolebindings on that
26+
subject are allowed in the namespace to which the RoleBindingRestriction
27+
belongs. If any one of those RoleBindingRestriction objects matches
28+
a subject, rolebindings on that subject in the namespace are allowed.
29+
30+
Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
31+
properties:
32+
apiVersion:
33+
description: |-
34+
APIVersion defines the versioned schema of this representation of an object.
35+
Servers should convert recognized schemas to the latest internal value, and
36+
may reject unrecognized values.
37+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
38+
type: string
39+
kind:
40+
description: |-
41+
Kind is a string value representing the REST resource this object represents.
42+
Servers may infer this from the endpoint the client submits requests to.
43+
Cannot be updated.
44+
In CamelCase.
45+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
46+
type: string
47+
metadata:
48+
type: object
49+
spec:
50+
description: spec defines the matcher.
51+
properties:
52+
grouprestriction:
53+
description: grouprestriction matches against group subjects.
54+
nullable: true
55+
properties:
56+
groups:
57+
description: |-
58+
groups is a list of groups used to match against an individual user's
59+
groups. If the user is a member of one of the whitelisted groups, the user
60+
is allowed to be bound to a role.
61+
items:
62+
type: string
63+
nullable: true
64+
type: array
65+
labels:
66+
description: Selectors specifies a list of label selectors over
67+
group labels.
68+
items:
69+
description: |-
70+
A label selector is a label query over a set of resources. The result of matchLabels and
71+
matchExpressions are ANDed. An empty label selector matches all objects. A null
72+
label selector matches no objects.
73+
properties:
74+
matchExpressions:
75+
description: matchExpressions is a list of label selector
76+
requirements. The requirements are ANDed.
77+
items:
78+
description: |-
79+
A label selector requirement is a selector that contains values, a key, and an operator that
80+
relates the key and values.
81+
properties:
82+
key:
83+
description: key is the label key that the selector
84+
applies to.
85+
type: string
86+
operator:
87+
description: |-
88+
operator represents a key's relationship to a set of values.
89+
Valid operators are In, NotIn, Exists and DoesNotExist.
90+
type: string
91+
values:
92+
description: |-
93+
values is an array of string values. If the operator is In or NotIn,
94+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
95+
the values array must be empty. This array is replaced during a strategic
96+
merge patch.
97+
items:
98+
type: string
99+
type: array
100+
x-kubernetes-list-type: atomic
101+
required:
102+
- key
103+
- operator
104+
type: object
105+
type: array
106+
x-kubernetes-list-type: atomic
107+
matchLabels:
108+
additionalProperties:
109+
type: string
110+
description: |-
111+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
112+
map is equivalent to an element of matchExpressions, whose key field is "key", the
113+
operator is "In", and the values array contains only "value". The requirements are ANDed.
114+
type: object
115+
type: object
116+
x-kubernetes-map-type: atomic
117+
nullable: true
118+
type: array
119+
type: object
120+
serviceaccountrestriction:
121+
description: serviceaccountrestriction matches against service-account
122+
subjects.
123+
nullable: true
124+
properties:
125+
namespaces:
126+
description: namespaces specifies a list of literal namespace
127+
names.
128+
items:
129+
type: string
130+
type: array
131+
serviceaccounts:
132+
description: serviceaccounts specifies a list of literal service-account
133+
names.
134+
items:
135+
description: |-
136+
ServiceAccountReference specifies a service account and namespace by their
137+
names.
138+
properties:
139+
name:
140+
description: name is the name of the service account.
141+
type: string
142+
namespace:
143+
description: |-
144+
namespace is the namespace of the service account. Service accounts from
145+
inside the whitelisted namespaces are allowed to be bound to roles. If
146+
Namespace is empty, then the namespace of the RoleBindingRestriction in
147+
which the ServiceAccountReference is embedded is used.
148+
type: string
149+
type: object
150+
type: array
151+
type: object
152+
userrestriction:
153+
description: userrestriction matches against user subjects.
154+
nullable: true
155+
properties:
156+
groups:
157+
description: groups specifies a list of literal group names.
158+
items:
159+
type: string
160+
nullable: true
161+
type: array
162+
labels:
163+
description: Selectors specifies a list of label selectors over
164+
user labels.
165+
items:
166+
description: |-
167+
A label selector is a label query over a set of resources. The result of matchLabels and
168+
matchExpressions are ANDed. An empty label selector matches all objects. A null
169+
label selector matches no objects.
170+
properties:
171+
matchExpressions:
172+
description: matchExpressions is a list of label selector
173+
requirements. The requirements are ANDed.
174+
items:
175+
description: |-
176+
A label selector requirement is a selector that contains values, a key, and an operator that
177+
relates the key and values.
178+
properties:
179+
key:
180+
description: key is the label key that the selector
181+
applies to.
182+
type: string
183+
operator:
184+
description: |-
185+
operator represents a key's relationship to a set of values.
186+
Valid operators are In, NotIn, Exists and DoesNotExist.
187+
type: string
188+
values:
189+
description: |-
190+
values is an array of string values. If the operator is In or NotIn,
191+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
192+
the values array must be empty. This array is replaced during a strategic
193+
merge patch.
194+
items:
195+
type: string
196+
type: array
197+
x-kubernetes-list-type: atomic
198+
required:
199+
- key
200+
- operator
201+
type: object
202+
type: array
203+
x-kubernetes-list-type: atomic
204+
matchLabels:
205+
additionalProperties:
206+
type: string
207+
description: |-
208+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
209+
map is equivalent to an element of matchExpressions, whose key field is "key", the
210+
operator is "In", and the values array contains only "value". The requirements are ANDed.
211+
type: object
212+
type: object
213+
x-kubernetes-map-type: atomic
214+
nullable: true
215+
type: array
216+
users:
217+
description: users specifies a list of literal user names.
218+
items:
219+
type: string
220+
type: array
221+
type: object
222+
type: object
223+
type: object
224+
served: true
225+
storage: true

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
77
github.com/ghodss/yaml v1.0.0
88
github.com/google/go-cmp v0.6.0
9-
github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f
9+
github.com/openshift/api v0.0.0-20250108172834-78bd56dba39b
1010
github.com/openshift/build-machinery-go v0.0.0-20241031155326-6ae126a9cb72
1111
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f
1212
github.com/openshift/library-go v0.0.0-20241120135057-fc703a7407c9
@@ -17,6 +17,7 @@ require (
1717
golang.org/x/net v0.29.0
1818
gopkg.in/yaml.v2 v2.4.0
1919
k8s.io/api v0.31.1
20+
k8s.io/apiextensions-apiserver v0.31.1
2021
k8s.io/apimachinery v0.31.1
2122
k8s.io/apiserver v0.31.1
2223
k8s.io/cli-runtime v0.31.1
@@ -113,7 +114,6 @@ require (
113114
gopkg.in/inf.v0 v0.9.1 // indirect
114115
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
115116
gopkg.in/yaml.v3 v3.0.1 // indirect
116-
k8s.io/apiextensions-apiserver v0.31.1 // indirect
117117
k8s.io/kms v0.31.1 // indirect
118118
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
119119
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
148148
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
149149
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
150150
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
151-
github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f h1:ya1OmyZm3LIIxI3U9VE9Nyx3ehCHgBwxyFUPflYPWls=
152-
github.com/openshift/api v0.0.0-20241001152557-e415140e5d5f/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
151+
github.com/openshift/api v0.0.0-20250108172834-78bd56dba39b h1:Nt4V9k5pyw2CiUL2L5IFlstvURf+12Z7uSzi/v30UpE=
152+
github.com/openshift/api v0.0.0-20250108172834-78bd56dba39b/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
153153
github.com/openshift/build-machinery-go v0.0.0-20241031155326-6ae126a9cb72 h1:kMM+Ea3YFrcoYS76RhhBA7uELy97JM0gwqnyoy7fxco=
154154
github.com/openshift/build-machinery-go v0.0.0-20241031155326-6ae126a9cb72/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
155155
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f h1:FRc0bVNWprihWS0GqQWzb3dY4dkCwpOP3mDw5NwSoR4=

pkg/dependencymagnet/dependencymagnet.go

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package dependencymagnet
77

88
import (
9+
_ "github.com/openshift/api/authorization/v1/zz_generated.crd-manifests"
910
_ "github.com/openshift/api/operator/v1/zz_generated.crd-manifests"
1011
_ "github.com/openshift/build-machinery-go"
1112
)

pkg/operator/replacement_starter.go

+13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515

1616
apiregistrationclient "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
1717

18+
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
19+
1820
operatorv1 "github.com/openshift/api/operator/v1"
1921
configclient "github.com/openshift/client-go/config/clientset/versioned"
2022
configinformer "github.com/openshift/client-go/config/informers/externalversions"
@@ -50,6 +52,7 @@ type authenticationOperatorInput struct {
5052
authenticationOperatorClient v1helpers.OperatorClient
5153
apiregistrationv1Client apiregistrationclient.Interface
5254
migrationClient kubemigratorclient.Interface
55+
apiextensionClient apiextensionsclient.Interface
5356
eventRecorder events.Recorder
5457

5558
informerFactories []libraryapplyconfiguration.SimplifiedInformerFactory
@@ -86,6 +89,10 @@ func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfig
8689
if err != nil {
8790
return nil, err
8891
}
92+
apiextensionClient, err := apiextensionsclient.NewForConfigAndClient(manifestclient.RecommendedRESTConfig(), momInput.MutationTrackingClient.GetHTTPClient())
93+
if err != nil {
94+
return nil, err
95+
}
8996

9097
authenticationOperatorClient, dynamicInformers, err := genericoperatorclient.NewOperatorClientWithClient(
9198
momInput.Clock,
@@ -128,6 +135,7 @@ func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfig
128135
authenticationOperatorClient: authenticationOperatorClient,
129136
apiregistrationv1Client: apiregistrationv1Client,
130137
migrationClient: migrationClient,
138+
apiextensionClient: apiextensionClient,
131139
eventRecorder: eventRecorder,
132140
informerFactories: []libraryapplyconfiguration.SimplifiedInformerFactory{
133141
libraryapplyconfiguration.DynamicInformerFactoryAdapter(dynamicInformers), // we don't share the dynamic informers, but we only want to start when requested
@@ -164,6 +172,10 @@ func CreateControllerInputFromControllerContext(ctx context.Context, controllerC
164172
if err != nil {
165173
return nil, err
166174
}
175+
apiextensionsClient, err := apiextensionsclient.NewForConfig(controllerContext.KubeConfig)
176+
if err != nil {
177+
return nil, err
178+
}
167179

168180
authenticationOperatorClient, dynamicInformers, err := genericoperatorclient.NewClusterScopedOperatorClient(
169181
controllerContext.Clock,
@@ -198,6 +210,7 @@ func CreateControllerInputFromControllerContext(ctx context.Context, controllerC
198210
authenticationOperatorClient: authenticationOperatorClient,
199211
apiregistrationv1Client: apiregistrationv1Client,
200212
migrationClient: migrationClient,
213+
apiextensionClient: apiextensionsClient,
201214
eventRecorder: eventRecorder,
202215
informerFactories: []libraryapplyconfiguration.SimplifiedInformerFactory{
203216
libraryapplyconfiguration.DynamicInformerFactoryAdapter(dynamicInformers), // we don't share the dynamic informers, but we only want to start when requested

pkg/operator/starter.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func prepareOauthOperator(
100100
resourceSyncController *resourcesynccontroller.ResourceSyncController,
101101
versionRecorder status.VersionGetter,
102102
) ([]libraryapplyconfiguration.NamedRunOnce, []libraryapplyconfiguration.RunFunc, error) {
103-
104103
clusterVersion, err := authOperatorInput.configClient.ConfigV1().ClusterVersions().Get(ctx, "version", metav1.GetOptions{})
105104
if err != nil {
106105
return nil, nil, err
@@ -142,8 +141,9 @@ func prepareOauthOperator(
142141
"oauth-openshift/oauth-service.yaml",
143142
"oauth-openshift/trust_distribution_role.yaml",
144143
"oauth-openshift/trust_distribution_rolebinding.yaml",
144+
"oauth-openshift/authorization.openshift.io_rolebindingrestrictions.yaml",
145145
},
146-
resourceapply.NewKubeClientHolder(authOperatorInput.kubeClient),
146+
resourceapply.NewKubeClientHolder(authOperatorInput.kubeClient).WithAPIExtensionsClient(authOperatorInput.apiextensionClient),
147147
authOperatorInput.authenticationOperatorClient,
148148
authOperatorInput.eventRecorder,
149149
).AddKubeInformers(informerFactories.kubeInformersForNamespaces)
@@ -580,7 +580,6 @@ func prepareOauthAPIServerOperator(
580580
WithoutLogLevelController().
581581
WithoutConfigUpgradableController().
582582
PrepareRun()
583-
584583
if err != nil {
585584
return nil, nil, err
586585
}
@@ -680,7 +679,7 @@ func singleNameListOptions(name string) func(opts *metav1.ListOptions) {
680679
}
681680

682681
func apiServices() []*apiregistrationv1.APIService {
683-
var apiServiceGroupVersions = []schema.GroupVersion{
682+
apiServiceGroupVersions := []schema.GroupVersion{
684683
// these are all the apigroups we manage
685684
{Group: "oauth.openshift.io", Version: "v1"},
686685
{Group: "user.openshift.io", Version: "v1"},

0 commit comments

Comments
 (0)