Values of the
productChargedContainers annotation
License Service uses the productChargedContainers annotation to
determine which containers within a pod should be charged for licensing. You can define the
containers by listing their exact names, or by using regular expressions to define inclusion and
exclusion patterns.
Accepted syntax
The following syntax is supported in the
productChargedContainers annotation: - All containers: The value
Allindicates that all containers are charged. An empty value indicates that all containers are not charged. - Exact match: The exact container name indicates a single container that is charged. For
example:
container1. - Multiple values: Multiple container names separated with a semicolon (
;) indicate a list of exact containers that are charged. For example:container1,container2,container3. - Inclusion patterns: Any string that contains wildcard characters such as the asterisk
(
*) indicates a pattern of container names that are charged. For example:app-.*. - Exclusion patterns: The
!prefix followed by a regular expression pattern or an exact container name indicates which containers are not charged. For example:!.*-sidecaror!proxy-service.
Precedence rules
If you specify multiple rules for the
productChargedContainers annotation, they
are evaluated in the following order:- If the
productChargedContainersannotation is set toAll, all containers are marked as charged. - If a container matches any exclusion pattern that is defined with the
!prefix, the container is excluded regardless of inclusion rules. - If the
productChargedContainersannotation contains specific inclusion patterns and a container does not match any of them, it is not charged (unlessAllis specified). - If a container name exactly matches an entry without wildcards, it is included (unless it is explicitly excluded).
Supported regular expressions
The following types of regular expressions are supported in the
productChargedContainers annotation: - Wildcards: an asterisk (
*) is used to match any sequence of characters. For example:app-.*matches all container names that start withapp-such asapp-frontendorapp-backend..*-servicematches all container names that end with-servicesuch asweb-serviceorauth-service.
- Character classes: square brackets
[]are used to match any single character from the set. For example:app-[123]matches containers names:app-1,app-2, orapp-3.app-[0-9]matches containers names such asapp-1,app-7, orapp-9.
- Quantifiers:
- The plus sign (
+) is used to match one or multiple occurrences of the preceding element. For example:app-[0-9]+matches container names that start withapp-and are followed by one or multiple numbers from zero to nine, such asapp-1,app-47, orapp-305. - The question mark (
?) is used to match zero or one occurrence of the preceding element. For example:app-[0-9]?matches container names that start withapp-and are followed by no or one number from zero to nine, such asapp-1andapp-7, but notapp-99. - The repetition quantifier
{n}is used to match exactlynoccurrences of the preceding element. For example:app-[0-9]{3}matches container names that start withapp-and are followed by exactly three occurrences of numbers from zero to nine, such asapp-372andapp-111, but notapp-11.
- The plus sign (
- Group with an alternation operator: A capturing group
(x|y)is used to match either of the listed elements. For example:(web|app)-.*matches container names that start withweb-orapp-, such asweb-serviceorapp-frontend. - End-of-string anchor: The dollar sign (
$) is used to match the end of the string exactly. For example:app-(prod|dev|test)$matches container names that end exactly with one of the specified values such asapp-prod,app-dev, orapp-test.
Examples
The following is a list of sample container names:
app-frontend-prod-v1- Production front-end application, version 1app-backend-prod-v2- Production backend application, version 2db-mysql-primary- Primary MySQL databaseprometheus-monitoring-sidecar- Prometheus monitoring sidecarfluentd-logging-sidecar- Fluentd logging sidecaristio-proxy- Istio service mesh proxyapp-frontend-dev- Development front-end application
productChargedContainers annotation.- Example 1: Charge only production application containers
- Regular
expression:
productChargedContainers: "app-.*-prod-.*"Table 1. Example 1 explanation Container Name Charged? Reason app-frontend-prod-v1Yes Matches pattern app-.*-prod-.*app-backend-prod-v2Yes Matches pattern app-.*-prod-.*db-mysql-primaryNo Does not match any inclusion pattern prometheus-monitoring-sidecarNo Does not match any inclusion pattern fluentd-logging-sidecarNo Does not match any inclusion pattern istio-proxyNo Does not match any inclusion pattern app-frontend-devNo Does not match any inclusion pattern - Example 2: Charge all containers except for sidecars and proxies
- Regular
expression:
productChargedContainers: "All;!.*-sidecar;!.*-proxy;!istio-proxy"Table 2. Example 2 explanation Container Name Charged? Reason app-frontend-prod-v1Yes Included by Alland not excludedapp-backend-prod-v2Yes Included by Alland not excludeddb-mysql-primaryYes Included by Alland not excludedprometheus-monitoring-sidecarNo Excluded by pattern !.*-sidecarfluentd-logging-sidecarNo Excluded by pattern !.*-sidecaristio-proxyNo Excluded by exact match !istio-proxyapp-frontend-devYes Included by Alland not excluded - Example 3: Charge only production containers excluding monitoring
- Regular
expression:
productChargedContainers: ".*-prod-.*;db-.*;!.*monitoring.*"Table 3. Example 3 explanation Container Name Charged? Reason app-frontend-prod-v1Yes Matches pattern .*-prod-.*app-backend-prod-v2Yes Matches pattern .*-prod-.*db-mysql-primaryYes Matches pattern db-.*prometheus-monitoring-sidecarNo Does not match any inclusion pattern and contains monitoringwhich is excludedfluentd-logging-sidecarNo Does not match any inclusion pattern istio-proxyNo Does not match any inclusion pattern app-frontend-devNo Does not match any inclusion pattern - Example 4: Charge all containers except for development
-
productChargedContainers: "All;!.*-dev"Table 4. Example 4 explanation Container Name Charged? Reason app-frontend-prod-v1Yes Included by Alland not excludedapp-backend-prod-v2Yes Included by Alland not excludeddb-mysql-primaryYes Included by Alland not excludedprometheus-monitoring-sidecarYes Included by Alland not excludedfluentd-logging-sidecarYes Included by Alland not excludedistio-proxyYes Included by Alland not excludedapp-frontend-devNo Excluded by pattern !.*-dev