// This assembly is included in the following assemblies:
//
// assembly-configuration-sizing-guide.adoc
//
[id='plan-sizing-{context}']
= Plan sizing

Plans enable dynamic scaling in the `standard` address space, as shown in the broker and router sizing sections. At the cluster level, the combination of plans and infrastructure configuration settings determines the maximum number of Pods that can be deployed on the cluster. Since {ProductName} does not support limiting the number of address spaces that can be created, it is a best practice to apply a policy to limit who is allowed to create address spaces. Such policy configuration can be handled through the standard {KubePlatform} policies.

From a capacity-planning perspective, it is useful to understand what the maximum number of Pods and the maximum amount of memory that can be consumed for a given address space. To make this calculation using a script, see link:{BookUrlBase}{BaseProductVersion}{BookNameUrl}#proc-run-calculation-script-messaging[Running the check-memory calculation script].

.Procedure

. Save the following script as `check-memory.sh`:
+
NOTE: Memory is assumed to be specified using the `Mi` unit, while storage is assumed to be specified using the `Gi` unit. Also, all three components,  `admin`, `router`, and `broker`, must have limits specified for the script to work as intended.
+
[source,shell,options="nowrap",subs="+quotes,attributes"]
----
#!/usr/bin/env bash
PLAN=$1

total_pods=0
total_memory_mb=0
total_storage_gb=0

routers=$(oc get addressspaceplan $PLAN -o jsonpath='{.spec.resourceLimits.router}')
brokers=$(oc get addressspaceplan $PLAN -o jsonpath='{.spec.resourceLimits.broker}')
infra=$(oc get addressspaceplan $PLAN -o jsonpath='{.spec.infraConfigRef}')

operator_memory=$(oc get standardinfraconfig $infra -o jsonpath='{.spec.admin.resources.memory}')
broker_memory=$(oc get standardinfraconfig $infra -o jsonpath='{.spec.broker.resources.memory}')
broker_storage=$(oc get standardinfraconfig $infra -o jsonpath='{.spec.broker.resources.storage}')
router_memory=$(oc get standardinfraconfig $infra -o jsonpath='{.spec.router.resources.memory}')

total_pods=$((routers + brokers + 1))
total_memory_mb=$(( (routers * ${router_memory%Mi}) + (brokers * ${broker_memory%Mi}) + ${operator_memory%Mi}))
total_storage_gb=$(( brokers * ${broker_storage%Gi}))

echo "Pods: ${total_pods}. Memory: ${total_memory_mb} MB. Storage: ${total_storage_gb} GB"
----

. Run the script using the following command:
+
----
bash calculate-memory.sh _standard-small_
----

+
If all components have limits defined in the assumed units, the script outputs the total resource limits for address spaces using this plan, as in the following example:
+
----
Pods: 3. Memory: 1280 MB. Storage: 2 GB
----
