Deployment Model
Deployment Model represents another layer, physical model with its own structure and elements (deployment nodes).
It references the logical model and inherits its relationships.
Specification
Section titled “Specification”First, following the same approach, deployment node kinds have to defined within the specification:
specification { deploymentNode environment deploymentNode zone deploymentNode kubernetes { // Nodes have same styling options style { color blue icon tech:kubernetes multiple true } } deploymentNode vm { // Common properties for the kind notation 'Virtual Machine' technology 'VMware' }}
You define whatever you need to represent your deployment model and your ubiquitous language.
Deployment nodes
Section titled “Deployment nodes”The deployment model is a set of nodes, organized in a hierarchical structure:
deployment { environment prod { zone eu { zone zone1 { vm vm1 vm vm2 } // You can also use '=' with the name coming first zone2 = zone { vm1 = vm vm2 = vm } } }}
Node names must be unique within its container (parent node); same rules as for element names in the logical model.
Nodes can also have titles, descriptions, tags, style, and other properties just like logical elements.
deployment { environment prod 'Production' { #live #sla-customer description 'Production environment' technology 'OpenTofu' link https://likec4.dev
zone eu { title 'EU Region' // ... } }}
Extend nodes
Section titled “Extend nodes”As in the logical model, you can extend
deployment nodes:
// File: 'deployments/prod.c4'deployment { environment prod}
// File: 'deployments/prod/zone-eu.c4'deployment { extend prod { zone eu }}
Same rules apply for extending nodes:
- extended node must be referenced by a fully qualified name.
- define additional properties.
Deployed instances
Section titled “Deployed instances”Operator instanceOf
“deploys” elements from the logical model to deployment nodes:
deployment { environment prod { zone eu { zone zone1 { // 'frontend.ui' is a logical element // by default, instance has same name, // i.e. it becomes 'prod.eu.zone1.ui' instanceOf frontend.ui // this becomes 'prod.eu.zone1.api' instanceOf backend.api }
zone zone2 { // or use '=' with the name coming first ui = instanceOf frontend.ui
// two instances of same element api1 = instanceOf backend.api api2 = instanceOf backend.api }
// Deploy to any level, not only leaf nodes // Assume database shared between zones db = instanceOf database } }}
Deployed instance inherits properties and styling from the element.
It is possible to override:
deployment { environment prod { zone eu { db = instanceOf database { title 'Primary DB' technology 'PostgreSQL with streaming replication' icon tech:postgresql style { color red } } } }}
Deployment relationships
Section titled “Deployment relationships”Deployment model inherits relationships from the logical model.
But also allows to define specific ones:
deployment { environment prod { vm vm1 { db = instanceOf database 'Primary DB' } vm vm2 { db = instanceOf database 'Standby DB' } vm2.db -> vm1.db 'replicates' }}
As you see, relationship is between same logical element, but different instances.
Assume, we don’t need this relationship in our logical model, but it makes sense for deployment.
Deployment relationships can be “kinded”, and have same properties as logical ones:
deployment { environment prod { vm2.db -[streaming]-> vm1.db { #next, #live title 'replicates' description 'Streaming replication' } }}