Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start bootstrapping cluster roles from kube #14026

Merged
merged 1 commit into from
May 8, 2017

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented May 3, 2017

This starts adding clusterroles and clusterrolebindings from kube RBAC rules as bootstrap origin roles. These will be plumbed to bootstrapping and to the reconcile commands.

This doesn't deprecate or remove any origin roles. Any origin role or binding takes priority.

Still todo:

  1. Wire up the clientbuilder for upstream controllers to create the kube-system SAs
  2. Create a dead.go file to contain roles that we're retiring in favor of upstream roles. Upstream controllers for example.
  3. Re-prefix remaining system: roles in openshift to system:openshift: or system:openshift:controller:
  4. Refactor origin controller bootstrapping to look like the upstream one to subdivide permissions easily.

@deads2k
Copy link
Contributor Author

deads2k commented May 3, 2017

[test]

@deads2k deads2k force-pushed the auth-12-upstream-roles branch from 372b355 to e23441b Compare May 3, 2017 16:37
role.Rules[j].Resources = authorizationapi.NormalizeResources(role.Rules[j].Resources)
}

// TODO roundtrip roles to pick up defaulting for API groups. Without this, the covers check in reconcile-cluster-roles will fail.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion and defaulting are separate. You'll need to call kapi.Scheme.Default on the external version, won't you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They aren't separate here: https://github.com/openshift/origin/blob/master/pkg/authorization/api/v1/conversion.go#L95

Also this is pre-existing. Just moved it closer to its need.

@ncdc
Copy link
Contributor

ncdc commented May 3, 2017 via email

@deads2k deads2k force-pushed the auth-12-upstream-roles branch 2 times, most recently from cc41706 to d7acdb1 Compare May 4, 2017 17:42
@deads2k deads2k force-pushed the auth-12-upstream-roles branch from d7acdb1 to 6306239 Compare May 5, 2017 13:05
@sttts sttts mentioned this pull request May 5, 2017
32 tasks
@deads2k
Copy link
Contributor Author

deads2k commented May 5, 2017

re[test]

Copy link
Contributor

@enj enj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. LGTM.

kind: ClusterRole
metadata:
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does origin do anything with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does origin do anything with this?

It will clone it back during the later sync: #14064

creationTimestamp: null
labels:
kubernetes.io/bootstrapping: rbac-defaults
name: system:basic-user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting mismtach.

creationTimestamp: null
labels:
kubernetes.io/bootstrapping: rbac-defaults
name: cluster-admin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So kube does not pluralize them like we do...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So kube does not pluralize them like we do...

Right.

out := []authorizationapi.ClusterRole{}
errs := []error{}

// add non-conflicting kube rbac roles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment does not make sense to me.

out := []authorizationapi.ClusterRoleBinding{}
errs := []error{}

// add non-conflicting kube rbac roles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment does not make sense to me.

extraWhitelistEntries := clusterRoleBindingConflicts.Difference(conflictingNames)
switch {
case len(extraRBACConflicts) > 0 && len(extraWhitelistEntries) > 0:
panic(fmt.Errorf("kube ClusterRoleBindings conflict with openshift ClusterRoleBindings: %v and ClusterRoleBinding whitelist contains a extraneous entries: %v ", extraRBACConflicts.List(), extraWhitelistEntries.List()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fmt.Sprintf

extraRBACConflicts := conflictingNames.Difference(clusterRoleBindingConflicts)
extraWhitelistEntries := clusterRoleBindingConflicts.Difference(conflictingNames)
switch {
case len(extraRBACConflicts) > 0 && len(extraWhitelistEntries) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which is more correct: len(set) or set.Len().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which is more correct: len(set) or set.Len().

len(set). It's native.

case len(extraRBACConflicts) > 0 && len(extraWhitelistEntries) > 0:
panic(fmt.Errorf("kube ClusterRoleBindings conflict with openshift ClusterRoleBindings: %v and ClusterRoleBinding whitelist contains a extraneous entries: %v ", extraRBACConflicts.List(), extraWhitelistEntries.List()))
case len(extraRBACConflicts) > 0:
panic(fmt.Errorf("kube ClusterRoleBindings conflict with openshift ClusterRoleBindings: %v", extraRBACConflicts.List()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you chose the panic the server route instead of failing a unit test somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you chose the panic the server route instead of failing a unit test somewhere?

I've structured the code to allow both. Turns out, this should fail the unit test creating the list of bootstrap roles, right? Thought of that later.

@deads2k deads2k force-pushed the auth-12-upstream-roles branch from 6306239 to ab36e11 Compare May 8, 2017 12:11
@deads2k
Copy link
Contributor Author

deads2k commented May 8, 2017

comments addressed. This is needed for an approved pull: #14033

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to ab36e11

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to ab36e11

@openshift-bot
Copy link
Contributor

openshift-bot commented May 8, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/583/) (Base Commit: 17ebd78) (Image: devenv-rhel7_6215)

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1224/) (Base Commit: 17ebd78)

@openshift-bot openshift-bot merged commit dac5ddc into openshift:master May 8, 2017
@deads2k deads2k deleted the auth-12-upstream-roles branch August 3, 2017 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants