Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Proposal: ns-scoped resources for brokers, services, and plans #1826

Closed

Conversation

pmorie
Copy link
Contributor

@pmorie pmorie commented Mar 12, 2018

Proposal to resolve #1200

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 12, 2018
Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

LGTM

jeremyrickard added a commit to jeremyrickard/service-catalog that referenced this pull request Mar 14, 2018
As part of the Prosopal for Namespaced Resources (kubernetes-retired#1826), this extracts
the common elements from the ClusterServicePlanSpec into a SharedServicePlanSpec
that can be embedded in both the ClusterServicePlanSpec and a new namesapced plan
@jeremyrickard
Copy link
Contributor

There were some comments on the current PRs about the use of "Shared" as the prefix on these extracted objects. Do we want to revise the proposal before we get too deep into the refactor?

cc: @n3wscott


To extract the shared fields, we will:

- Extract the identified shared fields onto embedable types: `SharedServiceBrokerSpec`, `SharedServiceClassSpec`, and `SharedServicePlanSpec`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am questioning Shared, how about Common or Core

Copy link
Contributor

Choose a reason for hiding this comment

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

Paul suggested SharedServerFooFields and I like that.

Copy link
Contributor

Choose a reason for hiding this comment

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

These don't show up to the user, do they?

As long as the notation is consistent and there is documentation describing what they are, I'm probably fine with most suggested names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, the names of these types never surface to users.

jboyd01 pushed a commit that referenced this pull request Mar 16, 2018
* Extracting common plan spec elements into embeddable struct

As part of the Prosopal for Namespaced Resources (#1826), this extracts
the common elements from the ClusterServicePlanSpec into a SharedServicePlanSpec
that can be embedded in both the ClusterServicePlanSpec and a new namesapced plan

* Cleaned up comments on shared fields to remove "Cluster" from description.

* Cleaned up comments on shared fields to remove "Cluster" from description.

* Refactored ClusterPlanStatus to match proposal

* Revert "Refactored ClusterPlanStatus to match proposal"

This reverts commit 6b36cf7.
Copy link
Contributor

@nilebox nilebox left a comment

Choose a reason for hiding this comment

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

See the comments.
Also I remember @duglin mentioning that he doesn't like merging proposals. Do we want to eventually merge it or just use PR for review?


Next, we will make the required changes to the binding controller loop to make it possible to create bindings against service instances that are associated with the ns-scoped variants of serviceclasses and plans.

### Remove feature flag
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the first time feature flag is mentioned in this proposal, i.e. there is no "add feature flag" anywhere.
Also, I'm not even sure we need feature flag at all, given that the proposed changes are backward compatible. Is that to be able to iteratively implement this proposal, i.e. having it merged without enabling for a first couple iterations until we get MVP? I would probably prefer to have an MVP in the first PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think he means feature gate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, feature gate.


### Use Case: Developing new services

Similar to to highly privileged services, there are a class of users who are service developers, and would be interested in publishing their services via a broker to the rest of the cluster. As part of their development cycle, they would like to work within their own private namespace while iterating on their service.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "to to"

- Create a policy that adds certain services and plans to multiple namespaces
- Creating a virtual resource that allows users to see all services or plans available to them across the cluster and namespace scopes

We should take care to acheive the goals of this proposal without preventing further progress on other issues that are out of scope.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/acheive/achieve


## Goals and non-goals

There are many related problems in service-catalog that users are interested in solutions for, but we need to keep the scope of this proposal controlled. In that light, let's establish the goals of this proposal:
Copy link
Contributor

Choose a reason for hiding this comment

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

service-catalog -> Service Catalog


Adding namespaced resources for brokers, services and plans is necessary but not sufficient to control access to services and plans. A single broker may offer a mix of services that all users should be able to access and services that should only be usable by some users.

In order to prevent a broker that offers a mix of unprivileged and privileged services to the cluster-scoped catalog, there must be a way to filter the services and plans exposed by a broker. This can be accomplished through the use of white/black lists that control which services and plans in a broker's catalog have service-catalog resources created for them. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

As I said before in person, I think that the entire Filtering services and plans from a broker paragraph is unrelated to the proposal, and should be just briefly mentioned in the The following are valid goals but outside the scope of this proposal: list instead.

The initial proposal should be about namespace-local services/plans only without support for mix of services with different access level.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to leave it in because it's an important part of the story we're trying to make possible here. Is it really necessary to rewrite it out of this PR?

Copy link
Contributor

@nilebox nilebox Mar 22, 2018

Choose a reason for hiding this comment

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

@pmorie it seems that you have removed it already, but I will still reply :)
I didn't want to be part of this proposal, as it addresses a different concern, and it's harder to sell/buy 2 proposals bundled into one. Unless your plan was to silently slip the black/whitelist proposal as part of the bigger one haha :)

