Skip to content

Commit

Permalink
WIP: Rename ResourceGroup to ResourceGraphDefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
a-hilaly committed Jan 23, 2025
1 parent bf4fc85 commit cb89862
Show file tree
Hide file tree
Showing 112 changed files with 739 additions and 753 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body:
**Expected Behavior**:
**Reproduction Steps** (Please include `ResourceGroup` and `Instances` files):
**Reproduction Steps** (Please include `ResourceGraphDefinition` and `Instances` files):
**Versions**:
- kro version:
Expand All @@ -38,7 +38,7 @@ body:
label: Which option describes the most your issue?
multiple: true
options:
- ResourceGroup (Create, Update, Deletion)
- ResourceGraphDefinition (Create, Update, Deletion)
- Instance (Create, Update, Deletion)
- Directed Acyclic Graph inference
- Common Expression Language (CEL)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

tt:
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/controller/resourcegroup"
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./pkg/controller/resourcegraphdefinition"

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This project aims to simplify the creation and management of complex custom resources for Kubernetes.

Kube Resource Orchestrator (**kro**) provides a powerful abstraction layer that allows you to define complex multi-resource constructs as reusable components in your applications and systems.
You define these using kro's fundamental custom resource, *ResourceGroup*.
You define these using kro's fundamental custom resource, *ResourceGraphDefinition*.
This resource serves as a blueprint for creating and managing collections of underlying Kubernetes resources.

With kro, you define custom resources as your fundamental building blocks for Kubernetes.
Expand All @@ -19,7 +19,7 @@ kro is Kubernetes native and integrates seamlessly with existing tools to preser
| -------------------------------------- | ------------------------------- |
| [Introduction][kro-overview] | An introduction to kro |
| [Installation][kro-installation] | Install kro in your cluster |
| [Getting started][kro-getting-started] | Deploy your first ResourceGroup |
| [Getting started][kro-getting-started] | Deploy your first ResourceGraphDefinition |
| [Concepts][kro-concepts] | Learn more about kro concepts |
| [Examples][kro-examples] | Example resources |
| [Contributions](./CONTRIBUTING.md) | How to get involved |
Expand All @@ -35,28 +35,28 @@ kro is Kubernetes native and integrates seamlessly with existing tools to preser
1. **What is kro?**

Kube Resource Orchestrator (**kro**) is a new operator for Kubernetes that simplifies the creation of complex Kubernetes resource configurations.
kro lets you create and manage custom groups of Kubernetes resources by defining them as a *ResourceGroup*, the project's fundamental custom resource.
ResourceGroup specifications define a set of resources and how they relate to each other functionally.
kro lets you create and manage custom groups of Kubernetes resources by defining them as a *ResourceGraphDefinition*, the project's fundamental custom resource.
ResourceGraphDefinition specifications define a set of resources and how they relate to each other functionally.
Once defined, resource groups can be applied to a Kubernetes cluster where the kro controller is running.
Once validated by kro, you can create instances of your resource group.
kro translates your ResourceGroup instance and its parameters into specific Kubernetes resources and configurations which it then manages for you.
kro translates your ResourceGraphDefinition instance and its parameters into specific Kubernetes resources and configurations which it then manages for you.

2. **How does kro work?**

kro is designed to use core Kubernetes primitives to make resource grouping, customization, and dependency management simpler.
When a ResourceGroup is applied to the cluster, the kro controller verifies its specification, then dynamically creates a new CRD and registers it with the API server.
When a ResourceGraphDefinition is applied to the cluster, the kro controller verifies its specification, then dynamically creates a new CRD and registers it with the API server.
kro then deploys a dedicated controller to respond to instance events on the CRD.
This microcontroller is responsible for managing the lifecycle of resources defined in the ResourceGroup for each instance that is created.
This microcontroller is responsible for managing the lifecycle of resources defined in the ResourceGraphDefinition for each instance that is created.

3. **How do I use kro?**

First, you define your custom resource groups by creating *ResourceGroup* specifications.
First, you define your custom resource groups by creating *ResourceGraphDefinition* specifications.
These specify one or more Kubernetes resources, and can include specific configuration for each resource.

For example, you can define a *WebApp* resource group that is composed of a *Deployment*, pre-configured to deploy your web server backend, and a *Service* configured to run on a specific port.
You can just as easily create a more complex *WebAppWithDB* resource group by combining the existing *WebApp* resource group with a *Table* custom resource to provision a cloud managed database instance for your web app to use.

