@@ -1609,3 +1609,27 @@ Example: "must be greater than \`request\`".
1609
1609
be less than 256", "must be greater than or equal to 0". Do not use words
1610
1610
like "larger than", "bigger than", "more than", "higher than", etc.
1611
1611
* When specifying numeric ranges, use inclusive ranges when possible.
1612
+
1613
+
1614
+ # # Automatic Resource Allocation And Deallocation
1615
+
1616
+ API objects often are [union](#Unions) object containing the following:
1617
+ 1. One or more fields identifying the `Type` specific to API object (aka the `discriminator`).
1618
+ 2. A set of N fields, only one of which should be set at any given time - effectively a union.
1619
+
1620
+ Controllers operating on the API type often allocate resources based on
1621
+ the `Type` and/or some additional data provided by user. A canonical example
1622
+ of this is the `Service` API object where resources such as IPs and network ports
1623
+ will be set in the API object based on `Type`. When the user does not specify
1624
+ resources, they will be allocated, and when the user specifies exact value, they will
1625
+ be reserved or rejected.
1626
+
1627
+ When the user chooses to change the `discriminator` value (e.g., from `Type X` to `Type Y`) without
1628
+ changing any other fields then the system should clear the fields that were used to represent `Type X`
1629
+ in the union along with releasing resources that were attached to `Type X`. This should automatically
1630
+ happen irrespective of how these values and resources were allocated (i.e., reserved by the user or
1631
+ automatically allocated by the system. A concrete example of this is again `Service` API. The system
1632
+ allocates resources such as `NodePorts` and `ClusterIPs` and automatically fill in the fields that
1633
+ represent them in case of the service is of type `NodePort` or `ClusterIP` (`discriminator` values).
1634
+ These resources and the fields representing them are automatically cleared when the users changes
1635
+ service type to `ExternalName` where these resources and field values no longer apply.
0 commit comments