|
| 1 | +# Resources |
| 2 | + |
| 3 | +Kusion uses [Spec](./6-specs.md) to manage resource specifications. A Kusion resource is a logical concept that encapsulates physical resources on different resource planes, including but not limited to Kubernetes, AWS, AliCloud, Azure and Google Cloud. |
| 4 | + |
| 5 | +Kusion Resources are produced by [Kusion Module Generators](./3-module/1-overview.md) and usually map to a physical resource that can be applied via a Kusion Runtime. |
| 6 | + |
| 7 | +## Runtimes |
| 8 | + |
| 9 | +Runtimes is the consumer of the resources in a Spec by turning them into actual physical resources in infrastructure providers. |
| 10 | + |
| 11 | +Currently there are two in-tree runtimes defined in the Kusion source code but we are planning to make them out-of-tree in the future: |
| 12 | + |
| 13 | +- Kubernetes, used to manage resources inside a Kubernetes cluster. This can be any native Kubernetes resources or CRDs (if you wish to manage infrastructures via [CrossPlane](https://www.crossplane.io/) or [Kubevela](https://kubevela.io/), for example, this is completely doable by creating a Kusion Module with a generator that produces the resource YAML for the relevant CRDs) |
| 14 | +- Terraform, used to manage infrastructure resources outside a Kubernetes cluster. Kusion uses Terraform as an executor that can manage basically any infrastructure given there is a [terraform provider](https://developer.hashicorp.com/terraform/language/providers) tailored for the infrastructure API. This is generally used to manage the lifecycle of infrastructure resources on clouds, no matter public or on-prem. |
| 15 | + |
| 16 | +## Resource Planes |
| 17 | + |
| 18 | +Resource Plane is a property of a Kusion resource. It represents the actual plane on which the resource exists. Current resource planes include `kubernetes`,`aws`,`azure`,`google`,`alicloud`,`ant` and `custom`. |
| 19 | + |
| 20 | +## Resource ID, Resource URN and Cloud Resource ID |
| 21 | + |
| 22 | +Kusion Resource ID is a unique identifier for a Kusion Resource within a Spec. It must be unique across a Spec. The resource ID is technically generated by module generators so there are no definite rules for producing a Kusion Resource ID. The best practice is to use the `KubernetesResourceID()` and `TerraformResourceID()` method from [kusion-module-framework](https://github.com/KusionStack/kusion-module-framework) to manage Kusion Resource IDs. You can use the [official module generators](https://github.com/KusionStack/catalog/blob/main/modules/mysql/src/alicloud_rds.go#L164) as a reference. |
| 23 | + |
| 24 | +'''tip |
| 25 | +Resource ID validations do exist. |
| 26 | +For Kubernetes resources, the resource ID must include API version, kind, namespace (if applicable) and name. |
| 27 | +For Terraform resources, the resource ID must include provider namespace, provider name, resource type and resource name. |
| 28 | +It's always recommended to use the `KubernetesResourceID()` and `TerraformResourceID()` method from [kusion-module-framework](https://github.com/KusionStack/kusion-module-framework) to produce the Resource IDs. |
| 29 | +''' |
| 30 | + |
| 31 | +Kusion Resource URN is used to uniquely identify a Kusion Resource across a Kusion server instance. It consists of `${project-name}:${stack-name}:${workspace-name}:${kusion-resource-id}` to ensure global uniqueness. |
| 32 | + |
| 33 | +Cloud Resource ID is used to map to an actual resource on the cloud. For AWS and Alicloud, this is usually known as the resource `ARN` on the cloud. For Azure and Google Cloud, this is known as the Resource ID. It can be empty in some cases, for example, a Kubernetes resource does not have cloud resource ID. |
| 34 | + |
| 35 | +## Resource Graphs |
| 36 | + |
| 37 | +A Resource Graph visualizes the relationship between all resources for a given stack. In the Kusion developer portal, you can inspect the resource graph by clicking on the `Resource Graph` tab on the stack page: |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +You can closely inspect the resource details by hovering over the resource node on the graph. |
| 42 | + |
| 43 | + |
0 commit comments