docs/_data/notes/meshery-model-generation.md
Meshery Design Document: Meshery Model Generation
Status: Draft | Under Review | Approved
Meshery Model Generation A factory of component generators
Prologue 3 Design Goals and Objectives 3 Actors Glossary 4 Generating Models and Components 5 Flow: Statically Generated Components 5 Flow: Dynamically Generated Components 6 Flow: Importing Designs 6 Model Lifecycle 6 Providing granular control for Models 7 Functional Architecture 8 Architecture Diagram 8 Sequence Diagram 8 System Flows 9 Flow: <short title> 9 Flow: <short title> 9 Action Items 10 ActionItem 1: Integration Spreadsheet 10 ActionItem 2: Generate components from multiple sources. 10 ActionItem 3: 11 ActionItem 4: Doc generation being supported by all Model Generators 11 ActionItem 5: Generate components from different formats 11 Sources of Interaction with the spreadsheet: 11
Model Factory
See also: Meshery Models
Prologue
Entities under Meshery’s management must be represented in Meshery’s native Model format. In order for Meshery to support a broad variety of platforms, a uniform, but extensible factory for the creation of Models and their components must be implemented. Meshery needs to facilitate the generation of Models and Components from a variety of sources (e.g. a URL or an OCI registry) and of a variety of formats (e.g. a Kubernetes Manifest or a Helm Chart or Operator Lifecycle Manager (OLM)).
Goal 1: Translation between infrastructure and visual design tools Infrastructure
Goal 2: Make Models versatile by supporting a broad set of actions.
Status field to store labels such as Preferred and Ignored.mesheryctl model repo add meshery/meshery
Tracks a list of packages (e.g. helm chart names) to import or not import from the given Package Importer.
Package Manager will be responsible for tracking and managing the list of Packages.
So, A PackageManager knows how to:
The PackageManager interface will look something like this: type PackageManager interface { GetPackages() (Package, error) } These importers are mechanical in nature; machines to configured to interact with the repo-specific APIs E.g. Artifact Hub, Docker Hub Environment - a collection of Connections. Sometimes the target of a deployment. Connection - an individual instance of one type of Meshery’s supported integrations. Sometimes the target of a deployment. Generating Models and Components Component Generator (Meshery Server) using MeshKit’s functions Meshery Server is scheduled to run on schedule, generate components, and persist components in the local database.
As a user of Kanvas, I would like to mark some categories and components as displayed or not. Prioritize component generation for “Official” repos first.
Generating Models does not require Meshery Server
mesheryctl and Meshery Server both utilize MeshKit’s libraries for ongoing programmatic generation of models and components.
Flow: Statically Generated Components
Goal: As a user, I would like to have a large number of integrations (models) available in Meshery out-of-the-box without having to find and generate my own, so that I can quickly move along with either creating new Designs or using my existing Designs.
Actors:List of model sources is defined in Meshery Integrations spreadsheet.
Scheduled workflow is configured to run daily. Assumptions:
Meshery Users: Statically generated models are available in Meshery container image.
Meshery Developers: Statically generated models are available in meshery/meshery repo. Behavior:
Schedule: Component generation as part of nightly workflow and mesheryctl script updates components based on the attribute value from the spreadsheet, pushing these components to meshery/meshery and updating spreadsheet.
The Meshery project’s scheduled workflow is only additive in the list of statically-generated models. In other words, if a scheduled workflow fails or if a particular model source is unavailable or a particular model within a given source is unavailable, the Meshery project’s scheduled workflow will not remove support for that model.
Meshery Server on boot registers Models generated from supported registrants (e.g. Artifact Hub). Implementation:
One Helm connection will be available in every Meshery deployment. This Helm connection will have many repos configured.[a]
Label all duplicative components that are not of the “Preferred” model with “Ignored”.
Error Handling:
Acceptance Criteria:
Helm is the Registrant (and Connection) with many repos configured. Flow: Dynamically Generated Components Import and Export of Models
Dynamic generation and registration occurs upon initial connection[b] to each supported platform (e.g. a Kubernetes context transitions to Discovered state)
[Adapter] pushes its specific capabilities to Meshery Server. In order to register capabilities, Adapters will send a POST request to/api/meshmodel/components/register.
[Meshery Server] Components can be registered with the server by interfacing with MeshModel APIs, mesheryctl and Meshery UI are two clients (will be) capable of invoking generation and registration. User imports a Meshery Application as a single file reference, folder reference (to be recursively searched), or a git repository to be walked. Flow: Importing Designs Importing Designs requires Meshery Server, so that your Design can be associated with your account.
Improve failure experience when importing Designs that have components that are registered.
Cloud only supports importing of Designs and Patterns. It does not support import and translation of charts, compose, manifests, and so on. Registry Lifecycle Users should have control to enable/disable Categories, Models and Components, this can be an individual/team-level preference. As a result, the meshmodel APIs should be intelligent enough to expose only those Models that are enabled by the user. Providing granular control for Models What is “preferred-models.yaml”? [c] A manually curated list of models, referred during component generation (static/dynamic) which controls what is shown in the UI to the user when designing infrastructure. The Registry UI still shows all the models irrespective of their preference in “preferred-models.yaml”.
Meshery tracks a list of preferred models and components in preferred-models.yaml. The Model Generator generates and registers models and components for all imported or discovered entities.
Having a “preferred” list means inviting duplicative components across models.
AI: Move from whitelist to preferred list, while still generating duplicative components. Label all duplicative components that are not of the “Preferred” model with “Ignored”.
The default behavior will be to expose all components, with the exception of a few, such as those components which have invalid schema or components which cannot be configured on Kanvas, such components will be marked as disabled in the Integrations spreadsheet.
The presence of schema will take precedence over the user’s preference, i.e. if a component is enabled by the user but has an invalid/empty schema such components will not be available (unless explicitly requested by the user).
Considering the current situation of Kanvas, Kubernetes CRD is not configurable and we experience a crash. Adding granular control for MeshModels will ensure that, by default such components are disabled. This in no sense means that UI should be allowed to crash, instead, UI should handle it gracefully with appropriate fallback mechanisms.
Categories, Models and Components each will have an attribute which specifies whether it is enabled / disabled.[d]
Categories will take precedence over models, which in turn takes precedence over components, in case of “disabled” behavior, i.e. If a model is marked as disabled, all components for that model will be disabled irrespective of their individual behavior. Similarly for Categories and models.
FAQ
How does it solve the problem at hand for CRD? The “hasSchema” attribute present in the spreadsheet needs to be renamed to be more meaningful, something that depicts the above-discussed behavior. This attribute will decide whether the component is enabled/disabled for the end user. CRD components will be marked as disabled, by default.[e][f]
What happens if during a collaborative session user A has model A and model B, but user B has model A disabled. Union of enabled categories/modes/components of user A and user B will be taken. For each user we have the required information, regarding enabled resources, in situations like this, the user will be informed indicating some of the disabled resources have been enabled, as part of a collaborative session. The synchronization of enabled/disabled resources can happen at the time of initializing a collaboration session or at runtime.
Union of Enabled Resources: Meshery could synchronize the registered Models between user A and user B. In this case, Meshery would combine the registered Models from both users, resulting in model A being enabled for the collaborative session. User B would be informed that some of their disabled resources have been temporarily enabled due to the collaboration. Functional Architecture Although right now the only source we will be using is CRDs, this will change in the future, so the architecture should take that into account.
Our sources can be anything. It can be ArtifactHub packages, DockerHub etc. Depending on the source we use, the data type varies along with the logic. Architecture Diagram <here> Sequence Diagram <here> System Flows Flow: <short title> Goal: As a [developer/integrator/mesheryctl/operator] user, I would like to …….. , so that ……….. Actors:
Action Items
Each source should implement the interface:
GetComponents UpdateComponents Process // Any specific conversion Generate HandleLifecycle // Used at the time of deployment, to provisioning/de-provisioning of required Operators/Controllers
Currently there’s an interface defined IHost (see the definition of Host/Registrant above) (https://github.com/meshery/meshkit/blob/9b066f8219d796da5b77ad695c6a802c41339e60/models/meshmodel/registry/host.go#L70C1-L70C1) ActionItem 3:
Refer the notes shared in slack during implementation. (Support for optionally updating spreadsheet is also mentioned there) ActionItem 4: Doc generation being supported by all Model Generators
ActionItem 5: Generate components from different formats
Any other formats (and not specifically K8S manifests)
Key points: The factory should be such that after it has been implemented (all 5 Action Items), we have the ability to generate components with different combinations eg: Helm Charts from OCI/URL/file Terraforms provider from OCI/URL/file Sources of Interaction with the spreadsheet: At the time of generation: The spreadsheet will be referenced and can optionally updated some columns. (hasSchema column)
At the of component update: To update the SVGs, shape, colour and other metadata. During this step spreadsheet is referenced as read only
// Supporting Connection and credential definitions and relationships. // Publishing to Targets