Copy link
Contributor

@MHBauer MHBauer left a comment

Choose a reason for hiding this comment

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

Read through it.

There are many related problems in service-catalog that users are interested in solutions for, but we need to keep the scope of this proposal controlled. In that light, let's establish the goals of this proposal:

- Make it possible to keep the cluster-scoped catalog limited to services and plans that everyone should be able to use
- Make it possible to add privileged services and plans into specific namespaces
Copy link
Contributor

Choose a reason for hiding this comment

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

strike the word privileged.

not sure if add is the correct word, but that is a nit.

1. Not all authorizers are able to provide a list of subjects with access to a resource
2. An external authorizer may have its state changed at any time out of band to kubernetes, making it impossible to do implement a correct `LIST` or `WATCH` operation from a certain resource version

Since ACL-filtering the cluster-scoped list of services and plans is not a realistic option, we must find another method of controlling read/write access to resources. In Kubernetes, namespaces are the defacto way of performing this type of access control.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't run or operate an application in a cluster. Any documentation on this use of namespaces? Blogs or official guidance. I've never understood the original use case for namespaces.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are two ingredients to successfully controlling access to services and plans:

- Namespaced versions of these resources are required to control access to services along the boundaries of namespaces
- API surfaces to allow black/whitelisting which services and plans from a broker's catalog have k8s resources created for them
Copy link
Contributor

Choose a reason for hiding this comment

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

From the rest of the proposal, this seems outside the boundaries. Limit this to resources, management later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's addressed later in the doc

Copy link
Contributor

Choose a reason for hiding this comment

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

black/whitelisting was removed from the doc, so probably remove this paragraph as well.


The API for the `ServiceBroker` resource should differ from `ClusterServiceBroker` in exactly one area:

- A user should only be able to specify a secret within the same namespace to hold the auth information
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean a localref of some sort? It would mean a special version of AuthInfo structs. Otherwise this is more of a policy thing done by either an admission controller or the controller proper.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is handled directly by kubernetes I believe. Nothing special we need to do here as long as bindings are namespaced.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MHBauer you're right; the plan was to introduce a LocalObjectRefthat only contains the name, since the namespace is implied. There is ClusterServiceBrokerAuthInfo with ClusterBasicAuthConfig and ClusterBearerTokenAuthConfig. This is in service of making room for namespaced variants without the Cluster prefix that use the LocalObjectRef.


Differences between `ClusterServiceClass` and `ServiceClass`:

- `ServiceClass.Spec` should have `ServiceBrokerName` instead of `ClusterServiceBrokerName`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we genericize this field to share it in struct data representation? To me it would seem 'obvious' that the cluster scoped class one should look for a cluster scoped broker, and that a namespace scoped one should look in the same namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's dealt with later, in the implementation plan.


To extract the shared fields, we will:

- Extract the identified shared fields onto embedable types: `SharedServiceBrokerSpec`, `SharedServiceClassSpec`, and `SharedServicePlanSpec`.
Copy link
Contributor

Choose a reason for hiding this comment

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

These don't show up to the user, do they?

As long as the notation is consistent and there is documentation describing what they are, I'm probably fine with most suggested names.

