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:

Difference between Operator and Reconciler
Figure 1. Difference between Operator and Reconciler

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:

Dependencies between the CRDs
Figure 2. Dependencies between the Custom Resource Definitions (CRDs)

GenericService

  • Each GenericService is associated with exactly one Instance.

  • 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, OpenShift Route, Service, Deployment, ConfigMap, Job, Role, RoleBinding or ServiceAccount.

  • 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 GenericService CRs 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 of True, False, or Unknown.

    • 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

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.

Table 1. Table: Summary of Service Availability Metrics
Field Description Evaluation Conditions

numberOfDesiredServices

Number of GenericService resources intended to be deployed as part of this Instance. This reflects the complete set of desired GenericService resources defined by the user.

Always evaluated.

numberOfHealthyServices

Number of GenericService resources that are both in Running phase and marked Ready. Only such GenericService resources are counted as healthy.

Always evaluated.

numberOfMigratedServices

Number of GenericService resources that have successfully completed their database schema migration process.

Evaluated only if:

  • The db-installer-needed annotation is set on the Instance CR

  • The Instance is in one of the following phases: MIGRATING, MIGRATED, or ERROR

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 status.serviceAvailabilityOverview section. This behavior applies only to conditionally evaluated fields such as numberOfMigratedServices.

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 status section of CRs. It never modifies the spec section. Modifications to the spec are 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 current spec of 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:

Responsibilities of Argo CD and the MES Operator in Managing Custom and Dependent Resources
Figure 3. Responsibilities of Argo CD and the MES Operator in managing Custom Resources and 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 the RUNNING phase.

    • If false or unset, the MES Operator undeploys or stops all services, reaching the UNDEPLOYED phase.

  • 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 db-installer-needed annotation. Besides this exception, the annotations are expected to be set and managed exclusively by higher-level tools (e.g., Kubectl, Argo), which will patch both annotations based on the user’s intended action.

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:

  1. Transition to Intermediate Phase: The MES Operator updates the Instance CR to reflect the intermediate phase (e.g., MIGRATING, DEPLOYING) required to reach the desired final state.

  2. Propagation to GenericService CRs: Each GenericService CR associated with the Instance is reconciled and enters the same intermediate phase.

  3. Phase Completion by GenericService CRs: Once a GenericService completes its task for the given phase, it updates its own status.phase to reflect the corresponding state (e.g., MIGRATED, RUNNING).

  4. Instance Transition to next Phase: When all associated GenericService CRs have reached the next state, the Instance CR 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 State Transition
Figure 4. State Transition Diagram for the GenericService and Instance CR

The diagram uses standardized symbols explained in the following legend:

State Transition Diagram Symbols
Figure 5. State Transition Diagram Symbols

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 ERROR phase

    • An Instance can transition into the ERROR phase from any other phase if an unrecoverable error occurs during reconciliation (e.g., in case of errors of the underlying MES Services).

  • Leaving the ERROR phase

    • To exit the ERROR phase, 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 the Instance to reach a clean state from which the services can be redeployed.

  • Transition from UNDEPLOYED to next phase

    • If an Instance is in the UNDEPLOYED phase and a new lifecycle operation is initiated (e.g., deployment or database schema migration), the MES Operator will only transition the Instance to the next phase once all associated GenericService CRs are also in the UNDEPLOYED phase. This ensures the system is in a consistent and clean state before progressing, and prevents scenarios where any GenericService CR might still be stuck in a previous phase (e.g., UNDEPLOYING).

  • Transition from RUNNING to DEPLOYING phase

    • If an Instance is in the RUNNING phase and at least one associated GenericService CR transitions to the DEPLOYING phase, the Instance will also transition to the DEPLOYING phase (see below for details on how a GenericService can enter the DEPLOYING phase).

    • Once all associated GenericService CRs have completed their deployment and transitioned back to the RUNNING phase, the Instance will also transition back to the RUNNING phase.

GenericService

Edge cases and error scenarios specific to the GenericService resource:

  • Transition to ERROR phase

    • Similar to the Instance, a GenericService can enter the ERROR phase from any other phase if a failure occurs during lifecycle operations (e.g., deployment, database schema migration).

  • Instance Deletion During Active phase

    • If an Instance is deleted while a GenericService is in an active or transitional phase (such as DEPLOYING, MIGRATING, UNDEPLOYING, or RUNNING), the MES Operator will transition the GenericService to the UNDEPLOYED phase.

    • This fallback behavior ensures that any future Instance with altered configuration does not leave the system in an inconsistent state. The operator treats the GenericService as unlinked and triggers a clean re-deployment using the updated Instance data.

  • Transition from RUNNING to DEPLOYING phase

    • If a GenericService is in the RUNNING phase and any relevant resource configuration changes (for example, configuration updates or certificate rotation), the MES Operator transitions the affected GenericService CRs to the DEPLOYING phase and restarts the associated MES Services (more precisely, their Kubernetes Deployment resources).

    • Once the deployment is complete and the GenericService has successfully restarted, it transitions back to the RUNNING phase.

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: central Service

The central service is a specific type of GenericService with additional handling due to its pivotal role in the PAS-X MES system.

  • Database Schema Migration:

    • The MES Operator first reconciles the central service to bring it to a consistent state.

    • Once migration of the central database schema is completed, the MES Operator proceeds to migrate all other GenericServices in parallel.

  • Deployment:

    • The MES Operator schedules the central service first and ensures it is placed on a node in the Kubernetes cluster.

    • Once the central pod is placed (note: not necessarily fully started), the MES Operator begins parallel reconciliation and placement of all other GenericServices.

Instance Reconciliation

Whenever a change is detected in the Instance or any of its associated resources (such as GenericServices or any Secrets relevant to the PAS-X MES Instance), the MES Operator automatically re-triggers the reconciliation process for that Instance.

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 prefix and a mandatory name segment, separated by a /. The name segment is limited to 63 characters.
By placing only the resource name after the /, we ensure the annotation adheres to Kubernetes naming constraints while keeping it concise, readable, and unique.

Full reference: Link

Reconciliation Flow

The general reconciliation process for handling configuration changes is as follows:

  1. MES Operator observes the Instance and GenericService CRs for changes, along with all associated resources.

  2. For each relevant ConfigMap or Secret, the operator reads the current resourceVersion from the Kubernetes API.

  3. The operator updates the corresponding Deployment annotations with the latest resourceVersion.

  4. Kubernetes detects the change in the Pod template and performs a restart.

  5. 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).

Benefits

  • Guarantee that configuration updates are applied consistently.

  • Reduce manual operational effort and prevent configuration drift.

  • Provide full transparency via annotations.

  • Align with Kubernetes-native restart semantics and the reconciler pattern of the MES Operator.