MES Operator and related Custom Resource Definitions
This section provides an overview of the MES Operator, along with its associated Custom Resource Definitions (CRDs) and Custom Resources (CRs). Together, these components facilitate an automated and declarative deployment of the PAS-X MES system within a Kubernetes environment.
Overview
The MES Operator is a Kubernetes-native controller developed specifically for managing the PAS-X MES system. It simplifies the installation, configuration, scaling, and maintenance of MES components by encapsulating operational knowledge into code.
The MES Operator is implemented using the Java Operator SDK (JOSDK), a framework for building Kubernetes operators in Java. It provides abstractions and tooling that align with Kubernetes concepts, allowing efficient development of operator logic.
Terminology
The Java Operator SDK introduces specific terminology that is essential for understanding and working with the MES Operator.
Operator
An Operator is the application that manages one or more Custom Resource Definitions and their corresponding Custom Resources. It orchestrates complex tasks by monitoring and adjusting system state to match the desired configuration specified by the CRs.
Reconciler
A Reconciler is the core component responsible for managing one specific CRD and its associated CRs. Each reconciler encapsulates the logic needed to ensure that the desired state defined in a CR matches the actual state of the system.
In the context of the Java Operator SDK, a reconciler is typically implemented as a service within the Operator application. Each reconciler continuously observes changes to its target CRs and performs reconciliation—detecting and correcting any state discrepancies by applying updates to Kubernetes resources as needed.
The following diagram illustrates the relationship between the Operator application, the Custom Resource (CRs), and their dedicated reconcilers:
Dependent Resource
In the context of the Java Operator SDK, a Dependent Resource represents any Kubernetes object (e.g., Deployment, ConfigMap, Secret, Job, etc.) that is created, managed, or deleted as part of the reconciliation process for a Custom Resource.
Dependent resources are automatically tracked and updated by the Reconciler based on their relationship to the owning CR. This ensures that all related components are in sync and conform to the expected state.
CRDs specific to MES Operator
The MES Operator defines two primary Custom Resource Definitions (CRDs) that represent and manage the structure, configuration, and lifecycle of a PAS-X MES system:
-
GenericService
-
Instance
Similar to the PAS-X MES system itself, the Custom Resources are namespace-scoped, meaning they are created, managed, and reconciled within a specific Kubernetes namespace. This scoping ensures isolation between different MES environments (e.g., test, staging, production) and aligns with Kubernetes best practices for multi-tenancy and separation of concerns.
GenericService
Represents an individual MES Service within a PAS-X MES instance, e.g. central or wms.
Each GenericService CRD defines and manages the deployment of a specific PAS-X MES Service and contains specific configurations for that service e.g., Docker image oder Database-Installers.
It encapsulates the necessary Kubernetes resources (e.g., Deployment, ConfigMap, Secret) required to run the service.
Instance
Represents the full PAS-X MES instance.
The Instance CRD models a complete MES installation.
It defines global configurations like Database connection, service composition (list of MES Service to be deployed), and high-level runtime properties.
It also manages status reporting at the instance level.
It is the primary interface for operational control — such as starting, stopping, or triggering migration — of the MES instance.
Relationships Between the CRDs
The Custom Resource Definitions (CRDs) managed by the MES Operator are tightly connected and follow a well-defined structure. Each CRD has a specific purpose and interacts with others to manage the full lifecycle of a PAS-X MES deployment.
The following diagram illustrates how the CRDs relate to and depend on one another:
GenericService
-
Each
GenericServiceis associated with exactly oneInstance. -
It encapsulates and manages its own Kubernetes resources (referred to as Dependent Resources), which are required to operate the MES Service successfully. These may include resources such as
Ingress, OpenShiftRoute,Service,Deployment,ConfigMap,Job,Role,RoleBindingorServiceAccount. -
On OpenShift, the operator creates Routes for service paths, including API-blocking Routes, instead of Kubernetes Ingress resources. Every expected Route must report
Admitted=True; see RouteExisting.
Instance
-
It composes multiple
GenericServiceCRs to represent and manage the functional building blocks of the PAS-X MES system. -
On OpenShift, it manages the router Secret-reader Role and RoleBinding when the TLS Secret and router identity fields are nonblank. See RouterSecretReaderRbacExisting for the exact evaluation scope. For certificate provisioning, see OpenShift certificate provisioning.
Status Objects
A Status Object is a dedicated section in a CR that is maintained by the corresponding Reconciler of the MES Operator. It is read-only from the user’s perspective and is updated only by the MES Operator during reconciliation.
The status provides real-time insights into the current state of the resource and is used by:
-
The operator itself to decide the next reconciliation actions
-
Other reconcilers (e.g., for aggregated state propagation)
-
System administrators for monitoring, validation, and troubleshooting
-
Automation tools to react programmatically to lifecycle events
The status values are dynamically set by the MES Operator during reconciliation.
They not only guide the operator’s internal decision-making but also serve as important indicators for auditability, automation tools, and operational troubleshooting.
|
Lifecycle Phases
The Instance and GenericService CRs expose a status.phase section that reflects the current lifecycle phase of the resource.
The following phases values are defined:
-
DEPLOYING– The CR is in the process of being deployed. This includes creating of all necessary Dependent Resources (e.g. Deployment, ConfigMap, …). -
ERROR– An error has occurred during reconciliation. The CR did not reach the desired state due to validation, configuration, or runtime issues. Requires manual intervention or redeployment. -
MIGRATING– The PAS-X MES system is currently performing a database schema migration as part of a lifecycle operation (e.g., install, upgrade). -
MIGRATED– The database schema migration has been successfully completed. The system will automatically continue with the next lifecycle phase. -
RUNNING– The CR is fully operational. All Dependent Resources are successfully deployed and healthy. -
UNDEPLOYING– The CR is being shut down. Associated Dependent Resources are being cleaned up. -
UNDEPLOYED– The CR is successfully shut down and all of its Dependent Resources have been successfully removed from the cluster.
Condition Overview
The Instance and GenericService CRs expose a set of status.conditions.
Conditions provide fine-grained insights into the internal state of each GenericService and Instance CR.
Unlike the lifecycle phase, which captures the overall progress of a CR, conditions describe specific aspects or checks relevant to system readiness, configuration, and operations.
Each condition consists of the following fields:
-
type– The name of the condition. -
status– One ofTrue,False, orUnknown.-
True— The condition is met, and the resource is in the desired state. -
False— The condition is not met, typically indicating an error or an unmet requirement. For example, the Deployment may not have the minimum number of available replicas and is still pending. -
Unknown— The controller cannot determine the current state, often due to pending reconciliation or incomplete evaluation data.
-
-
lastTransitionTime– The timestamp of the last condition update. -
reason– A brief machine-readable reason for the condition’s last status. -
message– A human-readable explanation for the current condition status.
These conditions are collected and exposed in the status.conditions list of each CR.
They are evaluated and updated independently by the MES Operator during reconciliation.
|
The set of available conditions depends on the CRD type and its configuration. Some conditions are common across all services, while others may only appear under specific configurations. |
Conditions are designed to:
-
Provide detailed operational diagnostics to human operators and automation tools.
-
Support external systems (e.g., health checks, dashboards, CI/CD controllers) in making decisions based on CR status.
-
Enable granular troubleshooting of deployment and reconciliation problems.
See the following document for a comprehensive list and description of all available conditions in the
-
GenericServiceCR: GenericService Status Conditions - API Reference -
InstanceCR: Instance Status Conditions - API Reference
Service Availability Overview
To improve visibility into the state of a PAS-X MES Instance, the status.serviceAvailabilityOverview object provides a concise summary about the associated GenericService resources. The information shows how many GenericService resources are desired to be deployed, how many are currently in a healthy state, and how many have been successfully migrated with their database schema updated.
This information is evaluated and maintained by the MES Operator as part of the reconciliation process.
The table below summarizes key metrics that reflect the overall availability and lifecycle progress of the managed services.
| Field | Description | Evaluation Conditions |
|---|---|---|
|
Number of |
Always evaluated. |
|
Number of |
Always evaluated. |
|
Number of |
Evaluated only if:
|
This availability overview supports:
-
Progress tracking during deployment and migration workflows
-
Operational visibility for administrators and automation systems
-
Troubleshooting by exposing gaps between the intended and actual service state
|
If the evaluation conditions for a field are not met, that field will be omitted from the |
Last Applied Change in Status
The status.lastAppliedChange field is used in both the Instance and GenericService Custom Resources (CRs).
It records the most recent change applied to the resource’s status section.
This field helps track when and why the status was last updated, improving transparency during reconciliation and making it easier to diagnose changes in the resource lifecycle.
MES Operator
The MES Operator is the core component responsible for managing the lifecycle of PAS-X MES deployments in the Kubernetes cluster. It implements the reconciler pattern to continuously ensure that the desired state defined in the Custom Resources (CRs) is achieved and maintained.
|
The MES Operator is currently under active development and does not yet support automated error recovery. |
Role and Responsibilities Within the Kubernetes Architecture
Understanding the position of the MES Operator in the Kubernetes ecosystem—especially in relation to Argo CD—is essential for clarifying its boundaries and responsibilities.
-
The MES Operator does not create or delete Custom Resources (CRs). These are managed declaratively by Argo CD, which applies and tracks the desired configuration of the PAS-X MES system.
-
The MES Operator exclusively reconciles the
statussection of CRs. It never modifies thespecsection. Modifications to thespecare solely handled by Argo CD. -
The MES Operator is responsible for reconciling any Dependent Resources (e.g.,
Deployment,ConfigMap,Secret) required to run the PAS-X MES system. It ensures these resources are correctly created, updated, or deleted to match the currentspecof the CRs.
The diagram below illustrates the division of responsibilities between Argo CD and the MES Operator, highlighting how they interact with Custom Resources and their corresponding Dependent Resources:
State Transitions
The MES Operator manages the lifecycle of the Custom Resources through a series of phase transitions.
These transitions can be triggered by adding annotations to the Instance CR that are executed by the MES Operator’s reconciler logic.
These phase-triggering annotations are used to control the system’s state and behavior and are described as follows:
-
install.mes.pasx.io/mes-system-running:true/false-
Indicates whether the PAS-X MES system should be running.
-
If
true, the MES Operator ensures all required services are deployed and running, reaching theRUNNINGphase. -
If
falseor unset, the MES Operator undeploys or stops all services, reaching theUNDEPLOYEDphase.
-
-
install.mes.pasx.io/db-installer-needed:true/false-
Indicates whether the DB-Installer should be executed as part of the lifecycle transition.
-
If
true, the MES Operator triggers the installer process. -
If
false, no migration action is taken.
-
|
When a db-schema migration is finished, the MES Operator will reset the |
Typical Deployment Lifecycle
This section describes the typical lifecycle of a PAS-X MES deployment as orchestrated by the MES Operator, focusing on the coordination between the Instance and GenericService Custom Resources (CRs).
Initial Deployment
When the Instance CR is initially created without lifecycle-related annotations, or if annotations are explicitly disabled (e.g., set to false), the MES Operator transitions the Instance as well as all GenericServices to the UNDEPLOYED phase.
This serves as the baseline state of the system.
Lifecycle Progression
Lifecycle transitions begin when the relevant annotations on the Instance Custom Resource (CR) are added or modified.
This triggers the MES Operator to initiate the reconciliation process toward the newly defined target phase.
The sequence is as follows:
-
Transition to Intermediate Phase: The MES Operator updates the
InstanceCR to reflect the intermediate phase (e.g.,MIGRATING,DEPLOYING) required to reach the desired final state. -
Propagation to GenericService CRs: Each
GenericServiceCR associated with theInstanceis reconciled and enters the same intermediate phase. -
Phase Completion by GenericService CRs: Once a
GenericServicecompletes its task for the given phase, it updates its ownstatus.phaseto reflect the corresponding state (e.g.,MIGRATED,RUNNING). -
Instance Transition to next Phase: When all associated
GenericServiceCRs have reached the next state, theInstanceCR is also transitioned to the that phase (e.g.,RUNNING).
This pattern repeats whenever a new lifecycle phase is triggered.
The Instance CR initiates the transition, the GenericService CRs perform the required actions, and the Instance CR completes the transition once all services are aligned.
Lifecycle Diagram
The following diagram illustrates the state transitions of both GenericService and Instance CRs during the typical installation lifecycle:
GenericService and Instance CRThe diagram uses standardized symbols explained in the following legend:
Error Handling and Behaviour in Edge Cases
This section outlines known error conditions and operational edge cases related to Instance and GenericService resources.
|
The following scenarios are considered exceptions to the normal operational flow and may require manual intervention or special handling. In particular, resources managed by Argo CD or the MES Operator must not be modified or deleted manually outside of their defined lifecycle operations. The system does not guarantee correct behavior in response to such manual changes. Doing so can lead to unexpected behavior or inconsistencies across the system. This risk is especially critical during transitional phases such as ongoing deployments or migrations. Manual interference during such operations may, for example, prevent the proper release of the database changelog lock, potentially causing issues with tools relying on database consistency. |
Instance
Edge cases and error scenarios specific to the Instance resource:
-
Transition to
ERRORphase-
An
Instancecan transition into theERRORphase from any other phase if an unrecoverable error occurs during reconciliation (e.g., in case of errors of the underlying MES Services).
-
-
Leaving the
ERRORphase-
To exit the
ERRORphase, manual intervention is required. This may involve fixing the underlying issue or, depending on the scenario, triggering an undeploy process. In some cases, the undeploy process may remove the associated resources, including the MES Services, allowing theInstanceto reach a clean state from which the services can be redeployed.
-
-
Transition from
UNDEPLOYEDto next phase-
If an
Instanceis in theUNDEPLOYEDphase and a new lifecycle operation is initiated (e.g., deployment or database schema migration), the MES Operator will only transition theInstanceto the next phase once all associatedGenericServiceCRs are also in theUNDEPLOYEDphase. This ensures the system is in a consistent and clean state before progressing, and prevents scenarios where anyGenericServiceCR might still be stuck in a previous phase (e.g.,UNDEPLOYING).
-
-
Transition from
RUNNINGtoDEPLOYINGphase-
If an
Instanceis in theRUNNINGphase and at least one associatedGenericServiceCR transitions to theDEPLOYINGphase, theInstancewill also transition to theDEPLOYINGphase (see below for details on how aGenericServicecan enter theDEPLOYINGphase). -
Once all associated
GenericServiceCRs have completed their deployment and transitioned back to theRUNNINGphase, theInstancewill also transition back to theRUNNINGphase.
-
GenericService
Edge cases and error scenarios specific to the GenericService resource:
-
Transition to
ERRORphase-
Similar to the
Instance, aGenericServicecan enter theERRORphase from any other phase if a failure occurs during lifecycle operations (e.g., deployment, database schema migration).
-
-
Instance Deletion During Active phase
-
If an
Instanceis deleted while aGenericServiceis in an active or transitional phase (such asDEPLOYING,MIGRATING,UNDEPLOYING, orRUNNING), the MES Operator will transition theGenericServiceto theUNDEPLOYEDphase. -
This fallback behavior ensures that any future
Instancewith altered configuration does not leave the system in an inconsistent state. The operator treats theGenericServiceas unlinked and triggers a clean re-deployment using the updatedInstancedata.
-
-
Transition from
RUNNINGtoDEPLOYINGphase-
If a
GenericServiceis in theRUNNINGphase and any relevant resource configuration changes (for example, configuration updates or certificate rotation), the MES Operator transitions the affectedGenericServiceCRs to theDEPLOYINGphase and restarts the associated MES Services (more precisely, their KubernetesDeploymentresources). -
Once the deployment is complete and the
GenericServicehas successfully restarted, it transitions back to theRUNNINGphase.
-
Reconciliation Process
The MES Operator follows a systematic reconciliation process to ensure that the actual state of the PAS-X MES system matches the desired state defined in the Custom Resources (CRs). This process is automatically triggered by changes to the CRs or their associated Dependent Resources.
GenericService Reconciliation
Whenever a change is detected in the GenericService or any of its associated resources (such as Instance or any Dependent Resource), the MES Operator automatically re-triggers the reconciliation process for that GenericService.
|
Special Case: The
|
Automatic Restart of MES Services in Case of Configuration Changes
This section describes how the MES Operator automatically restarts MES Services when configuration changes are detected in relevant ConfigMaps or Secrets.
Overview
The MES Operator monitors all configured Secrets and ConfigMaps that are consumed by a given MES Service.
For each relevant resource, the operator internally tracks the Kubernetes resourceVersion.
Whenever the resourceVersion of a ConfigMap or Secret changes, the MES Operator detects the update and triggers a restart of the affected MES Service deployments.
This ensures that MES Services always consume the latest configuration and credentials without requiring manual intervention.
|
Only ConfigMaps and Secrets that are actually referenced by a MES Service are monitored. Changes to unrelated resources do not trigger a restart. |
Deployment Annotations
The operator annotates the spec.template.metadata.annotations of the Kubernetes Deployment resource associated with each MES Service.
The annotation contains the current resourceVersion of each relevant ConfigMap or Secret.
The annotation follows a consistent pattern:
resource-version.<resourceType>.pasx.io/<resource-name>: "<resourceVersion>"
Example:
spec:
template:
metadata:
annotations:
resource-version.configmap.pasx.io/central-config: "12345"
resource-version.secret.pasx.io/database-credentials: "67890"
Changes to these annotations trigger a restart of the deployment.
|
Kubernetes annotation keys consist of an optional Full reference: Link |
Reconciliation Flow
The general reconciliation process for handling configuration changes is as follows:
-
MES Operator observes the Instance and GenericService CRs for changes, along with all associated resources.
-
For each relevant ConfigMap or Secret, the operator reads the current
resourceVersionfrom the Kubernetes API. -
The operator updates the corresponding Deployment annotations with the latest
resourceVersion. -
Kubernetes detects the change in the Pod template and performs a restart.
-
The MES Service Pods are recreated with the updated configuration or credentials.
|
Internally managed Secrets (e.g., SharedSecurity Secret) are excluded from automatic restart triggers because their content is immutable during runtime. |
Scope and Limitations
-
Only Deployments are automatically restarted.
-
Jobs, StatefulSets, DaemonSets, and other workload types are excluded.
-
Only configuration resources actively consumed by the MES Service trigger restarts.
-
Configuration changes applied via the PAS-X Service Configuration dialog (backed by ConfigService) are outside the MES Operator reconciliation scope, see Configuration Service in SmartInstall).