2.7 KiB
2.7 KiB
Core Concepts
Harmony's design is based on a few key concepts. Understanding them is the key to unlocking the framework's power.
1. Score
- What it is: A Score is a declarative description of a desired state. It's a "resource" that defines what you want to achieve, not how to do it.
- Example:
ApplicationScoredeclares "I want this web application to be running and monitored."
2. Topology
- What it is: A Topology is the logical representation of your infrastructure and its abilities. It's the "where" your Scores will be applied.
- Key Job: A Topology's most important job is to expose which
Capabilitiesit supports. - Example:
HAClusterTopologyrepresents a bare-metal cluster and exposesCapabilitieslikeNetworkManagerandSwitch.K8sAnywhereTopologyrepresents a Kubernetes cluster and exposes theK8sClientCapability.
3. Capability
- What it is: A Capability is a specific feature or API that a
Topologyoffers. It's the "how" aTopologycan fulfill aScore's request. - Example: The
K8sClientcapability offers a way to interact with a Kubernetes API. TheSwitchcapability offers a way to configure a physical network switch.
4. Interpret
- What it is: An Interpret is the execution logic that makes a
Scorea reality. It's the "glue" that connects the desired state (Score) to the environment's abilities (Topology'sCapabilities). - How it works: When you apply a
Score, Harmony finds the matchingInterpretfor yourTopology. ThisInterpretthen uses theCapabilitiesprovided by theTopologyto execute the necessary steps.
5. Inventory
- What it is: An Inventory is the physical material (the "what") used in a cluster. This is most relevant for bare-metal or on-premise topologies.
- Example: A list of nodes with their roles (control plane, worker), CPU, RAM, and network interfaces. For the
K8sAnywhereTopology, the inventory might be empty or autoloaded, as the infrastructure is more abstract.
How They Work Together (The Compile-Time Check)
- You write a
Score(e.g.,ApplicationScore). - Your
Score'sInterpretlogic requires certainCapabilities(e.g.,K8sClientandIngress). - You choose a
Topologyto run it on (e.g.,HAClusterTopology). - At compile-time, Harmony checks: "Does
HAClusterTopologyprovide theK8sClientandIngresscapabilities thatApplicationScoreneeds?"- If Yes: Your code compiles. You can be confident it will run.
- If No: The compiler gives you an error. You've just prevented a "config-is-valid-but-platform-is-wrong" runtime error before you even deployed.