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

Commit b667117

Browse files
carolynvsk8s-ci-robot
authored andcommitted
Define default provisioning params on plans (#2282)
* Support default provisioning parameters on plans * Vendor mergemap which helps merging parameters from multiple sources * Reconcile instance and default params After a service instance resolves a class and plan, reconcile the default parameters defined on the plan with those from the instance. Persist the original default parameters on the instance status so that they are not applied more than once, and also help with debugging. * update generated code * allow the controller to update the instance/binding spec We need to be able to update the spec on both instances and bindings eventually so that default parameters can be applied for both provisioning and binding. * Add feature gate: ServicePlanDefaults * Document service plan defaults
1 parent 9fa968f commit b667117

25 files changed

Lines changed: 668 additions & 6 deletions

Gopkg.lock

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/catalog/templates/apiserver-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ spec:
5858
{{- end }}
5959
- --feature-gates
6060
- OriginatingIdentity={{.Values.originatingIdentityEnabled}}
61+
- --feature-gates
62+
- ServicePlanDefaults={{.Values.servicePlanDefaultsEnabled}}
6163
{{- if .Values.namespacedServiceBrokerDisabled }}
6264
- --feature-gates
6365
- NamespacedServiceBroker=false

charts/catalog/templates/controller-manager-deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ spec:
7171
{{- end }}
7272
- --feature-gates
7373
- OriginatingIdentity={{.Values.originatingIdentityEnabled}}
74+
- --feature-gates
75+
- ServicePlanDefaults={{.Values.servicePlanDefaultsEnabled}}
7476
{{- if .Values.asyncBindingOperationsEnabled }}
7577
- --feature-gates
7678
- AsyncBindingOperations=true

charts/catalog/templates/rbac.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ items:
101101
resources: ["clusterserviceplans"]
102102
verbs: ["get","list","watch","create","patch","update","delete"]
103103
- apiGroups: ["servicecatalog.k8s.io"]
104-
resources: ["clusterservicebrokers","serviceinstances","servicebindings"]
104+
resources: ["clusterservicebrokers"]
105105
verbs: ["get","list","watch"]
106+
- apiGroups: ["servicecatalog.k8s.io"]
107+
resources: ["serviceinstances","servicebindings"]
108+
verbs: ["get","list","watch", "update"]
106109
- apiGroups: ["servicecatalog.k8s.io"]
107110
resources: ["clusterservicebrokers/status","clusterserviceclasses/status","clusterserviceplans/status","serviceinstances/status","serviceinstances/reference","servicebindings/status"]
108111
verbs: ["update"]

charts/catalog/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,5 @@ originatingIdentityEnabled: true
167167
asyncBindingOperationsEnabled: false
168168
# Whether the NamespacedServiceBroker alpha feature should be disabled
169169
namespacedServiceBrokerDisabled: false
170+
# Whether the ServicePlanDefaults alpha feature should be enabled
171+
servicePlanDefaultsEnabled: false

contrib/hack/start-server.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ docker run -d --name apiserver \
4747
bin/service-catalog apiserver -v 10 --logtostderr --etcd-servers http://localhost:2379 \
4848
--storage-type=etcd --disable-auth \
4949
--feature-gates "PodPreset=true" \
50-
--feature-gates "NamespacedServiceBroker=true"
50+
--feature-gates "NamespacedServiceBroker=true" \
51+
--feature-gates "ServicePlanDefaults=true"
5152

5253
# Wait for apiserver to be up and running
5354
echo Waiting for API Server to be available...

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Afterward, see the topics below.
3333

3434
- [Using Namespaced Broker Resources](./namespaced-broker-resources.md)
3535
- [Filtering Broker Catalogs](./catalog-restrictions.md)
36+
- [Setting Defaults for Service Instances](./service-plan-defaults.md)
3637

3738
## Request for Comments
3839

docs/feature-gates.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ different Service Catalog.
2929
| `OriginatingIdentityLocking` | `true` | Alpha | v0.1.14 | |
3030
| `PodPreset` | `false` | Alpha | v0.1.6 | |
3131
| `ResponseSchema` | `false` | Alpha | v0.1.12 | |
32+
| `ServicePlanDefaults` | `false` | Alpha | v0.1.32 | |
3233
| `UpdateDashboardURL` | `false` | Alpha | v0.1.13 | |
3334

3435

@@ -92,6 +93,9 @@ for updating while we are still processing the current spec.
9293
- `ResponseSchema`: Enables the storage of the binding response schema in
9394
ServicePlans
9495

96+
- `ServicePlanDefaults`: Enables applying default values to service instances
97+
and bindings
98+
9599
- `UpdateDashboardURL`: Enables the update of DashboardURL in response to
96100
update service instance requests to brokers.
97101

docs/service-plan-defaults.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
title: Service Plan Defaults
3+
layout: docwithnav
4+
---
5+
6+
Service Plan Defaults is a new feature in Service Catalog that gives operators
7+
the ability to configure default provision parameters for a plan. When a new
8+
instance of that plan is created, the default provision parameters defined
9+
on the plan are merged with parameters defined on the instance before it is
10+
provisioned
11+
12+
For example, the operator could define a default set of IP addresses allowed to
13+
connect to databases, or require TLS by default.
14+
15+
## Enable Service Plan Defaults
16+
17+
Service Plan Defaults is an alpha-feature of Service
18+
Catalog that is off by default. To enable this feature, you will need
19+
to pass an argument to the API Server when you install Service Catalog:
20+
`--feature-gates ServicePlanDefaults=true`.
21+
22+
If you are using Helm, you can use the `servicePlanDefaultsEnabled` setting
23+
to control that flag:
24+
25+
```
26+
helm install svc-cat/catalog --name catalog --set servicePlanDefaultsEnabled=true
27+
```
28+
29+
## Define Default Provision Parameters
30+
31+
You can either define default provision parameters on an existing plan,
32+
or create a custom plan with the parameters defined.
33+
34+
### Create and modify a copy of an existing plan
35+
36+
1. Using an existing plan as a template, save its definition to a yaml file.
37+
38+
```
39+
kubectl get clusterserviceplan -o yaml PLAN > custom-plan.yaml
40+
```
41+
1. Edit the yaml file and remove the `ownerReferences` node from the metadata.
42+
This indicates to Service Catalog that it is a user-managed plan.
43+
1. Change the `name` and `externalName` of the plan to a unique value.
44+
1. Add a `defaultProvisionParameters` node to the spec and define the default
45+
parameters:
46+
47+
```yaml
48+
apiVersion: servicecatalog.k8s.io/v1beta1
49+
kind: ClusterServicePlan
50+
metadata:
51+
name: custom-mysql
52+
spec:
53+
clusterServiceBrokerName: minibroker
54+
externalID: mysql-5-7-14
55+
externalName: custom-mysql
56+
defaultProvisionParameters:
57+
port: 5000
58+
```
59+
1. Save the yaml file and apply it using kubectl:
60+
61+
```
62+
kubectl apply -f custom-plan.yaml
63+
```
64+
65+
### Modify an existing plan
66+
67+
1. Use kubectl to modify the spec of an existing plan:
68+
69+
```
70+
kubectl edit clusterserviceplan mysql-5-7-14
71+
```
72+
1. Add a `defaultProvisionParameters` node to the spec and define the default
73+
parameters:
74+
75+
```yaml
76+
apiVersion: servicecatalog.k8s.io/v1beta1
77+
kind: ClusterServicePlan
78+
metadata:
79+
name: 5-7-14
80+
spec:
81+
clusterServiceBrokerName: minibroker
82+
externalID: mysql-5-7-14
83+
externalName: 5-7-14
84+
defaultProvisionParameters:
85+
port: 5000
86+
```
87+
1. Save the updated resource definition.
88+
89+
## Provision a service instance with default parameters
90+
91+
Once you have a plan with default provision parameters set, provision an instance
92+
of that plan:
93+
94+
```console
95+
$ svcat provision mydb --class mysql --plan custom-mysql
96+
Name: mydb
97+
Namespace: default
98+
Status:
99+
Class: mysql
100+
Plan: custom-mysql
101+
102+
Parameters:
103+
No parameters defined
104+
105+
$ svcat describe instance mydb
106+
Name: mydb
107+
Namespace: default
108+
Status: Ready - The instance was provisioned successfully @ 2018-09-11 20:26:58 +0000 UTC
109+
Class: mysql
110+
Plan: custom-mysql
111+
112+
Parameters:
113+
port: 5000
114+
```
115+
116+
Note that the service instance initially did not have any parameters defined,
117+
but after it was provisioned it has the parameters defined on the custom
118+
service plan that we created above.

docsite/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ tocs:
5959
- resources
6060
- namespaced-broker-resources
6161
- catalog-restrictions
62+
- service-plan-defaults
6263
- docs-home # fallthrough, leave this last

0 commit comments

Comments
 (0)