-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Claim portability improvements #703
Description
Current situation
Currently claims are not really portable if they are not using the default class configured with ressource class policy.
To target a specific class which is not the default a user needs to know the specific class kind and api as well as its name and namespace using the classRef attribute:
apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstance
metadata:
name: mysql-instance
spec:
classRef:
kind: RDSInstanceClass
apiVersion: database.aws.crossplane.io/v1alpha1
name: mysql-standard
namespace: crossplane-systemProposal
Instead of targeting a specific class the user could define a set of wanted properties for the claim. At creation crossplane would automatically choose the ressource class that matches the user claim.
For example in the case of a database instance the user could define the minimum size of the DB:
apiVersion: database.crossplane.io/v1alpha1
kind: MySQLInstance
metadata:
name: mysql-instance
spec:
classRequirements:
size: 40In this case crossplane will try to find a concrete class that has a size at least of 40. If not a proper error should be returned to the user.
To be able to find the available classes for an abstract type the relation between policy and classes could be done the other way.
Currenly with a MySQLInstancePolicy resource it is possible to define the default resource class to use:
apiVersion: storage.crossplane.io/v1alpha1
kind: MySQLInstancePolicy
metadata:
name: mysql-policy
namespace: demo
defaultClassRef:
kind: RDSInstanceClass
apiVersion: database.aws.crossplane.io/v1alpha1
name: standard-mysql
namespace: crossplane-systemInstead of defining a ref MySQLInstancePolicy - <defaultClassRef> -> RDSInstanceClass it is maybe possible to reverse it to reference multiple concrete class in the policy: (RDSInstanceClass|CloudsqlInstanceClass|...) - <policyRef (default: true|false)> -> MySQLInstancePolicy:
apiVersion: database.aws.crossplane.io/v1alpha1
kind: RDSInstanceClass
metadata:
name: standard-mysql
namespace: crossplane-system
specTemplate:
size: 20
providerRef: ...
policyRef:
kind: MySQLInstancePolicy
apiVersion: storage.crossplane.io/v1alpha1
default: true
---
apiVersion: database.gcp.crossplane.io/v1alpha1
kind: CloudsqlInstanceClass
metadata:
name: big-mysql
namespace: crossplane-system
specTemplate:
databaseVersion: MYSQL_5_7
storageGB: 100
providerRef: ...
policyRef:
kind: MySQLInstancePolicy
apiVersion: storage.crossplane.io/v1alpha1Now, from the MySQLInstancePolicy it would be possible to find concrete classes to choose from following back references.
One of theses references can be set as the default one.