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

add reconcile command to kubectl auth #51636

Merged
merged 1 commit into from
Sep 3, 2017

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Aug 30, 2017

This pull exposes the RBAC reconcile commands through kubectl auth reconcile -f FILE. When passed a file which contains RBAC roles, rolebindings, clusterroles, or clusterrolebindings, it will compute covers and add the missing rules.

The logic required to properly "apply" rbac permissions is more complicated that a json merge since you have to compute logical covers operations between rule sets. This means that we cannot use kubectl apply to update rbac roles without risking breaking old clients (like controllers).

To solve this problem, RBAC created reconcile functions to use during startup for "stock" roles. We want to offer this power to users who are running their own controllers and extension servers.

This is an intersection between @kubernetes/sig-auth-misc and @kubernetes/sig-cli-misc

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 30, 2017
@enj
Copy link
Member

enj commented Aug 30, 2017

@deads2k I assume we plan to expose these in some manner in Openshift?

cc @simo5

@deads2k
Copy link
Contributor Author

deads2k commented Aug 30, 2017

@deads2k I assume we plan to expose these in some manner in Openshift?

cc @simo5

Nothing special. oc already wraps kubectl. This is needed to make RBAC upgrades whole for kube consumers.

@fabianofranz
Copy link
Contributor

/release-note

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Aug 30, 2017
ContinueOnError().
NamespaceParam(namespace).DefaultNamespace().
FilenameParam(enforceNamespace, options).
ResourceTypeOrNameArgs(false, args...).
Copy link
Member

Choose a reason for hiding this comment

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

ResourceTypeOrNameArgs lets them specify a resource name that is fetched from the server? what would that do for reconcile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ResourceTypeOrNameArgs lets them specify a resource name that is fetched from the server? what would that do for reconcile?

nothing since args are forced to be zero length. I'll remove that bit though.

},
}
result, err := reconcileOptions.Run()
shallowInfoCopy.Object = result.Role.GetObject()
Copy link
Contributor

Choose a reason for hiding this comment

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

When the error is non-nil can result be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the error is non-nil can result be nil?

Maybe. I'll gate it.


var (
reconcileLong = templates.LongDesc(`
Reconciles rules for RBAC Role, RoleBinding, ClusterRole, and ClusterRole binding objects`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this always be used instead of kubectl apply, or are there different cases when one is preferred instead of another? Can we add that to the description?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would this always be used instead of kubectl apply, or are there different cases when one is preferred instead of another? Can we add that to the description?

I can't think of a reason to use apply with rbac resources. It rarely does what you want. Maybe in the bare creation case. I can add it.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 30, 2017

comments addressed


cmdutil.AddPrinterFlags(cmd)
usage := "identifying the resource to reconcile."
cmdutil.AddFilenameOptionFlags(cmd, fileOptions, usage)
Copy link
Contributor

Choose a reason for hiding this comment

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

cmd.MarkFlagRequired("filename") since it is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cmd.MarkFlagRequired("filename") since it is required.

done

}

cmd := &cobra.Command{
Use: "reconcile -f [FILE|URL|DIRECTORY]",
Copy link
Contributor

Choose a reason for hiding this comment

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

We've been using the usage like reconcile -f FILENAME in other places (create, convert, etc).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We've been using the usage like reconcile -f FILENAME in other places (create, convert, etc).

done

}

// shallowInfoCopy this is used to later twiddle the Object for printing
// we really need more straightforward printing options
Copy link
Contributor

Choose a reason for hiding this comment

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

return nil

default:
// skip ignored resources
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, worth to glog.V(n) print the ignored ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit, worth to glog.V(n) print the ignored ones?

done

@deads2k
Copy link
Contributor Author

deads2k commented Aug 30, 2017

comments addressed.

@fabianofranz
Copy link
Contributor

LGTM

@ericchiang
Copy link
Contributor

/test pull-kubernetes-e2e-gce-gpu

@deads2k
Copy link
Contributor Author

deads2k commented Aug 31, 2017

/retest

@deads2k
Copy link
Contributor Author

deads2k commented Aug 31, 2017

/approve no-issue

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deads2k
We suggest the following additional approver: smarterclayton

Assign the PR to them by writing /assign @smarterclayton in a comment when ready.

Associated issue requirement bypassed by: deads2k

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@deads2k deads2k added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Aug 31, 2017
@deads2k
Copy link
Contributor Author

deads2k commented Aug 31, 2017

docs are generated, labeled.

@deads2k deads2k added this to the v1.8 milestone Sep 1, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 50832, 51119, 51636, 48921, 51712)

@k8s-github-robot k8s-github-robot merged commit a3aac42 into kubernetes:master Sep 3, 2017
@deads2k deads2k deleted the cli-01-reconcile branch July 3, 2018 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants