title | layout |
---|---|
Service Plan Defaults |
docwithnav |
Service Plan Defaults is a new feature in Service Catalog that gives operators the ability to configure default provision parameters on classes and plans. When a new instance of that class or plan is created, the default provision parameters defined are merged with parameters defined on the instance before it is provisioned.
For example, the operator could define a default set of IP addresses allowed to connect to databases, or require TLS by default.
The precedence order for parameters is: class defaults < plan defaults < instance parameters.
Service Plan Defaults is an alpha-feature of Service
Catalog that is off by default. To enable this feature, you will need
to pass an argument to the Webhook Server when you install Service Catalog:
--feature-gates ServicePlanDefaults=true
.
If you are using Helm, you can use the servicePlanDefaultsEnabled
setting
to control that flag:
helm install svc-cat/catalog --name catalog --set servicePlanDefaultsEnabled=true
Copy an existing class or plan and then define defaultProvisionParameters
.
Directly modifying the original resource managed by the service broker is not
recommended because your changes may be lost the next time the catalog syncs.
-
Using an existing plan as a template, save its definition to a yaml file.
kubectl get clusterserviceplan -o yaml PLAN > custom-plan.yaml
-
Edit the yaml file and remove the
ownerReferences
node from the metadata. This indicates to Service Catalog that it is a user-managed plan. -
Change the
name
andexternalName
of the plan to a unique value. -
Add a
defaultProvisionParameters
node to the spec and define the default parameters:apiVersion: servicecatalog.k8s.io/v1beta1 kind: ClusterServicePlan metadata: name: custom-mysql spec: clusterServiceBrokerName: minibroker externalID: mysql-5-7-14 externalName: custom-mysql defaultProvisionParameters: port: 5000
-
Save the yaml file and apply it using kubectl:
kubectl apply -f custom-plan.yaml
-
Create a copy of an existing class and give it a new name:
svcat create class custom-mysql --from mysql --scope cluster
-
Use kubectl to modify the spec of the new class:
kubectl edit clusterserviceclass custom-mysql
-
Add a
defaultProvisionParameters
node to the spec and define the default parameters:apiVersion: servicecatalog.k8s.io/v1beta1 kind: ClusterServiceClass metadata: name: custom-mysql spec: clusterServiceBrokerName: minibroker externalID: mysql-5-7-14 externalName: custom-mysql defaultProvisionParameters: port: 5000
-
Save the class after editing it.
-
Use kubectl to edit the new plan and modify the class reference (
clusterServiceClassRef
orserviceClassRef
) to use the name of the new class.kubectl edit clusterserviceplan tiny-plan
kind: ClusterServicePlan metadata: name: tiny-plan spec: clusterServiceBrokerName: minibroker clusterServiceClassRef: name: custom-mysql externalID: mysql-5-7-14 externalName: tiny-plan
-
Run
svcat get plans --class custom-mysql
and verify that the new custom plan is properly associated with the new class.$ svcat get plans --class custom-mysql NAME NAMESPACE CLASS DESCRIPTION +------------+-----------+--------------+-------------------------------------+ tiny-plan custom-mysql Fast, reliable, scalable, and easy to use open-source relational database system.
Once you have a class or plan with default provision parameters set, provision an instance:
$ svcat provision mydb --class mysql --plan custom-mysql
Name: mydb
Namespace: default
Status:
Class: mysql
Plan: custom-mysql
Parameters:
No parameters defined
$ svcat describe instance mydb
Name: mydb
Namespace: default
Status: Ready - The instance was provisioned successfully @ 2018-09-11 20:26:58 +0000 UTC
Class: mysql
Plan: custom-mysql
Parameters:
port: 5000
Note that the service instance initially did not have any parameters defined, but after it was provisioned it has the parameters defined on the custom service plan that we created above.