|
| 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. |
0 commit comments