Once you have defined a ResourceGroup, you can apply it to a Kubernetes cluster where the kro controller is running.
Once you have defined a ResourceGraphDefinition, you can apply it to a Kubernetes cluster where the kro controller is running.
kro will take care of the heavy lifting of creating CRDs and deploying dedicated controllers in order to manage instances of your new custom resource group.

You are now ready to create instances of your new custom resource group, and kro will respond by dynamically creating, configuring, and managing the underlying Kubernetes resources for you.
Expand All @@ -74,7 +74,7 @@ kro is Kubernetes native and integrates seamlessly with existing tools to preser
6. **Can I use this in production?**

This project is in active development and not yet intended for production use.
The *ResourceGroup* CRD and other APIs used in this project are not solidified and highly subject to change.
The *ResourceGraphDefinition* CRD and other APIs used in this project are not solidified and highly subject to change.

7. **Will this be built into Amazon Elastic Kubernetes Service (EKS)?**

Expand Down
18 changes: 9 additions & 9 deletions api/v1alpha1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import (
type ConditionType string

const (
// ResourceGroupConditionTypeGraphSynced indicates the state of the directed
// ResourceGraphDefinitionConditionTypeGraphSynced indicates the state of the directed
// acyclic graph (DAG) that kro uses to manage the resources in a
// ResourceGroup.
ResourceGroupConditionTypeGraphVerified ConditionType = "GraphVerified"
// ResourceGroupConditionTypeCustomResourceDefinitionSynced indicates the state of the
// ResourceGraphDefinition.
ResourceGraphDefinitionConditionTypeGraphVerified ConditionType = "GraphVerified"
// ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced indicates the state of the
// CustomResourceDefinition (CRD) that kro uses to manage the resources in a
// ResourceGroup.
ResourceGroupConditionTypeCustomResourceDefinitionSynced ConditionType = "CustomResourceDefinitionSynced"
// ResourceGroupConditionTypeReconcilerReady indicates the state of the reconciler.
// Whenever an ResourceGroup resource is created, kro will spin up a
// ResourceGraphDefinition.
ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced ConditionType = "CustomResourceDefinitionSynced"
// ResourceGraphDefinitionConditionTypeReconcilerReady indicates the state of the reconciler.
// Whenever an ResourceGraphDefinition resource is created, kro will spin up a
// reconciler for that resource. This condition indicates the state of the
// reconciler.
ResourceGroupConditionTypeReconcilerReady ConditionType = "ReconcilerReady"
ResourceGraphDefinitionConditionTypeReconcilerReady ConditionType = "ReconcilerReady"
)

const (
Expand Down
24 changes: 0 additions & 24 deletions api/v1alpha1/resourcegroup_state.go

This file was deleted.

68 changes: 39 additions & 29 deletions api/v1alpha1/resource_group.go → api/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ const (
DefaultServiceAccountKey = "*"
)

// ResourceGroupSpec defines the desired state of ResourceGroup
type ResourceGroupSpec struct {
// The schema of the resourcegroup, which includes the
// ResourceGraphDefinitionSpec defines the desired state of ResourceGraphDefinition
type ResourceGraphDefinitionSpec struct {
// The schema of the resourcegraphdefinition, which includes the
// apiVersion, kind, spec, status, types, and some validation
// rules.
//
// +kubebuilder:validation:Required
Schema *Schema `json:"schema,omitempty"`
// The resources that are part of the resourcegroup.
// The resources that are part of the resourcegraphdefinition.
//
// +kubebuilder:validation:Optional
Resources []*Resource `json:"resources,omitempty"`
Expand All @@ -46,36 +46,36 @@ type ResourceGroupSpec struct {
}

// Schema represents the attributes that define an instance of
// a resourcegroup.
// a resourcegraphdefinition.
type Schema struct {
// The kind of the resourcegroup. This is used to generate
// and create the CRD for the resourcegroup.
// The kind of the resourcegraphdefinition. This is used to generate
// and create the CRD for the resourcegraphdefinition.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="kind is immutable"
Kind string `json:"kind,omitempty"`
// The APIVersion of the resourcegroup. This is used to generate
// and create the CRD for the resourcegroup.
// The APIVersion of the resourcegraphdefinition. This is used to generate
// and create the CRD for the resourcegraphdefinition.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="apiVersion is immutable"
APIVersion string `json:"apiVersion,omitempty"`
// The group of the resourcegroup. This is used to set the API group
// The group of the resourcegraphdefinition. This is used to set the API group
// of the generated CRD. If omitted, it defaults to "kro.run".
//
// +kubebuilder:validation:Optional
// +kubebuilder:default="kro.run"
Group string `json:"group,omitempty"`
// The spec of the resourcegroup. Typically, this is the spec of
// the CRD that the resourcegroup is managing. This is adhering
// The spec of the resourcegraphdefinition. Typically, this is the spec of
// the CRD that the resourcegraphdefinition is managing. This is adhering
// to the SimpleSchema spec
Spec runtime.RawExtension `json:"spec,omitempty"`
// The status of the resourcegroup. This is the status of the CRD
// that the resourcegroup is managing. This is adhering to the
// The status of the resourcegraphdefinition. This is the status of the CRD
// that the resourcegraphdefinition is managing. This is adhering to the
// SimpleSchema spec.
Status runtime.RawExtension `json:"status,omitempty"`
// Validation is a list of validation rules that are applied to the
// resourcegroup.
// resourcegraphdefinition.
// Not implemented yet.
Validation []string `json:"validation,omitempty"`
}
Expand All @@ -96,11 +96,21 @@ type Resource struct {
IncludeWhen []string `json:"includeWhen,omitempty"`
}

// ResourceGroupStatus defines the observed state of ResourceGroup
type ResourceGroupStatus struct {
// State is the state of the resourcegroup
State ResourceGroupState `json:"state,omitempty"`
// TopologicalOrder is the topological order of the resourcegroup graph
// ResourceGraphDefinitionState defines the state of the resource group.
type ResourceGraphDefinitionState string

const (
// ResourceGraphDefinitionStateActive represents the active state of the resource group.
ResourceGraphDefinitionStateActive ResourceGraphDefinitionState = "Active"
// ResourceGraphDefinitionStateInactive represents the inactive state of the resource group
ResourceGraphDefinitionStateInactive ResourceGraphDefinitionState = "Inactive"
)

// ResourceGraphDefinitionStatus defines the observed state of ResourceGraphDefinition
type ResourceGraphDefinitionStatus struct {
// State is the state of the resourcegraphdefinition
State ResourceGraphDefinitionState `json:"state,omitempty"`
// TopologicalOrder is the topological order of the resourcegraphdefinition graph
TopologicalOrder []string `json:"topologicalOrder,omitempty"`
// Conditions represent the latest available observations of an object's state
Conditions []Condition `json:"conditions,omitempty"`
Expand All @@ -109,7 +119,7 @@ type ResourceGroupStatus struct {
}

// ResourceInformation defines the information about a resource
// in the resourcegroup
// in the resourcegraphdefinition
type ResourceInformation struct {
// ID represents the id of the resources we're providing information for
ID string `json:"id,omitempty"`
Expand All @@ -133,24 +143,24 @@ type Dependency struct {
// +kubebuilder:printcolumn:name="AGE",type="date",priority=0,JSONPath=".metadata.creationTimestamp"
// +kubebuilder:resource:shortName=rg

// ResourceGroup is the Schema for the resourcegroups API
type ResourceGroup struct {
// ResourceGraphDefinition is the Schema for the resourcegraphdefinitions API
type ResourceGraphDefinition struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ResourceGroupSpec `json:"spec,omitempty"`
Status ResourceGroupStatus `json:"status,omitempty"`
Spec ResourceGraphDefinitionSpec `json:"spec,omitempty"`
Status ResourceGraphDefinitionStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ResourceGroupList contains a list of ResourceGroup
type ResourceGroupList struct {
// ResourceGraphDefinitionList contains a list of ResourceGraphDefinition
type ResourceGraphDefinitionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourceGroup `json:"items"`
Items []ResourceGraphDefinition `json:"items"`
}

func init() {
SchemeBuilder.Register(&ResourceGroup{}, &ResourceGroupList{})
SchemeBuilder.Register(&ResourceGraphDefinition{}, &ResourceGraphDefinitionList{})
}
38 changes: 19 additions & 19 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cb89862

Please sign in to comment.