- Minor controller changes to reflect the fact that these fields now belong to an embedded type.
- Required updates to the fuzzer, validations, and defaults where necessary.

This PR will result in no behavioral changes, and should remain entirely transparent to users. It is effectively a no-op.
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this plan.


Next, we will make the required changes to the binding controller loop to make it possible to create bindings against service instances that are associated with the ns-scoped variants of serviceclasses and plans.

### Remove feature flag
Copy link
Contributor

Choose a reason for hiding this comment

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

I think he means feature gate

type ServiceBrokerSpec struct {
SharedServiceBrokerSpec `json:",inline"`

AuthInfo *ServiceBrokerAuthInfo `json:"authInfo,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is what I mean by localref version of struct above.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the old name, but the content needs to switch to some kind of localref.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what's implied. I can add the type description here if people think it's necessary

type ClusterServiceBrokerSpec struct {
SharedServiceBrokerSpec `json:",inline"`

AuthInfo *ClusterServiceBrokerAuthInfo `json:"authInfo,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This is new and needs to be defined as the existing spec.

@pmorie pmorie force-pushed the ns-scoped-resources-proposal branch from 648d0c0 to 157f9f5 Compare March 21, 2018 16:49
@pmorie
Copy link
Contributor Author

pmorie commented Mar 21, 2018

Addressed comments

@n3wscott
Copy link
Contributor

LGTM

@carolynvs
Copy link
Contributor

carolynvs commented Apr 17, 2018

EDIT: Updated s/SCOPE/NAMESPACE to match agreement below.

At the F2F, @eriknelson @jeremyrickard and I talked about what svcat would look like with namespaced scoped brokers.

  • get by namespace by default. This would change the current behavior of svcat to be consistent with how kubectl and svcat treat namespace scoped resources today. When no scope is specified, the current namespace defined on the kube context is used.
  • support --namespace and --all-namespaces flags
  • introduce --cluster flag to indicate listing at the cluster level
  • combine --all-namespaces and --cluster to show everything
$ svcat get classes
	NAME          NAMESPACE       DESCRIPTION
+------------------+-------------+---------------------+
  azure-mysql       test-ns   	     mysql on azure

$ svcat describe class azure-mysql
  Name: azure-mysql
  Namespace: test-ns
  ... TRUNCATED

$ svcat get classes --namespace qa-ns
	NAME          NAMESPACE       DESCRIPTION
+------------------+-------------+---------------------+
  google-mysql        qa-ns   	     mysql on google

$ svcat get classes --cluster
	NAME          NAMESPACE       DESCRIPTION
+------------------+-------------+---------------------+
  rando-mysql                     mysql on rando cloud

$ svcat describe class rando-mysql --cluster
  Name: rando-mysql
  ... TRUNCATED

$ svcat get classes --cluster --all-namespaces
	NAME          NAMESPACE       DESCRIPTION
+------------------+-------------+---------------------+
  rando-mysql                     mysql on rando cloud
  google-mysql        qa-ns   	     mysql on google
  azure-mysql       test-ns   	     mysql on azure

I didn't include UUID because I'm lazy and am just focusing on the new column, SCOPE.
I am suggesting SCOPE and not just NAMESPACE, because that will work well with user-defined classes and plans from my proposal and give us a way to indicate if a plan came from the broker or not. https://github.com/carolynvs/service-catalog/blob/3de6f842996056489d4c9aac53d4efa2b26a6381/docs/proposals/default-service-plans.md#service-class-discovery.

@n3wscott
Copy link
Contributor

new column, SCOPE.

What is the convention in k8s? It might just make sense to call it NAMESPACE

@jeremyrickard
Copy link
Contributor

If we label that field namespace, would we leave the cluster scoped resources blank in that column?

@n3wscott
Copy link
Contributor

If we label that field namespace, would we leave the cluster scoped resources blank in that column?

yeah, it has no namespace.

@jeremyrickard
Copy link
Contributor

yeah, it has no namespace.

@n3wscott Ok, that's what I assumed when I read your reply. I think I would vote in favor of the following:

  • Namespace Column on the table, with empty value for cluster level things
  • On describe, include the "scope" : [cluster|namespace] and then an optional namespace like...
  • JSON and YAML probably also the later case (is Type Metadata + object metadata sufficient in the yaml or json output to cover that?)
$ svcat describe class azure-mysql
  Name: azure-mysql
  Scope: namespace
  Namespace: test-ns
  ... TRUNCATED

and

$ svcat describe class rando-mysql --cluster
  Name: rando-mysql
  Scope: cluster
  ... TRUNCATED

I think it's clear from absence of a value in the namespace column, but on the describe i think the explicit fields help. What do you think @carolynvs

@carolynvs
Copy link
Contributor

I think it's clear from absence of a value in the namespace column, but on the describe i think the explicit fields help. What do you think @carolynvs

:shipit:


## Design

In this proposal we'll focus on adding the namespaced `ServiceBroker`, `ServiceClass`, and `ServicePlan` resources. For details on filtering which services and plans in a broker's catalog have k8s resources created for them, see https://github.com/kubernetes-incubator/Service Catalog/pull/1773.
Copy link
Contributor

Choose a reason for hiding this comment

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

@pmorie I have a general question about namespaced brokers.
Does it mean I can register same service-broker many times? For example Azure Broker as ClusterServiceBroker, and then as ServiceBroker twice for particular namespaces.

Choose a reason for hiding this comment

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

Also have the same question. Seems it should be possible to have the same broker as a CSB and a SB but would be good to know for sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you can absolutely do that. I'd be happy to make that explicit if people care about the design proposal beyond this PR.

Choose a reason for hiding this comment

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

@pmorie If user can register the same service-broker for many times, such as for clusterservicebroker and then as ServiceBroker for a namespace, how about the serviceclass fetched from the broker ?
As I can see, the for a particular apb, the class ID the unique, but it can be fetched by the clusterservicebroker and servicebroker, how to distinguish the two ?

Copy link

@maleck13 maleck13 Jun 27, 2018

Choose a reason for hiding this comment

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

I was also thinking about this. Would this perhaps be handled by the catalog restrictions filter on the broker? IE if using the same broker for a service broker and cluster broker then set a filter https://github.com/kubernetes-incubator/service-catalog/pull/1773/files#diff-316f664334f2a9051f4897bee901c5f5R135 to filter out what you want to expose as a ServiceClass and what you want to expose as a ClusterServicePlan. An example of doing this would be very useful I think (If this is the way it would be done)

Copy link
Contributor

Choose a reason for hiding this comment

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

@zihantang-rh, IMO when getting list of service classes you will use different API to distinguish same class with same uuid by SB or CSB API. During provisioning you always provide clusterServiceClassExternalName or serviceClassExternalName.

@carolynvs carolynvs added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed do-not-merge labels Jun 12, 2018

## Design

In this proposal we'll focus on adding the namespaced `ServiceBroker`, `ServiceClass`, and `ServicePlan` resources. For details on filtering which services and plans in a broker's catalog have k8s resources created for them, see https://github.com/kubernetes-incubator/Service Catalog/pull/1773.
Copy link

@maleck13 maleck13 Jun 21, 2018

Choose a reason for hiding this comment

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

The link here looks incorrect should it be https://github.com/kubernetes-incubator/service-catalog/pull/1773

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does look like a more correct link :)

@carolynvs
Copy link
Contributor

@pmorie Since namespaced brokers is implemented, and documented, what's the end state for this PR? Can I merge/close it?

@carolynvs
Copy link
Contributor

We discussed this at the SIG meeting today. Since this doc is going to go stale fast (if it isn't already), we decided to close the proposal, and then create follow-up issues to mine the proposal for any missing docs that should be added to our website.

There a few features yet to be implemented, but they are all on the svcat cli side, and we have people working on them already.

@carolynvs carolynvs closed this Sep 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. LGTM1 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.

Add a namespaced version of ServiceBroker, ServiceClass, and ServicePlan