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 All indicates 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: !.*-sidecar or !proxy-service.

Precedence rules

If you specify multiple rules for the productChargedContainers annotation, they are evaluated in the following order:
  • If the productChargedContainers annotation is set to All, 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 productChargedContainers annotation contains specific inclusion patterns and a container does not match any of them, it is not charged (unless All is 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 with app- such as app-frontend or app-backend.
    • .*-service matches all container names that end with -service such as web-service or auth-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, or app-3.
    • app-[0-9] matches containers names such as app-1, app-7, or app-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 with app- and are followed by one or multiple numbers from zero to nine, such as app-1, app-47, or app-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 with app- and are followed by no or one number from zero to nine, such as app-1 and app-7, but not app-99.
    • The repetition quantifier {n} is used to match exactly n occurrences of the preceding element. For example: app-[0-9]{3} matches container names that start with app- and are followed by exactly three occurrences of numbers from zero to nine, such as app-372 and app-111, but not app-11.
  • 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 with web- or app-, such as web-service or app-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 as app-prod, app-dev, or app-test.

Examples

The following is a list of sample container names:
  • app-frontend-prod-v1 - Production front-end application, version 1
  • app-backend-prod-v2 - Production backend application, version 2
  • db-mysql-primary - Primary MySQL database
  • prometheus-monitoring-sidecar - Prometheus monitoring sidecar
  • fluentd-logging-sidecar - Fluentd logging sidecar
  • istio-proxy - Istio service mesh proxy
  • app-frontend-dev - Development front-end application
The sample container names are used in the following examples to show which containers are charged or not charged based on the regular expressions that are used in the 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-v1 Yes Matches pattern app-.*-prod-.*
app-backend-prod-v2 Yes Matches pattern app-.*-prod-.*
db-mysql-primary No Does not match any inclusion pattern
prometheus-monitoring-sidecar No Does not match any inclusion pattern
fluentd-logging-sidecar No Does not match any inclusion pattern
istio-proxy No Does not match any inclusion pattern
app-frontend-dev No 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-v1 Yes Included by All and not excluded
app-backend-prod-v2 Yes Included by All and not excluded
db-mysql-primary Yes Included by All and not excluded
prometheus-monitoring-sidecar No Excluded by pattern !.*-sidecar
fluentd-logging-sidecar No Excluded by pattern !.*-sidecar
istio-proxy No Excluded by exact match !istio-proxy
app-frontend-dev Yes Included by All and 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-v1 Yes Matches pattern .*-prod-.*
app-backend-prod-v2 Yes Matches pattern .*-prod-.*
db-mysql-primary Yes Matches pattern db-.*
prometheus-monitoring-sidecar No Does not match any inclusion pattern and contains monitoring which is excluded
fluentd-logging-sidecar No Does not match any inclusion pattern
istio-proxy No Does not match any inclusion pattern
app-frontend-dev No 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-v1 Yes Included by All and not excluded
app-backend-prod-v2 Yes Included by All and not excluded
db-mysql-primary Yes Included by All and not excluded
prometheus-monitoring-sidecar Yes Included by All and not excluded
fluentd-logging-sidecar Yes Included by All and not excluded
istio-proxy Yes Included by All and not excluded
app-frontend-dev No Excluded by pattern !.*-dev