diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml index b5ad3f2c..b6009880 100644 --- a/.github/ISSUE_TEMPLATE/bug.yaml +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -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: @@ -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) diff --git a/Makefile b/Makefile index 0752bde0..6a0798f4 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/README.md b/README.md index f3e2e849..5d06d712 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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 | @@ -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. @@ -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)?** diff --git a/api/v1alpha1/conditions.go b/api/v1alpha1/conditions.go index f0a0edfe..99da5600 100644 --- a/api/v1alpha1/conditions.go +++ b/api/v1alpha1/conditions.go @@ -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 ( diff --git a/api/v1alpha1/resourcegroup_state.go b/api/v1alpha1/resourcegroup_state.go deleted file mode 100644 index f8df8613..00000000 --- a/api/v1alpha1/resourcegroup_state.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may -// not use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either -// express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -package v1alpha1 - -// ResourceGroupState defines the state of the resource group. -type ResourceGroupState string - -const ( - // ResourceGroupStateActive represents the active state of the resource group. - ResourceGroupStateActive ResourceGroupState = "Active" - // ResourceGroupStateInactive represents the inactive state of the resource group - ResourceGroupStateInactive ResourceGroupState = "Inactive" -) diff --git a/api/v1alpha1/resource_group.go b/api/v1alpha1/types.go similarity index 66% rename from api/v1alpha1/resource_group.go rename to api/v1alpha1/types.go index 8a45d418..72e31905 100644 --- a/api/v1alpha1/resource_group.go +++ b/api/v1alpha1/types.go @@ -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"` @@ -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"` } @@ -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"` @@ -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"` @@ -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{}) } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 22cf5958..89ae2523 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -92,7 +92,7 @@ func (in *Resource) DeepCopy() *Resource { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceGroup) DeepCopyInto(out *ResourceGroup) { +func (in *ResourceGraphDefinition) DeepCopyInto(out *ResourceGraphDefinition) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) @@ -100,18 +100,18 @@ func (in *ResourceGroup) DeepCopyInto(out *ResourceGroup) { in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGroup. -func (in *ResourceGroup) DeepCopy() *ResourceGroup { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGraphDefinition. +func (in *ResourceGraphDefinition) DeepCopy() *ResourceGraphDefinition { if in == nil { return nil } - out := new(ResourceGroup) + out := new(ResourceGraphDefinition) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ResourceGroup) DeepCopyObject() runtime.Object { +func (in *ResourceGraphDefinition) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -119,31 +119,31 @@ func (in *ResourceGroup) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceGroupList) DeepCopyInto(out *ResourceGroupList) { +func (in *ResourceGraphDefinitionList) DeepCopyInto(out *ResourceGraphDefinitionList) { *out = *in out.TypeMeta = in.TypeMeta in.ListMeta.DeepCopyInto(&out.ListMeta) if in.Items != nil { in, out := &in.Items, &out.Items - *out = make([]ResourceGroup, len(*in)) + *out = make([]ResourceGraphDefinition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGroupList. -func (in *ResourceGroupList) DeepCopy() *ResourceGroupList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGraphDefinitionList. +func (in *ResourceGraphDefinitionList) DeepCopy() *ResourceGraphDefinitionList { if in == nil { return nil } - out := new(ResourceGroupList) + out := new(ResourceGraphDefinitionList) in.DeepCopyInto(out) return out } // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ResourceGroupList) DeepCopyObject() runtime.Object { +func (in *ResourceGraphDefinitionList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } @@ -151,7 +151,7 @@ func (in *ResourceGroupList) DeepCopyObject() runtime.Object { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceGroupSpec) DeepCopyInto(out *ResourceGroupSpec) { +func (in *ResourceGraphDefinitionSpec) DeepCopyInto(out *ResourceGraphDefinitionSpec) { *out = *in if in.Schema != nil { in, out := &in.Schema, &out.Schema @@ -178,18 +178,18 @@ func (in *ResourceGroupSpec) DeepCopyInto(out *ResourceGroupSpec) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGroupSpec. -func (in *ResourceGroupSpec) DeepCopy() *ResourceGroupSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGraphDefinitionSpec. +func (in *ResourceGraphDefinitionSpec) DeepCopy() *ResourceGraphDefinitionSpec { if in == nil { return nil } - out := new(ResourceGroupSpec) + out := new(ResourceGraphDefinitionSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceGroupStatus) DeepCopyInto(out *ResourceGroupStatus) { +func (in *ResourceGraphDefinitionStatus) DeepCopyInto(out *ResourceGraphDefinitionStatus) { *out = *in if in.TopologicalOrder != nil { in, out := &in.TopologicalOrder, &out.TopologicalOrder @@ -212,12 +212,12 @@ func (in *ResourceGroupStatus) DeepCopyInto(out *ResourceGroupStatus) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGroupStatus. -func (in *ResourceGroupStatus) DeepCopy() *ResourceGroupStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceGraphDefinitionStatus. +func (in *ResourceGraphDefinitionStatus) DeepCopy() *ResourceGraphDefinitionStatus { if in == nil { return nil } - out := new(ResourceGroupStatus) + out := new(ResourceGraphDefinitionStatus) in.DeepCopyInto(out) return out } diff --git a/cmd/controller/main.go b/cmd/controller/main.go index 8b581f02..122db996 100644 --- a/cmd/controller/main.go +++ b/cmd/controller/main.go @@ -33,7 +33,7 @@ import ( xv1alpha1 "github.com/kro-run/kro/api/v1alpha1" kroclient "github.com/kro-run/kro/pkg/client" - resourcegroupctrl "github.com/kro-run/kro/pkg/controller/resourcegroup" + resourcegraphdefinitionctrl "github.com/kro-run/kro/pkg/controller/resourcegraphdefinition" "github.com/kro-run/kro/pkg/dynamiccontroller" "github.com/kro-run/kro/pkg/graph" //+kubebuilder:scaffold:imports @@ -159,7 +159,7 @@ func main() { os.Exit(1) } - reconciler := resourcegroupctrl.NewResourceGroupReconciler( + reconciler := resourcegraphdefinitionctrl.NewResourceGraphDefinitionReconciler( rootLogger, mgr.GetClient(), set, @@ -170,16 +170,16 @@ func main() { err = ctrl.NewControllerManagedBy( mgr, ).For( - &xv1alpha1.ResourceGroup{}, + &xv1alpha1.ResourceGraphDefinition{}, ).WithEventFilter( predicate.GenerationChangedPredicate{}, ).WithOptions( ctrlrtcontroller.Options{ MaxConcurrentReconciles: resourceGroupConcurrentReconciles, }, - ).Complete(reconcile.AsReconciler[*xv1alpha1.ResourceGroup](mgr.GetClient(), reconciler)) + ).Complete(reconcile.AsReconciler[*xv1alpha1.ResourceGraphDefinition](mgr.GetClient(), reconciler)) if err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ResourceGroup") + setupLog.Error(err, "unable to create controller", "controller", "ResourceGraphDefinition") os.Exit(1) } diff --git a/config/crd/bases/kro.run_resourcegroups.yaml b/config/crd/bases/kro.run_resourcegroups.yaml index f7ccacc9..c2616f4f 100644 --- a/config/crd/bases/kro.run_resourcegroups.yaml +++ b/config/crd/bases/kro.run_resourcegroups.yaml @@ -4,16 +4,16 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.16.2 - name: resourcegroups.kro.run + name: resourcegraphdefinitions.kro.run spec: group: kro.run names: - kind: ResourceGroup - listKind: ResourceGroupList - plural: resourcegroups + kind: ResourceGraphDefinition + listKind: ResourceGraphDefinitionList + plural: resourcegraphdefinitions shortNames: - rg - singular: resourcegroup + singular: resourcegraphdefinition scope: Namespaced versions: - additionalPrinterColumns: @@ -36,7 +36,7 @@ spec: name: v1alpha1 schema: openAPIV3Schema: - description: ResourceGroup is the Schema for the resourcegroups API + description: ResourceGraphDefinition is the Schema for the resourcegraphdefinitions API properties: apiVersion: description: |- @@ -56,7 +56,7 @@ spec: metadata: type: object spec: - description: ResourceGroupSpec defines the desired state of ResourceGroup + description: ResourceGraphDefinitionSpec defines the desired state of ResourceGraphDefinition properties: defaultServiceAccounts: additionalProperties: @@ -68,7 +68,7 @@ spec: namespace not explicitly mapped. type: object resources: - description: The resources that are part of the resourcegroup. + description: The resources that are part of the resourcegraphdefinition. items: properties: id: @@ -91,14 +91,14 @@ spec: type: array schema: description: |- - The schema of the resourcegroup, which includes the + The schema of the resourcegraphdefinition, which includes the apiVersion, kind, spec, status, types, and some validation rules. properties: apiVersion: description: |- - 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. type: string x-kubernetes-validations: - message: apiVersion is immutable @@ -106,35 +106,35 @@ spec: group: default: kro.run description: |- - 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". type: string kind: description: |- - 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. type: string x-kubernetes-validations: - message: kind is immutable rule: self == oldSelf spec: description: |- - 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 type: object x-kubernetes-preserve-unknown-fields: true status: description: |- - 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. type: object x-kubernetes-preserve-unknown-fields: true validation: description: |- Validation is a list of validation rules that are applied to the - resourcegroup. + resourcegraphdefinition. Not implemented yet. items: type: string @@ -147,7 +147,7 @@ spec: - schema type: object status: - description: ResourceGroupStatus defines the observed state of ResourceGroup + description: ResourceGraphDefinitionStatus defines the observed state of ResourceGraphDefinition properties: conditions: description: Conditions represent the latest available observations @@ -195,7 +195,7 @@ spec: items: description: |- ResourceInformation defines the information about a resource - in the resourcegroup + in the resourcegraphdefinition properties: dependencies: description: Dependencies represents the resource dependencies @@ -217,10 +217,10 @@ spec: type: object type: array state: - description: State is the state of the resourcegroup + description: State is the state of the resourcegraphdefinition type: string topologicalOrder: - description: TopologicalOrder is the topological order of the resourcegroup + description: TopologicalOrder is the topological order of the resourcegraphdefinition graph items: type: string diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 9f709df1..b95b8c87 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -2,18 +2,18 @@ # since it depends on service name and namespace that are out of this kustomize package. # It should be run by config/default resources: -- bases/kro.run_resourcegroups.yaml +- bases/kro.run_resourcegraphdefinitions.yaml #+kubebuilder:scaffold:crdkustomizeresource patches: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -#- path: patches/webhook_in_resourcegroups.yaml +#- path: patches/webhook_in_resourcegraphdefinitions.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- path: patches/cainjection_in_resourcegroups.yaml +#- path: patches/cainjection_in_resourcegraphdefinitions.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/config/rbac/abstraction_editor_role.yaml b/config/rbac/abstraction_editor_role.yaml index de7df538..1c021054 100644 --- a/config/rbac/abstraction_editor_role.yaml +++ b/config/rbac/abstraction_editor_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to edit resourcegroups. +# permissions for end users to edit resourcegraphdefinitions. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: resourcegroup-editor-role + app.kubernetes.io/instance: resourcegraphdefinition-editor-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: kro app.kubernetes.io/part-of: kro app.kubernetes.io/managed-by: kustomize - name: resourcegroup-editor-role + name: resourcegraphdefinition-editor-role rules: - apiGroups: - kro.run resources: - - resourcegroups + - resourcegraphdefinitions verbs: - create - delete @@ -26,6 +26,6 @@ rules: - apiGroups: - kro.run resources: - - resourcegroups/status + - resourcegraphdefinitions/status verbs: - get diff --git a/config/rbac/abstraction_viewer_role.yaml b/config/rbac/abstraction_viewer_role.yaml index af12d31f..04c43332 100644 --- a/config/rbac/abstraction_viewer_role.yaml +++ b/config/rbac/abstraction_viewer_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to view resourcegroups. +# permissions for end users to view resourcegraphdefinitions. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: resourcegroup-viewer-role + app.kubernetes.io/instance: resourcegraphdefinition-viewer-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: kro app.kubernetes.io/part-of: kro app.kubernetes.io/managed-by: kustomize - name: resourcegroup-viewer-role + name: resourcegraphdefinition-viewer-role rules: - apiGroups: - kro.run resources: - - resourcegroups + - resourcegraphdefinitions verbs: - get - list @@ -22,6 +22,6 @@ rules: - apiGroups: - kro.run resources: - - resourcegroups/status + - resourcegraphdefinitions/status verbs: - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 03c6f17b..938dae89 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -7,7 +7,7 @@ rules: - apiGroups: - kro.run resources: - - resourcegroups + - resourcegraphdefinitions verbs: - create - delete @@ -19,13 +19,13 @@ rules: - apiGroups: - kro.run resources: - - resourcegroups/finalizers + - resourcegraphdefinitions/finalizers verbs: - update - apiGroups: - kro.run resources: - - resourcegroups/status + - resourcegraphdefinitions/status verbs: - get - patch diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index e5419385..768db30c 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,4 +1,4 @@ ## Append samples of your project ## resources: -- x_v1alpha1_resourcegroup.yaml +- x_v1alpha1_resourcegraphdefinition.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/config/samples/x_v1alpha1_abstraction.yaml b/config/samples/x_v1alpha1_abstraction.yaml index 93aaf2f6..4b0c58d0 100644 --- a/config/samples/x_v1alpha1_abstraction.yaml +++ b/config/samples/x_v1alpha1_abstraction.yaml @@ -1,12 +1,12 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: labels: - app.kubernetes.io/name: resourcegroup - app.kubernetes.io/instance: resourcegroup-sample + app.kubernetes.io/name: resourcegraphdefinition + app.kubernetes.io/instance: resourcegraphdefinition-sample app.kubernetes.io/part-of: kro app.kubernetes.io/managed-by: kustomize app.kubernetes.io/created-by: kro - name: resourcegroup-sample + name: resourcegraphdefinition-sample spec: # TODO(user): Add fields here diff --git a/examples/ack-controller/README.md b/examples/ack-controller/README.md index a844abbc..d07aac47 100644 --- a/examples/ack-controller/README.md +++ b/examples/ack-controller/README.md @@ -64,7 +64,7 @@ The controllers are using the IAM controller to create the necessary roles for t 5. Install the combined Resource Group controllers: ``` - kubectl apply -f resourcegroup.yaml + kubectl apply -f resourcegraphdefinition.yaml ``` 6. Install the combined instance: diff --git a/examples/ack-controller/controllers/ec2-controller.yaml b/examples/ack-controller/controllers/ec2-controller.yaml index afc458a9..26250a55 100644 --- a/examples/ack-controller/controllers/ec2-controller.yaml +++ b/examples/ack-controller/controllers/ec2-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ec2controller.kro.run namespace: kro diff --git a/examples/ack-controller/controllers/ecr-controller.yaml b/examples/ack-controller/controllers/ecr-controller.yaml index a432993b..357ab54d 100644 --- a/examples/ack-controller/controllers/ecr-controller.yaml +++ b/examples/ack-controller/controllers/ecr-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ecrcontrollers.kro.run namespace: kro diff --git a/examples/ack-controller/controllers/ecr-public-controller.yaml b/examples/ack-controller/controllers/ecr-public-controller.yaml index c7b4218c..9e712e38 100644 --- a/examples/ack-controller/controllers/ecr-public-controller.yaml +++ b/examples/ack-controller/controllers/ecr-public-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ecrpubliccontrollers.kro.run namespace: kro diff --git a/examples/ack-controller/controllers/eks-controller.yaml b/examples/ack-controller/controllers/eks-controller.yaml index e9edcf78..4cd1df9f 100644 --- a/examples/ack-controller/controllers/eks-controller.yaml +++ b/examples/ack-controller/controllers/eks-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscontrollers.kro.run namespace: kro diff --git a/examples/ack-controller/controllers/iam-controller.yaml b/examples/ack-controller/controllers/iam-controller.yaml index e34241e7..d39713fd 100644 --- a/examples/ack-controller/controllers/iam-controller.yaml +++ b/examples/ack-controller/controllers/iam-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: iamcontroller.kro.run namespace: kro diff --git a/examples/ack-controller/controllers/s3-controller.yaml b/examples/ack-controller/controllers/s3-controller.yaml index fbe654ef..32a6a139 100644 --- a/examples/ack-controller/controllers/s3-controller.yaml +++ b/examples/ack-controller/controllers/s3-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: s3controller.kro.run namespace: kro diff --git a/examples/ack-controller/controllers/sqs-controller.yaml b/examples/ack-controller/controllers/sqs-controller.yaml index 963bed5c..2eceeac0 100644 --- a/examples/ack-controller/controllers/sqs-controller.yaml +++ b/examples/ack-controller/controllers/sqs-controller.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: sqscontrollers.kro.run namespace: kro diff --git a/examples/ack-controller/crds/ec2-crd-group.yaml b/examples/ack-controller/crds/ec2-crd-group.yaml index 136efa5d..172511a4 100644 --- a/examples/ack-controller/crds/ec2-crd-group.yaml +++ b/examples/ack-controller/crds/ec2-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ec2crdgroup.kro.run namespace: kro @@ -755,7 +755,7 @@ spec: properties: capacityReservationID: type: string - capacityReservationResourceGroupARN: + capacityReservationResourceGraphDefinitionARN: type: string type: object type: object @@ -1148,7 +1148,7 @@ spec: type: string hostID: type: string - hostResourceGroupARN: + hostResourceGraphDefinitionARN: type: string partitionNumber: format: int64 diff --git a/examples/ack-controller/crds/ecr-crd-group.yaml b/examples/ack-controller/crds/ecr-crd-group.yaml index 4b842646..3c7f2c01 100644 --- a/examples/ack-controller/crds/ecr-crd-group.yaml +++ b/examples/ack-controller/crds/ecr-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ecrcrds.kro.run namespace: kro diff --git a/examples/ack-controller/crds/ecr-public-crd-group.yaml b/examples/ack-controller/crds/ecr-public-crd-group.yaml index f2ebe8f3..993287b5 100644 --- a/examples/ack-controller/crds/ecr-public-crd-group.yaml +++ b/examples/ack-controller/crds/ecr-public-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ecrpubliccrds.kro.run namespace: kro diff --git a/examples/ack-controller/crds/eks-crd-group.yaml b/examples/ack-controller/crds/eks-crd-group.yaml index 4ed324e0..c3a7a8b9 100644 --- a/examples/ack-controller/crds/eks-crd-group.yaml +++ b/examples/ack-controller/crds/eks-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscrds.kro.run namespace: kro diff --git a/examples/ack-controller/crds/iam-crd-group.yaml b/examples/ack-controller/crds/iam-crd-group.yaml index 507a385a..e202e19b 100644 --- a/examples/ack-controller/crds/iam-crd-group.yaml +++ b/examples/ack-controller/crds/iam-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: iamcrdgroup.kro.run namespace: kro diff --git a/examples/ack-controller/crds/s3-crd-group.yaml b/examples/ack-controller/crds/s3-crd-group.yaml index e766dde8..1aa60ef0 100644 --- a/examples/ack-controller/crds/s3-crd-group.yaml +++ b/examples/ack-controller/crds/s3-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: s3crds.kro.run namespace: kro diff --git a/examples/ack-controller/crds/sqs-crd-group.yaml b/examples/ack-controller/crds/sqs-crd-group.yaml index 1d7c7e5e..3f3f9fb2 100644 --- a/examples/ack-controller/crds/sqs-crd-group.yaml +++ b/examples/ack-controller/crds/sqs-crd-group.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: sqsrds.kro.run namespace: kro diff --git a/examples/ack-controller/resourcegroup.yaml b/examples/ack-controller/resourcegroup.yaml index ba6488b3..feb4b507 100644 --- a/examples/ack-controller/resourcegroup.yaml +++ b/examples/ack-controller/resourcegroup.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ack-controllers.kro.run namespace: kro @@ -22,7 +22,7 @@ spec: iamRole: maxSessionDuration: integer | default=3600 oidcProvider: string | required=true - roleDescription: string | default=IRSA role for ACK controllers deployment on EKS cluster using Kro ResourceGroup + roleDescription: string | default=IRSA role for ACK controllers deployment on EKS cluster using Kro ResourceGraphDefinition repository: string | default=public.ecr.aws/aws-controllers-k8s/iam-controller tag: string | default=1.3.13 serviceAccount: diff --git a/examples/ack-eks-cluster/eks-cluster.yaml b/examples/ack-eks-cluster/eks-cluster.yaml index 8cbdd2cf..cf4a2469 100644 --- a/examples/ack-eks-cluster/eks-cluster.yaml +++ b/examples/ack-eks-cluster/eks-cluster.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscluster.kro.run spec: diff --git a/examples/ack-eks-cluster/eks-reused.yaml b/examples/ack-eks-cluster/eks-reused.yaml index 0bec689b..ea3df787 100644 --- a/examples/ack-eks-cluster/eks-reused.yaml +++ b/examples/ack-eks-cluster/eks-reused.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscluster.kro.run spec: diff --git a/examples/cachecluster/cachecluster.yaml b/examples/cachecluster/cachecluster.yaml index 50de49e6..35b86072 100644 --- a/examples/cachecluster/cachecluster.yaml +++ b/examples/cachecluster/cachecluster.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: valkey.kro.run spec: diff --git a/examples/cachecluster/simple-cachecluster.yaml b/examples/cachecluster/simple-cachecluster.yaml index ac3bca96..dba001ba 100644 --- a/examples/cachecluster/simple-cachecluster.yaml +++ b/examples/cachecluster/simple-cachecluster.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: valkey.kro.run spec: diff --git a/examples/cel-functions/rg.yaml b/examples/cel-functions/rg.yaml index b9c3d763..7a188ad0 100644 --- a/examples/cel-functions/rg.yaml +++ b/examples/cel-functions/rg.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: somethings.kro.run spec: diff --git a/examples/core-dns/core-dns.yaml b/examples/core-dns/core-dns.yaml index a42486b6..7db2c377 100644 --- a/examples/core-dns/core-dns.yaml +++ b/examples/core-dns/core-dns.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: coredns.kro.run spec: diff --git a/examples/data-processor/README.md b/examples/data-processor/README.md index 48b6ffa2..ac58e489 100644 --- a/examples/data-processor/README.md +++ b/examples/data-processor/README.md @@ -28,7 +28,7 @@ Install kro in the cluster created in the previous step following [instructions] ## Create instance -Create kro ResourceGroup for the data processor: +Create kro ResourceGraphDefinition for the data processor: ```shell kubectl apply -f eda-eks-data-processor.yaml ``` diff --git a/examples/data-processor/eda-eks-data-processor.yaml b/examples/data-processor/eda-eks-data-processor.yaml index f54992a3..f7cd6bdc 100644 --- a/examples/data-processor/eda-eks-data-processor.yaml +++ b/examples/data-processor/eda-eks-data-processor.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: eda-eks-data-processor.kro.run spec: diff --git a/examples/defaults/rg.yaml b/examples/defaults/rg.yaml index 0d1bd544..7c1fd1ec 100644 --- a/examples/defaults/rg.yaml +++ b/examples/defaults/rg.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: somethings.kro.run spec: diff --git a/examples/eks-cluster-mgmt/clusters/rg/eks-w-vpc.yaml b/examples/eks-cluster-mgmt/clusters/rg/eks-w-vpc.yaml index e5d3270f..69f83e6e 100644 --- a/examples/eks-cluster-mgmt/clusters/rg/eks-w-vpc.yaml +++ b/examples/eks-cluster-mgmt/clusters/rg/eks-w-vpc.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: eksclusterwithvpc.kro.run annotations: diff --git a/examples/eks-cluster-mgmt/clusters/rg/eks.yaml b/examples/eks-cluster-mgmt/clusters/rg/eks.yaml index 4bbd9f93..ea71d49b 100644 --- a/examples/eks-cluster-mgmt/clusters/rg/eks.yaml +++ b/examples/eks-cluster-mgmt/clusters/rg/eks.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscluster.kro.run annotations: diff --git a/examples/eks-cluster-mgmt/clusters/rg/vpc.yaml b/examples/eks-cluster-mgmt/clusters/rg/vpc.yaml index a9652bd1..de287495 100644 --- a/examples/eks-cluster-mgmt/clusters/rg/vpc.yaml +++ b/examples/eks-cluster-mgmt/clusters/rg/vpc.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: vpc.kro.run annotations: diff --git a/examples/networkstack/network-stack.yaml b/examples/networkstack/network-stack.yaml index 4a2a25e2..2d7a666a 100644 --- a/examples/networkstack/network-stack.yaml +++ b/examples/networkstack/network-stack.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: networkingstack.kro.run spec: diff --git a/examples/podidenity/rg.yaml b/examples/podidenity/rg.yaml index 27d34dcb..350502e7 100644 --- a/examples/podidenity/rg.yaml +++ b/examples/podidenity/rg.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: podidentity.kro.run spec: diff --git a/examples/s3bucket/rg.yaml b/examples/s3bucket/rg.yaml index c719f6de..9b10d8fb 100644 --- a/examples/s3bucket/rg.yaml +++ b/examples/s3bucket/rg.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: s3bucket.kro.run spec: diff --git a/examples/serverless-microservice/README.md b/examples/serverless-microservice/README.md index 49e52aa9..07180d07 100644 --- a/examples/serverless-microservice/README.md +++ b/examples/serverless-microservice/README.md @@ -70,7 +70,7 @@ implement anything more complicated than simple CRUD operations. Check out `./src/install.sh` script for the commands used to install necessary ACK controllers . -### Deploy ResourceGroup +### Deploy ResourceGraphDefinition Make sure you are in the following directory: @@ -82,10 +82,10 @@ cd examples/serverless-microservice/ kubectl apply -f microservice.yaml ``` -Verify the ResourceGroups +Verify the ResourceGraphDefinitions ```shell -kubectl get ResourceGroup +kubectl get ResourceGraphDefinition ``` Expected output @@ -184,7 +184,7 @@ test-microservice 12m Get a list of the resource groups ``` -kubectl get ResourceGroup +kubectl get ResourceGraphDefinition ``` Expected result @@ -197,7 +197,7 @@ microservice.kro.run 35m Describe your resource group, look for errors and events: ``` -kubectl describe resourcegroup.kro.run/microservice.kro.run +kubectl describe resourcegraphdefinition.kro.run/microservice.kro.run ``` Expected result (resource definitions removed for brevity) @@ -208,7 +208,7 @@ Namespace: default Labels: Annotations: API Version: kro.run/v1alpha1 -Kind: ResourceGroup +Kind: ResourceGraphDefinition Metadata: Creation Timestamp: 2024-07-11T15:34:53Z Finalizers: @@ -337,7 +337,7 @@ kubectl delete -f claim.yaml Delete the S3 bucket you've created and the Lambda ZIP packages in it -Delete the ResourceGroups +Delete the ResourceGraphDefinitions ```shell kubectl delete -f microservice.yaml diff --git a/examples/serverless-microservice/microservice.yaml b/examples/serverless-microservice/microservice.yaml index 3b660478..acb8b748 100644 --- a/examples/serverless-microservice/microservice.yaml +++ b/examples/serverless-microservice/microservice.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: microservice.kro.run spec: diff --git a/examples/webapp/Readme.md b/examples/webapp/Readme.md index 00dd33d8..1382dd21 100644 --- a/examples/webapp/Readme.md +++ b/examples/webapp/Readme.md @@ -1,9 +1,9 @@ # kro WebApp example -This example creates a ResourceGroup called `WebApp` and then instaciates it with +This example creates a ResourceGraphDefinition called `WebApp` and then instaciates it with the default nginx container image. -### Create ResourceGroup called WebApp +### Create ResourceGraphDefinition called WebApp Apply the RG to your cluster: @@ -14,7 +14,7 @@ kubectl apply -f rg.yaml Validate the RG status is Active: ``` -kubectl get rg webapp.kro.run +kubectl get rgd webapp.kro.run ``` Expected result: @@ -82,8 +82,8 @@ Remove the instance: kubectl delete webapps test-app ``` -Remove the resourcegroup: +Remove the resourcegraphdefinition: ``` -kubectl delete rg webapp.kro.run +kubectl delete rgd webapp.kro.run ``` diff --git a/examples/webapp/rg.yaml b/examples/webapp/rg.yaml index b082a164..dbe28d1d 100644 --- a/examples/webapp/rg.yaml +++ b/examples/webapp/rg.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: webapp.kro.run spec: diff --git a/examples/webstack/Readme.md b/examples/webstack/Readme.md index 80e4bdbc..4697aaaa 100644 --- a/examples/webstack/Readme.md +++ b/examples/webstack/Readme.md @@ -1,12 +1,12 @@ # kro Nested RG example -This example creates a ResourceGroup called `WebStack` comprised of +This example creates a ResourceGraphDefinition called `WebStack` comprised of three other RGs: `WebApp`, `S3Bucket`, and `PodIdentity` ![Netsted RG Instance](../../images/architecture-diagrams/kro-WebStack.png) _Fugure 1: Nested RG Example_ -### Create ResourceGroups +### Create ResourceGraphDefinitions Change directory to `examples`: ``` @@ -110,8 +110,8 @@ Remove the instance: kubectl delete webstacks test-app ``` -Remove the ResourceGroups: +Remove the ResourceGraphDefinitions: ``` -kubectl delete rg webstack.kro.run webapp.kro.run s3bucket.kro.run podidentity.kro.run +kubectl delete rgd webstack.kro.run webapp.kro.run s3bucket.kro.run podidentity.kro.run ``` diff --git a/examples/webstack/rg.yaml b/examples/webstack/rg.yaml index 96101d8b..dad9f008 100644 --- a/examples/webstack/rg.yaml +++ b/examples/webstack/rg.yaml @@ -1,5 +1,5 @@ apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: webstack.kro.run spec: diff --git a/helm/crds/kro.run_resourcegroups.yaml b/helm/crds/kro.run_resourcegroups.yaml index f7ccacc9..c2616f4f 100644 --- a/helm/crds/kro.run_resourcegroups.yaml +++ b/helm/crds/kro.run_resourcegroups.yaml @@ -4,16 +4,16 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.16.2 - name: resourcegroups.kro.run + name: resourcegraphdefinitions.kro.run spec: group: kro.run names: - kind: ResourceGroup - listKind: ResourceGroupList - plural: resourcegroups + kind: ResourceGraphDefinition + listKind: ResourceGraphDefinitionList + plural: resourcegraphdefinitions shortNames: - rg - singular: resourcegroup + singular: resourcegraphdefinition scope: Namespaced versions: - additionalPrinterColumns: @@ -36,7 +36,7 @@ spec: name: v1alpha1 schema: openAPIV3Schema: - description: ResourceGroup is the Schema for the resourcegroups API + description: ResourceGraphDefinition is the Schema for the resourcegraphdefinitions API properties: apiVersion: description: |- @@ -56,7 +56,7 @@ spec: metadata: type: object spec: - description: ResourceGroupSpec defines the desired state of ResourceGroup + description: ResourceGraphDefinitionSpec defines the desired state of ResourceGraphDefinition properties: defaultServiceAccounts: additionalProperties: @@ -68,7 +68,7 @@ spec: namespace not explicitly mapped. type: object resources: - description: The resources that are part of the resourcegroup. + description: The resources that are part of the resourcegraphdefinition. items: properties: id: @@ -91,14 +91,14 @@ spec: type: array schema: description: |- - The schema of the resourcegroup, which includes the + The schema of the resourcegraphdefinition, which includes the apiVersion, kind, spec, status, types, and some validation rules. properties: apiVersion: description: |- - 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. type: string x-kubernetes-validations: - message: apiVersion is immutable @@ -106,35 +106,35 @@ spec: group: default: kro.run description: |- - 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". type: string kind: description: |- - 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. type: string x-kubernetes-validations: - message: kind is immutable rule: self == oldSelf spec: description: |- - 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 type: object x-kubernetes-preserve-unknown-fields: true status: description: |- - 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. type: object x-kubernetes-preserve-unknown-fields: true validation: description: |- Validation is a list of validation rules that are applied to the - resourcegroup. + resourcegraphdefinition. Not implemented yet. items: type: string @@ -147,7 +147,7 @@ spec: - schema type: object status: - description: ResourceGroupStatus defines the observed state of ResourceGroup + description: ResourceGraphDefinitionStatus defines the observed state of ResourceGraphDefinition properties: conditions: description: Conditions represent the latest available observations @@ -195,7 +195,7 @@ spec: items: description: |- ResourceInformation defines the information about a resource - in the resourcegroup + in the resourcegraphdefinition properties: dependencies: description: Dependencies represents the resource dependencies @@ -217,10 +217,10 @@ spec: type: object type: array state: - description: State is the state of the resourcegroup + description: State is the state of the resourcegraphdefinition type: string topologicalOrder: - description: TopologicalOrder is the topological order of the resourcegroup + description: TopologicalOrder is the topological order of the resourcegraphdefinition graph items: type: string diff --git a/pkg/controller/instance/controller.go b/pkg/controller/instance/controller.go index 2568f354..f3fea358 100644 --- a/pkg/controller/instance/controller.go +++ b/pkg/controller/instance/controller.go @@ -49,7 +49,7 @@ type ReconcileConfig struct { DeletionPolicy string } -// Controller manages the reconciliation of a single instance of a ResourceGroup, +// Controller manages the reconciliation of a single instance of a ResourceGraphDefinition, // / it is responsible for reconciling the instance and its sub-resources. // // The controller is responsible for the following: @@ -60,12 +60,12 @@ type ReconcileConfig struct { // - Handling errors and retries // - Performing cleanup operations (garbage collection) // -// For each instance of a ResourceGroup, the controller creates a new instance of +// For each instance of a ResourceGraphDefinition, the controller creates a new instance of // the InstanceGraphReconciler to manage the reconciliation of the instance and its // sub-resources. // // It is important to state that when the controller is reconciling an instance, it -// creates and uses a new instance of the ResourceGroupRuntime to uniquely manage +// creates and uses a new instance of the ResourceGraphDefinitionRuntime to uniquely manage // the state of the instance and its sub-resources. This ensure that at each // reconciliation loop, the controller is working with a fresh state of the instance // and its sub-resources. @@ -76,10 +76,10 @@ type Controller struct { gvr schema.GroupVersionResource // client holds the dynamic client to use for interacting with the Kubernetes API. clientSet *kroclient.Set - // rg is a read-only reference to the ResourceGroup that the controller is + // rgd is a read-only reference to the Graph that the controller is // managing instances for. - // TODO: use a read-only interface for the ResourceGroup - rg *graph.Graph + // TODO: use a read-only interface for the ResourceGraphDefinition + rgd *graph.Graph // instanceLabeler is responsible for applying consistent labels // to resources managed by this controller. instanceLabeler metadata.Labeler @@ -95,7 +95,7 @@ func NewController( log logr.Logger, reconcileConfig ReconcileConfig, gvr schema.GroupVersionResource, - rg *graph.Graph, + rgd *graph.Graph, clientSet *kroclient.Set, defaultServiceAccounts map[string]string, instanceLabeler metadata.Labeler, @@ -104,7 +104,7 @@ func NewController( log: log, gvr: gvr, clientSet: clientSet, - rg: rg, + rgd: rgd, instanceLabeler: instanceLabeler, reconcileConfig: reconcileConfig, defaultServiceAccounts: defaultServiceAccounts, @@ -132,7 +132,7 @@ func (c *Controller) Reconcile(ctx context.Context, req ctrl.Request) error { // instance of the resource group. The instance graph reconciler is responsible // for reconciling the instance and its sub-resources, while keeping the same // runtime object in it's fields. - rgRuntime, err := c.rg.NewGraphRuntime(instance) + rgRuntime, err := c.rgd.NewGraphRuntime(instance) if err != nil { return fmt.Errorf("failed to create runtime resource group: %w", err) } diff --git a/pkg/controller/instance/controller_reconcile.go b/pkg/controller/instance/controller_reconcile.go index 8e60f9d9..f471281f 100644 --- a/pkg/controller/instance/controller_reconcile.go +++ b/pkg/controller/instance/controller_reconcile.go @@ -33,7 +33,7 @@ import ( // instanceGraphReconciler is responsible for reconciling a single instance and // and its associated sub-resources. It executes the reconciliation logic based -// on the graph inferred from the ResourceGroup analysis. +// on the graph inferred from the ResourceGraphDefinition analysis. type instanceGraphReconciler struct { log logr.Logger // gvr represents the Group, Version, and Resource of the custom resource @@ -41,7 +41,7 @@ type instanceGraphReconciler struct { gvr schema.GroupVersionResource // client is a dynamic client for interacting with the Kubernetes API server client dynamic.Interface - // runtime is the runtime representation of the ResourceGroup. It holds the + // runtime is the runtime representation of the ResourceGraphDefinition. It holds the // information about the instance and its sub-resources, the CEL expressions // their dependencies, and the resolved values... etc runtime runtime.Interface diff --git a/pkg/controller/resourcegroup/controller.go b/pkg/controller/resourcegraphdefinition/controller.go similarity index 57% rename from pkg/controller/resourcegroup/controller.go rename to pkg/controller/resourcegraphdefinition/controller.go index ba7a120d..be13b04c 100644 --- a/pkg/controller/resourcegroup/controller.go +++ b/pkg/controller/resourcegraphdefinition/controller.go @@ -11,7 +11,7 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -package resourcegroup +package resourcegraphdefinition import ( "context" @@ -31,12 +31,12 @@ import ( "github.com/kro-run/kro/pkg/metadata" ) -//+kubebuilder:rbac:groups=kro.run,resources=resourcegroups,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kro.run,resources=resourcegroups/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=kro.run,resources=resourcegroups/finalizers,verbs=update +//+kubebuilder:rbac:groups=kro.run,resources=resourcegraphdefinitions,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kro.run,resources=resourcegraphdefinitions/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=kro.run,resources=resourcegraphdefinitions/finalizers,verbs=update -// ResourceGroupReconciler reconciles a ResourceGroup object -type ResourceGroupReconciler struct { +// ResourceGraphDefinitionReconciler reconciles a ResourceGraphDefinition object +type ResourceGraphDefinitionReconciler struct { log logr.Logger rootLogger logr.Logger @@ -51,20 +51,20 @@ type ResourceGroupReconciler struct { dynamicController *dynamiccontroller.DynamicController } -func NewResourceGroupReconciler( +func NewResourceGraphDefinitionReconciler( log logr.Logger, mgrClient client.Client, clientSet *kroclient.Set, allowCRDDeletion bool, dynamicController *dynamiccontroller.DynamicController, builder *graph.Builder, -) *ResourceGroupReconciler { +) *ResourceGraphDefinitionReconciler { crdWrapper := clientSet.CRD(kroclient.CRDWrapperConfig{ Log: log, }) rgLogger := log.WithName("controller.resourceGroup") - return &ResourceGroupReconciler{ + return &ResourceGraphDefinitionReconciler{ rootLogger: log, log: rgLogger, clientSet: clientSet, @@ -78,25 +78,25 @@ func NewResourceGroupReconciler( } // SetupWithManager sets up the controller with the Manager. -func (r *ResourceGroupReconciler) SetupWithManager(mgr ctrl.Manager) error { +func (r *ResourceGraphDefinitionReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.ResourceGroup{}). + For(&v1alpha1.ResourceGraphDefinition{}). WithEventFilter(predicate.GenerationChangedPredicate{}). - Complete(reconcile.AsReconciler[*v1alpha1.ResourceGroup](mgr.GetClient(), r)) + Complete(reconcile.AsReconciler[*v1alpha1.ResourceGraphDefinition](mgr.GetClient(), r)) } -func (r *ResourceGroupReconciler) Reconcile(ctx context.Context, resourcegroup *v1alpha1.ResourceGroup) (ctrl.Result, error) { - rlog := r.log.WithValues("resourcegroup", types.NamespacedName{Namespace: resourcegroup.Namespace, Name: resourcegroup.Name}) +func (r *ResourceGraphDefinitionReconciler) Reconcile(ctx context.Context, resourcegraphdefinition *v1alpha1.ResourceGraphDefinition) (ctrl.Result, error) { + rlog := r.log.WithValues("resourcegraphdefinition", types.NamespacedName{Namespace: resourcegraphdefinition.Namespace, Name: resourcegraphdefinition.Name}) ctx = log.IntoContext(ctx, rlog) - if !resourcegroup.DeletionTimestamp.IsZero() { - rlog.V(1).Info("ResourceGroup is being deleted") - if err := r.cleanupResourceGroup(ctx, resourcegroup); err != nil { + if !resourcegraphdefinition.DeletionTimestamp.IsZero() { + rlog.V(1).Info("ResourceGraphDefinition is being deleted") + if err := r.cleanupResourceGraphDefinition(ctx, resourcegraphdefinition); err != nil { return ctrl.Result{}, err } - rlog.V(1).Info("Setting resourcegroup as unmanaged") - if err := r.setUnmanaged(ctx, resourcegroup); err != nil { + rlog.V(1).Info("Setting resourcegraphdefinition as unmanaged") + if err := r.setUnmanaged(ctx, resourcegraphdefinition); err != nil { return ctrl.Result{}, err } @@ -104,15 +104,15 @@ func (r *ResourceGroupReconciler) Reconcile(ctx context.Context, resourcegroup * } rlog.V(1).Info("Setting resource group as managed") - if err := r.setManaged(ctx, resourcegroup); err != nil { + if err := r.setManaged(ctx, resourcegraphdefinition); err != nil { return ctrl.Result{}, err } - rlog.V(1).Info("Syncing resourcegroup") - topologicalOrder, resourcesInformation, reconcileErr := r.reconcileResourceGroup(ctx, resourcegroup) + rlog.V(1).Info("Syncing resourcegraphdefinition") + topologicalOrder, resourcesInformation, reconcileErr := r.reconcileResourceGraphDefinition(ctx, resourcegraphdefinition) - rlog.V(1).Info("Setting resourcegroup status") - if err := r.setResourceGroupStatus(ctx, resourcegroup, topologicalOrder, resourcesInformation, reconcileErr); err != nil { + rlog.V(1).Info("Setting resourcegraphdefinition status") + if err := r.setResourceGraphDefinitionStatus(ctx, resourcegraphdefinition, topologicalOrder, resourcesInformation, reconcileErr); err != nil { return ctrl.Result{}, err } diff --git a/pkg/controller/resourcegroup/controller_cleanup.go b/pkg/controller/resourcegraphdefinition/controller_cleanup.go similarity index 63% rename from pkg/controller/resourcegroup/controller_cleanup.go rename to pkg/controller/resourcegraphdefinition/controller_cleanup.go index dbd4a427..f08d1cdb 100644 --- a/pkg/controller/resourcegroup/controller_cleanup.go +++ b/pkg/controller/resourcegraphdefinition/controller_cleanup.go @@ -11,7 +11,7 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -package resourcegroup +package resourcegraphdefinition import ( "context" @@ -26,45 +26,45 @@ import ( "github.com/kro-run/kro/pkg/metadata" ) -// cleanupResourceGroup handles the deletion of a ResourceGroup by shutting down its associated +// cleanupResourceGraphDefinition handles the deletion of a ResourceGraphDefinition by shutting down its associated // microcontroller and cleaning up the CRD if enabled. It executes cleanup operations in order: // 1. Shuts down the microcontroller // 2. Deletes the associated CRD (if CRD deletion is enabled) -func (r *ResourceGroupReconciler) cleanupResourceGroup(ctx context.Context, rg *v1alpha1.ResourceGroup) error { +func (r *ResourceGraphDefinitionReconciler) cleanupResourceGraphDefinition(ctx context.Context, rgd *v1alpha1.ResourceGraphDefinition) error { log, _ := logr.FromContext(ctx) - log.V(1).Info("cleaning up resource group", "name", rg.Name) + log.V(1).Info("cleaning up resource group", "name", rgd.Name) // shutdown microcontroller - gvr := metadata.GetResourceGroupInstanceGVR(rg.Spec.Schema.Group, rg.Spec.Schema.APIVersion, rg.Spec.Schema.Kind) - if err := r.shutdownResourceGroupMicroController(ctx, &gvr); err != nil { + gvr := metadata.GetResourceGraphDefinitionInstanceGVR(rgd.Spec.Schema.Group, rgd.Spec.Schema.APIVersion, rgd.Spec.Schema.Kind) + if err := r.shutdownResourceGraphDefinitionMicroController(ctx, &gvr); err != nil { return fmt.Errorf("failed to shutdown microcontroller: %w", err) } - group := rg.Spec.Schema.Group + group := rgd.Spec.Schema.Group if group == "" { group = v1alpha1.KroDomainName } // cleanup CRD - crdName := extractCRDName(group, rg.Spec.Schema.Kind) - if err := r.cleanupResourceGroupCRD(ctx, crdName); err != nil { + crdName := extractCRDName(group, rgd.Spec.Schema.Kind) + if err := r.cleanupResourceGraphDefinitionCRD(ctx, crdName); err != nil { return fmt.Errorf("failed to cleanup CRD %s: %w", crdName, err) } return nil } -// shutdownResourceGroupMicroController stops the dynamic controller associated with the given GVR. +// shutdownResourceGraphDefinitionMicroController stops the dynamic controller associated with the given GVR. // This ensures no new reconciliations occur for this resource type. -func (r *ResourceGroupReconciler) shutdownResourceGroupMicroController(ctx context.Context, gvr *schema.GroupVersionResource) error { +func (r *ResourceGraphDefinitionReconciler) shutdownResourceGraphDefinitionMicroController(ctx context.Context, gvr *schema.GroupVersionResource) error { if err := r.dynamicController.StopServiceGVK(ctx, *gvr); err != nil { return fmt.Errorf("error stopping service: %w", err) } return nil } -// cleanupResourceGroupCRD deletes the CRD with the given name if CRD deletion is enabled. +// cleanupResourceGraphDefinitionCRD deletes the CRD with the given name if CRD deletion is enabled. // If CRD deletion is disabled, it logs the skip and returns nil. -func (r *ResourceGroupReconciler) cleanupResourceGroupCRD(ctx context.Context, crdName string) error { +func (r *ResourceGraphDefinitionReconciler) cleanupResourceGraphDefinitionCRD(ctx context.Context, crdName string) error { if !r.allowCRDDeletion { log, _ := logr.FromContext(ctx) log.Info("skipping CRD deletion (disabled)", "crd", crdName) diff --git a/pkg/controller/resourcegroup/controller_reconcile.go b/pkg/controller/resourcegraphdefinition/controller_reconcile.go similarity index 69% rename from pkg/controller/resourcegroup/controller_reconcile.go rename to pkg/controller/resourcegraphdefinition/controller_reconcile.go index 5fbde156..4588f272 100644 --- a/pkg/controller/resourcegroup/controller_reconcile.go +++ b/pkg/controller/resourcegraphdefinition/controller_reconcile.go @@ -11,7 +11,7 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -package resourcegroup +package resourcegraphdefinition import ( "context" @@ -29,38 +29,38 @@ import ( "github.com/kro-run/kro/pkg/metadata" ) -// reconcileResourceGroup orchestrates the reconciliation of a ResourceGroup by: +// reconcileResourceGraphDefinition orchestrates the reconciliation of a ResourceGraphDefinition by: // 1. Processing the resource graph // 2. Ensuring CRDs are present // 3. Setting up and starting the microcontroller -func (r *ResourceGroupReconciler) reconcileResourceGroup(ctx context.Context, rg *v1alpha1.ResourceGroup) ([]string, []v1alpha1.ResourceInformation, error) { +func (r *ResourceGraphDefinitionReconciler) reconcileResourceGraphDefinition(ctx context.Context, rgd *v1alpha1.ResourceGraphDefinition) ([]string, []v1alpha1.ResourceInformation, error) { log, _ := logr.FromContext(ctx) // Process resource group graph first to validate structure log.V(1).Info("reconciling resource group graph") - processedRG, resourcesInfo, err := r.reconcileResourceGroupGraph(ctx, rg) + processedRG, resourcesInfo, err := r.reconcileResourceGraphDefinitionGraph(ctx, rgd) if err != nil { return nil, nil, err } // Ensure CRD exists and is up to date log.V(1).Info("reconciling resource group CRD") - if err := r.reconcileResourceGroupCRD(ctx, processedRG.Instance.GetCRD()); err != nil { + if err := r.reconcileResourceGraphDefinitionCRD(ctx, processedRG.Instance.GetCRD()); err != nil { return processedRG.TopologicalOrder, resourcesInfo, err } // Setup metadata labeling - graphExecLabeler, err := r.setupLabeler(rg) + graphExecLabeler, err := r.setupLabeler(rgd) if err != nil { return nil, nil, fmt.Errorf("failed to setup labeler: %w", err) } // Setup and start microcontroller gvr := processedRG.Instance.GetGroupVersionResource() - controller := r.setupMicroController(gvr, processedRG, rg.Spec.DefaultServiceAccounts, graphExecLabeler) + controller := r.setupMicroController(gvr, processedRG, rgd.Spec.DefaultServiceAccounts, graphExecLabeler) log.V(1).Info("reconciling resource group micro controller") - if err := r.reconcileResourceGroupMicroController(ctx, &gvr, controller.Reconcile); err != nil { + if err := r.reconcileResourceGraphDefinitionMicroController(ctx, &gvr, controller.Reconcile); err != nil { return processedRG.TopologicalOrder, resourcesInfo, err } @@ -68,13 +68,13 @@ func (r *ResourceGroupReconciler) reconcileResourceGroup(ctx context.Context, rg } // setupLabeler creates and merges the required labelers for the resource group -func (r *ResourceGroupReconciler) setupLabeler(rg *v1alpha1.ResourceGroup) (metadata.Labeler, error) { - rgLabeler := metadata.NewResourceGroupLabeler(rg) +func (r *ResourceGraphDefinitionReconciler) setupLabeler(rgd *v1alpha1.ResourceGraphDefinition) (metadata.Labeler, error) { + rgLabeler := metadata.NewResourceGraphDefinitionLabeler(rgd) return r.metadataLabeler.Merge(rgLabeler) } // setupMicroController creates a new controller instance with the required configuration -func (r *ResourceGroupReconciler) setupMicroController( +func (r *ResourceGraphDefinitionReconciler) setupMicroController( gvr schema.GroupVersionResource, processedRG *graph.Graph, defaultSVCs map[string]string, @@ -98,10 +98,10 @@ func (r *ResourceGroupReconciler) setupMicroController( ) } -// reconcileResourceGroupGraph processes the resource group to build a dependency graph +// reconcileResourceGraphDefinitionGraph processes the resource group to build a dependency graph // and extract resource information -func (r *ResourceGroupReconciler) reconcileResourceGroupGraph(_ context.Context, rg *v1alpha1.ResourceGroup) (*graph.Graph, []v1alpha1.ResourceInformation, error) { - processedRG, err := r.rgBuilder.NewResourceGroup(rg) +func (r *ResourceGraphDefinitionReconciler) reconcileResourceGraphDefinitionGraph(_ context.Context, rgd *v1alpha1.ResourceGraphDefinition) (*graph.Graph, []v1alpha1.ResourceInformation, error) { + processedRG, err := r.rgBuilder.NewResourceGraphDefinition(rgd) if err != nil { return nil, nil, newGraphError(err) } @@ -129,16 +129,16 @@ func buildResourceInfo(name string, deps []string) v1alpha1.ResourceInformation } } -// reconcileResourceGroupCRD ensures the CRD is present and up to date in the cluster -func (r *ResourceGroupReconciler) reconcileResourceGroupCRD(ctx context.Context, crd *v1.CustomResourceDefinition) error { +// reconcileResourceGraphDefinitionCRD ensures the CRD is present and up to date in the cluster +func (r *ResourceGraphDefinitionReconciler) reconcileResourceGraphDefinitionCRD(ctx context.Context, crd *v1.CustomResourceDefinition) error { if err := r.crdManager.Ensure(ctx, *crd); err != nil { return newCRDError(err) } return nil } -// reconcileResourceGroupMicroController starts the microcontroller for handling the resources -func (r *ResourceGroupReconciler) reconcileResourceGroupMicroController(ctx context.Context, gvr *schema.GroupVersionResource, handler dynamiccontroller.Handler) error { +// reconcileResourceGraphDefinitionMicroController starts the microcontroller for handling the resources +func (r *ResourceGraphDefinitionReconciler) reconcileResourceGraphDefinitionMicroController(ctx context.Context, gvr *schema.GroupVersionResource, handler dynamiccontroller.Handler) error { err := r.dynamicController.StartServingGVK(ctx, *gvr, handler) if err != nil { return newMicroControllerError(err) @@ -146,7 +146,7 @@ func (r *ResourceGroupReconciler) reconcileResourceGroupMicroController(ctx cont return nil } -// Error types for the resourcegroup controller +// Error types for the resourcegraphdefinition controller type ( graphError struct{ err error } crdError struct{ err error } diff --git a/pkg/controller/resourcegroup/controller_status.go b/pkg/controller/resourcegraphdefinition/controller_status.go similarity index 69% rename from pkg/controller/resourcegroup/controller_status.go rename to pkg/controller/resourcegraphdefinition/controller_status.go index fd6ae650..f9b95523 100644 --- a/pkg/controller/resourcegroup/controller_status.go +++ b/pkg/controller/resourcegraphdefinition/controller_status.go @@ -11,7 +11,7 @@ // express or implied. See the License for the specific language governing // permissions and limitations under the License. -package resourcegroup +package resourcegraphdefinition import ( "context" @@ -27,17 +27,17 @@ import ( "github.com/kro-run/kro/pkg/metadata" ) -// StatusProcessor handles the processing of ResourceGroup status updates +// StatusProcessor handles the processing of ResourceGraphDefinition status updates type StatusProcessor struct { conditions []v1alpha1.Condition - state v1alpha1.ResourceGroupState + state v1alpha1.ResourceGraphDefinitionState } // NewStatusProcessor creates a new StatusProcessor with default active state func NewStatusProcessor() *StatusProcessor { return &StatusProcessor{ conditions: []v1alpha1.Condition{}, - state: v1alpha1.ResourceGroupStateActive, + state: v1alpha1.ResourceGraphDefinitionStateActive, } } @@ -57,7 +57,7 @@ func (sp *StatusProcessor) processGraphError(err error) { newReconcilerReadyCondition(metav1.ConditionUnknown, "Faulty Graph"), newCustomResourceDefinitionSyncedCondition(metav1.ConditionUnknown, "Faulty Graph"), } - sp.state = v1alpha1.ResourceGroupStateInactive + sp.state = v1alpha1.ResourceGraphDefinitionStateInactive } // processCRDError handles CRD-related errors @@ -67,7 +67,7 @@ func (sp *StatusProcessor) processCRDError(err error) { newCustomResourceDefinitionSyncedCondition(metav1.ConditionFalse, err.Error()), newReconcilerReadyCondition(metav1.ConditionUnknown, "CRD not-synced"), } - sp.state = v1alpha1.ResourceGroupStateInactive + sp.state = v1alpha1.ResourceGraphDefinitionStateInactive } // processMicroControllerError handles microcontroller-related errors @@ -77,14 +77,14 @@ func (sp *StatusProcessor) processMicroControllerError(err error) { newCustomResourceDefinitionSyncedCondition(metav1.ConditionTrue, ""), newReconcilerReadyCondition(metav1.ConditionFalse, err.Error()), } - sp.state = v1alpha1.ResourceGroupStateInactive + sp.state = v1alpha1.ResourceGraphDefinitionStateInactive } -// setResourceGroupStatus calculates the ResourceGroup status and updates it +// setResourceGraphDefinitionStatus calculates the ResourceGraphDefinition status and updates it // in the API server. -func (r *ResourceGroupReconciler) setResourceGroupStatus( +func (r *ResourceGraphDefinitionReconciler) setResourceGraphDefinitionStatus( ctx context.Context, - resourcegroup *v1alpha1.ResourceGroup, + resourcegraphdefinition *v1alpha1.ResourceGraphDefinition, topologicalOrder []string, resources []v1alpha1.ResourceInformation, reconcileErr error, @@ -118,8 +118,8 @@ func (r *ResourceGroupReconciler) setResourceGroupStatus( return retry.RetryOnConflict(retry.DefaultRetry, func() error { // Get fresh copy to avoid conflicts - current := &v1alpha1.ResourceGroup{} - if err := r.Get(ctx, client.ObjectKeyFromObject(resourcegroup), current); err != nil { + current := &v1alpha1.ResourceGraphDefinition{} + if err := r.Get(ctx, client.ObjectKeyFromObject(resourcegraphdefinition), current); err != nil { return fmt.Errorf("failed to get current resource group: %w", err) } @@ -139,46 +139,46 @@ func (r *ResourceGroupReconciler) setResourceGroupStatus( }) } -// setManaged sets the resourcegroup as managed, by adding the +// setManaged sets the resourcegraphdefinition as managed, by adding the // default finalizer if it doesn't exist. -func (r *ResourceGroupReconciler) setManaged(ctx context.Context, rg *v1alpha1.ResourceGroup) error { +func (r *ResourceGraphDefinitionReconciler) setManaged(ctx context.Context, rgd *v1alpha1.ResourceGraphDefinition) error { log, _ := logr.FromContext(ctx) - log.V(1).Info("setting resourcegroup as managed") + log.V(1).Info("setting resourcegraphdefinition as managed") // Skip if finalizer already exists - if metadata.HasResourceGroupFinalizer(rg) { + if metadata.HasResourceGraphDefinitionFinalizer(rgd) { return nil } - dc := rg.DeepCopy() - metadata.SetResourceGroupFinalizer(dc) - return r.Patch(ctx, dc, client.MergeFrom(rg)) + dc := rgd.DeepCopy() + metadata.SetResourceGraphDefinitionFinalizer(dc) + return r.Patch(ctx, dc, client.MergeFrom(rgd)) } -// setUnmanaged sets the resourcegroup as unmanaged, by removing the +// setUnmanaged sets the resourcegraphdefinition as unmanaged, by removing the // default finalizer if it exists. -func (r *ResourceGroupReconciler) setUnmanaged(ctx context.Context, rg *v1alpha1.ResourceGroup) error { +func (r *ResourceGraphDefinitionReconciler) setUnmanaged(ctx context.Context, rgd *v1alpha1.ResourceGraphDefinition) error { log, _ := logr.FromContext(ctx) - log.V(1).Info("setting resourcegroup as unmanaged") + log.V(1).Info("setting resourcegraphdefinition as unmanaged") // Skip if finalizer already removed - if !metadata.HasResourceGroupFinalizer(rg) { + if !metadata.HasResourceGraphDefinitionFinalizer(rgd) { return nil } - dc := rg.DeepCopy() - metadata.RemoveResourceGroupFinalizer(dc) - return r.Patch(ctx, dc, client.MergeFrom(rg)) + dc := rgd.DeepCopy() + metadata.RemoveResourceGraphDefinitionFinalizer(dc) + return r.Patch(ctx, dc, client.MergeFrom(rgd)) } func newReconcilerReadyCondition(status metav1.ConditionStatus, reason string) v1alpha1.Condition { - return v1alpha1.NewCondition(v1alpha1.ResourceGroupConditionTypeReconcilerReady, status, reason, "micro controller is ready") + return v1alpha1.NewCondition(v1alpha1.ResourceGraphDefinitionConditionTypeReconcilerReady, status, reason, "micro controller is ready") } func newGraphVerifiedCondition(status metav1.ConditionStatus, reason string) v1alpha1.Condition { - return v1alpha1.NewCondition(v1alpha1.ResourceGroupConditionTypeGraphVerified, status, reason, "Directed Acyclic Graph is synced") + return v1alpha1.NewCondition(v1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified, status, reason, "Directed Acyclic Graph is synced") } func newCustomResourceDefinitionSyncedCondition(status metav1.ConditionStatus, reason string) v1alpha1.Condition { - return v1alpha1.NewCondition(v1alpha1.ResourceGroupConditionTypeCustomResourceDefinitionSynced, status, reason, "Custom Resource Definition is synced") + return v1alpha1.NewCondition(v1alpha1.ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced, status, reason, "Custom Resource Definition is synced") } diff --git a/pkg/dynamiccontroller/dynamic_controller.go b/pkg/dynamiccontroller/dynamic_controller.go index 238d1aca..e1a53e83 100644 --- a/pkg/dynamiccontroller/dynamic_controller.go +++ b/pkg/dynamiccontroller/dynamic_controller.go @@ -108,7 +108,7 @@ type Config struct { // flexible and lightweight operation. DC serves as the core component of kro's // dynamic resource management system. Its primary purpose is to create and manage // "micro" controllers for custom resources defined by users at runtime (via the -// ResourceGroup CRs). +// ResourceGraphDefinition CRs). type DynamicController struct { config Config @@ -288,14 +288,14 @@ func (dc *DynamicController) processNextWorkItem(ctx context.Context) bool { // syncFunc reconciles a single item. func (dc *DynamicController) syncFunc(ctx context.Context, oi ObjectIdentifiers) error { gvrKey := fmt.Sprintf("%s/%s/%s", oi.GVR.Group, oi.GVR.Version, oi.GVR.Resource) - dc.log.V(1).Info("Syncing resourcegroup instance request", "gvr", gvrKey, "namespacedKey", oi.NamespacedKey) + dc.log.V(1).Info("Syncing resourcegraphdefinition instance request", "gvr", gvrKey, "namespacedKey", oi.NamespacedKey) startTime := time.Now() defer func() { duration := time.Since(startTime) reconcileDuration.WithLabelValues(gvrKey).Observe(duration.Seconds()) reconcileTotal.WithLabelValues(gvrKey).Inc() - dc.log.V(1).Info("Finished syncing resourcegroup instance request", + dc.log.V(1).Info("Finished syncing resourcegraphdefinition instance request", "gvr", gvrKey, "namespacedKey", oi.NamespacedKey, "duration", duration) diff --git a/pkg/graph/builder.go b/pkg/graph/builder.go index 80ad7c30..d2bada9d 100644 --- a/pkg/graph/builder.go +++ b/pkg/graph/builder.go @@ -78,7 +78,7 @@ func NewBuilder( // // If any of the above steps fail, the Builder will return an error. // -// The resulting ResourceGroup object is a fulyl processed and validated +// The resulting ResourceGraphDefinition object is a fulyl processed and validated // representation of a resource group CR, it's underlying resources, and the // relationships between the resources. This object can be used to instantiate // a "runtime" data structure that can be used to create the resources in the @@ -96,11 +96,11 @@ type Builder struct { discoveryClient discovery.DiscoveryInterface } -// NewResourceGroup creates a new ResourceGroup object from the given ResourceGroup -// CRD. The ResourceGroup object is a fully processed and validated representation +// NewResourceGraphDefinition creates a new ResourceGraphDefinition object from the given ResourceGraphDefinition +// CRD. The ResourceGraphDefinition object is a fully processed and validated representation // of the resource group CRD, it's underlying resources, and the relationships between // the resources. -func (b *Builder) NewResourceGroup(originalCR *v1alpha1.ResourceGroup) (*Graph, error) { +func (b *Builder) NewResourceGraphDefinition(originalCR *v1alpha1.ResourceGraphDefinition) (*Graph, error) { // Before anything else, let's copy the resource group to avoid modifying the // original object. rg := originalCR.DeepCopy() @@ -112,9 +112,9 @@ func (b *Builder) NewResourceGroup(originalCR *v1alpha1.ResourceGroup) (*Graph, // that the names of the resources are valid to be used in CEL expressions. // for example name-something-something is not a valid name for a resource, // because in CEL - is a subtraction operator. - err := validateResourceGroupNamingConventions(rg) + err := validateResourceGraphDefinitionNamingConventions(rg) if err != nil { - return nil, fmt.Errorf("failed to validate resourcegroup: %w", err) + return nil, fmt.Errorf("failed to validate resourcegraphdefinition: %w", err) } // Now that we did a basic validation of the resource group, we can start understanding @@ -199,7 +199,7 @@ func (b *Builder) NewResourceGroup(originalCR *v1alpha1.ResourceGroup) (*Graph, resources, ) if err != nil { - return nil, fmt.Errorf("failed to build resourcegroup '%v': %w", rg.Name, err) + return nil, fmt.Errorf("failed to build resourcegraphdefinition '%v': %w", rg.Name, err) } // Before getting into the dependency graph, we need to validate the CEL expressions @@ -429,7 +429,7 @@ func (b *Builder) buildInstanceResource( // CRD declarations. // The instance resource is a Kubernetes resource, so it has a GroupVersionKind. - gvk := metadata.GetResourceGroupInstanceGVK(group, apiVersion, kind) + gvk := metadata.GetResourceGraphDefinitionInstanceGVK(group, apiVersion, kind) // We need to unmarshal the instance schema to a map[string]interface{} to // make it easier to work with. diff --git a/pkg/graph/builder_test.go b/pkg/graph/builder_test.go index 5827bd50..49ce557b 100644 --- a/pkg/graph/builder_test.go +++ b/pkg/graph/builder_test.go @@ -36,13 +36,13 @@ func TestGraphBuilder_Validation(t *testing.T) { tests := []struct { name string - resourceGroupOpts []generator.ResourceGroupOption + resourceGroupOpts []generator.ResourceGraphDefinitionOption wantErr bool errMsg string }{ { name: "invalid resource type", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -63,7 +63,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid resource id with operator", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -84,7 +84,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "resource without a valid GVK", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -101,7 +101,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid CEL syntax in readyWhen", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -122,7 +122,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid CEL syntax in includeWhen expression", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -143,7 +143,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "missing required field", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -165,7 +165,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid field reference", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -189,7 +189,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "valid VPC with valid conditional subnets", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -236,7 +236,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid resource type", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -257,7 +257,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid instance spec field type", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -271,7 +271,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid instance status field reference", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -294,7 +294,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "invalid field type in resource spec", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -318,7 +318,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "crds aren't allowed to have variables in their spec fields", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -350,7 +350,7 @@ func TestGraphBuilder_Validation(t *testing.T) { }, { name: "valid instance definition with complex types", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -381,8 +381,8 @@ func TestGraphBuilder_Validation(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rg := generator.NewResourceGroup("test-group", tt.resourceGroupOpts...) - _, err := builder.NewResourceGroup(rg) + rg := generator.NewResourceGraphDefinition("test-group", tt.resourceGroupOpts...) + _, err := builder.NewResourceGraphDefinition(rg) if tt.wantErr { assert.Error(t, err) @@ -404,14 +404,14 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { tests := []struct { name string - resourceGroupOpts []generator.ResourceGroupOption + resourceGroupOpts []generator.ResourceGraphDefinitionOption wantErr bool errMsg string validateDeps func(*testing.T, *Graph) }{ { name: "complex eks setup dependencies", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -514,7 +514,7 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { }, { name: "missing dependency", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -539,7 +539,7 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { }, { name: "cyclic dependency", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -575,7 +575,7 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { }, { name: "independent pods", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -656,7 +656,7 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { }, { name: "cyclic pod dependencies", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -730,7 +730,7 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { }, { name: "shared infrastructure dependencies", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -937,8 +937,8 @@ func TestGraphBuilder_DependencyValidation(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rg := generator.NewResourceGroup("testgroup", tt.resourceGroupOpts...) - g, err := builder.NewResourceGroup(rg) + rg := generator.NewResourceGraphDefinition("testgroup", tt.resourceGroupOpts...) + g, err := builder.NewResourceGraphDefinition(rg) if tt.wantErr { assert.Error(t, err) @@ -964,12 +964,12 @@ func TestGraphBuilder_ExpressionParsing(t *testing.T) { tests := []struct { name string - resourceGroupOpts []generator.ResourceGroupOption + resourceGroupOpts []generator.ResourceGraphDefinitionOption validateVars func(*testing.T, *Graph) }{ { name: "complex resource variable parsing", - resourceGroupOpts: []generator.ResourceGroupOption{ + resourceGroupOpts: []generator.ResourceGraphDefinitionOption{ generator.WithSchema( "Test", "v1alpha1", map[string]interface{}{ @@ -1187,8 +1187,8 @@ func TestGraphBuilder_ExpressionParsing(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rg := generator.NewResourceGroup("testgroup", tt.resourceGroupOpts...) - g, err := builder.NewResourceGroup(rg) + rg := generator.NewResourceGraphDefinition("testgroup", tt.resourceGroupOpts...) + g, err := builder.NewResourceGraphDefinition(rg) require.NoError(t, err) if tt.validateVars != nil { tt.validateVars(t, g) diff --git a/pkg/graph/crd/defaults.go b/pkg/graph/crd/defaults.go index 87bf0a12..2cc5837c 100644 --- a/pkg/graph/crd/defaults.go +++ b/pkg/graph/crd/defaults.go @@ -56,23 +56,23 @@ var ( // NAME STATE SYNCED AGE // testcluster29 ACTIVE True 22d defaultAdditionalPrinterColumns = []extv1.CustomResourceColumnDefinition{ - // ResourceGroup instance state + // ResourceGraphDefinition instance state { Name: "State", - Description: "The state of a ResourceGroup instance", + Description: "The state of a ResourceGraphDefinition instance", Priority: 0, Type: "string", JSONPath: ".status.state", }, - // ResourceGroup instance AllResourcesReady condition + // ResourceGraphDefinition instance AllResourcesReady condition { Name: "Synced", - Description: "Whether a ResourceGroup instance have all it's subresources ready", + Description: "Whether a ResourceGraphDefinition instance have all it's subresources ready", Priority: 0, Type: "string", JSONPath: ".status.conditions[?(@.type==\"InstanceSynced\")].status", }, - // ResourceGroup instance age + // ResourceGraphDefinition instance age { Name: "Age", Description: "Age of the resource", diff --git a/pkg/graph/graph.go b/pkg/graph/graph.go index 8cc9d4a9..5f7fbebd 100644 --- a/pkg/graph/graph.go +++ b/pkg/graph/graph.go @@ -20,7 +20,7 @@ import ( "github.com/kro-run/kro/pkg/runtime" ) -// Graph represents a processed resourcegroup. It contains the DAG representation +// Graph represents a processed resourcegraphdefinition. It contains the DAG representation // and everything needed to "manage" the resources defined in the resource group. type Graph struct { // DAG is the directed acyclic graph representation of the resource group. @@ -34,17 +34,17 @@ type Graph struct { } // NewGraphRuntime creates a new runtime resource group from the resource group instance. -func (rg *Graph) NewGraphRuntime(newInstance *unstructured.Unstructured) (*runtime.ResourceGroupRuntime, error) { +func (rgd *Graph) NewGraphRuntime(newInstance *unstructured.Unstructured) (*runtime.ResourceGraphDefinitionRuntime, error) { // we need to copy the resources to the runtime resources, mainly focusing // on the variables and dependencies. resources := make(map[string]runtime.Resource) - for name, resource := range rg.Resources { + for name, resource := range rgd.Resources { resources[name] = resource.DeepCopy() } - instance := rg.Instance.DeepCopy() + instance := rgd.Instance.DeepCopy() instance.originalObject = newInstance - rt, err := runtime.NewResourceGroupRuntime(instance, resources, rg.TopologicalOrder) + rt, err := runtime.NewResourceGraphDefinitionRuntime(instance, resources, rgd.TopologicalOrder) if err != nil { return nil, err } diff --git a/pkg/graph/schema/field_descriptor.go b/pkg/graph/schema/field_descriptor.go index 6cccd946..827d23d4 100644 --- a/pkg/graph/schema/field_descriptor.go +++ b/pkg/graph/schema/field_descriptor.go @@ -28,7 +28,7 @@ import ( // Isn't yet defined in the schema, but we want to add it to the schema. // // This is mainly used to generate the proper OpenAPI Schema for the status field -// of a CRD (Created via a ResourceGroup). +// of a CRD (Created via a ResourceGraphDefinition). // // For example, given the following status definition in simpleschema standard: // status: diff --git a/pkg/graph/validation.go b/pkg/graph/validation.go index d847ab45..50ae3ce3 100644 --- a/pkg/graph/validation.go +++ b/pkg/graph/validation.go @@ -52,7 +52,7 @@ var ( "namespace", "object", "resource", - "resourcegroup", + "resourcegraphdefinition", "resources", "runtime", "serviceAccountName", @@ -85,20 +85,20 @@ func isKROReservedWord(word string) bool { return false } -// validateResourceGroupNamingConventions validates the naming conventions of +// validateResourceGraphDefinitionNamingConventions validates the naming conventions of // the given resource group. -func validateResourceGroupNamingConventions(rg *v1alpha1.ResourceGroup) error { - if !isValidKindName(rg.Spec.Schema.Kind) { - return fmt.Errorf("%s: kind '%s' is not a valid KRO kind name: must be UpperCamelCase", ErrNamingConvention, rg.Spec.Schema.Kind) +func validateResourceGraphDefinitionNamingConventions(rgd *v1alpha1.ResourceGraphDefinition) error { + if !isValidKindName(rgd.Spec.Schema.Kind) { + return fmt.Errorf("%s: kind '%s' is not a valid KRO kind name: must be UpperCamelCase", ErrNamingConvention, rgd.Spec.Schema.Kind) } - err := validateResourceIDs(rg) + err := validateResourceIDs(rgd) if err != nil { return fmt.Errorf("%s: %w", ErrNamingConvention, err) } return nil } -// validateResource performs basic validation on a given resourcegroup. +// validateResource performs basic validation on a given resourcegraphdefinition. // It checks that there are no duplicate resource ids and that the // resource ids are conformant to the KRO naming convention. // @@ -106,9 +106,9 @@ func validateResourceGroupNamingConventions(rg *v1alpha1.ResourceGroup) error { // - The id should start with a lowercase letter. // - The id should only contain alphanumeric characters. // - does not contain any special characters, underscores, or hyphens. -func validateResourceIDs(rg *v1alpha1.ResourceGroup) error { +func validateResourceIDs(rgd *v1alpha1.ResourceGraphDefinition) error { seen := make(map[string]struct{}) - for _, res := range rg.Spec.Resources { + for _, res := range rgd.Spec.Resources { if isKROReservedWord(res.ID) { return fmt.Errorf("id %s is a reserved keyword in KRO", res.ID) } diff --git a/pkg/graph/validation_test.go b/pkg/graph/validation_test.go index a0f00890..f744592d 100644 --- a/pkg/graph/validation_test.go +++ b/pkg/graph/validation_test.go @@ -22,13 +22,13 @@ import ( func TestValidateRGResourceNames(t *testing.T) { tests := []struct { name string - rg *v1alpha1.ResourceGroup + rg *v1alpha1.ResourceGraphDefinition expectError bool }{ { name: "Valid resource group resource ids", - rg: &v1alpha1.ResourceGroup{ - Spec: v1alpha1.ResourceGroupSpec{ + rg: &v1alpha1.ResourceGraphDefinition{ + Spec: v1alpha1.ResourceGraphDefinitionSpec{ Resources: []*v1alpha1.Resource{ {ID: "validID1"}, {ID: "validID2"}, @@ -39,8 +39,8 @@ func TestValidateRGResourceNames(t *testing.T) { }, { name: "Duplicate resource ids", - rg: &v1alpha1.ResourceGroup{ - Spec: v1alpha1.ResourceGroupSpec{ + rg: &v1alpha1.ResourceGraphDefinition{ + Spec: v1alpha1.ResourceGraphDefinitionSpec{ Resources: []*v1alpha1.Resource{ {ID: "duplicateID"}, {ID: "duplicateID"}, @@ -51,8 +51,8 @@ func TestValidateRGResourceNames(t *testing.T) { }, { name: "Invalid resource ID", - rg: &v1alpha1.ResourceGroup{ - Spec: v1alpha1.ResourceGroupSpec{ + rg: &v1alpha1.ResourceGraphDefinition{ + Spec: v1alpha1.ResourceGraphDefinitionSpec{ Resources: []*v1alpha1.Resource{ {ID: "Invalid_ID"}, }, @@ -62,8 +62,8 @@ func TestValidateRGResourceNames(t *testing.T) { }, { name: "Reserved word as resource id", - rg: &v1alpha1.ResourceGroup{ - Spec: v1alpha1.ResourceGroupSpec{ + rg: &v1alpha1.ResourceGraphDefinition{ + Spec: v1alpha1.ResourceGraphDefinitionSpec{ Resources: []*v1alpha1.Resource{ {ID: "spec"}, }, @@ -88,7 +88,7 @@ func TestIsKROReservedWord(t *testing.T) { word string expected bool }{ - {"resourcegroup", true}, + {"resourcegraphdefinition", true}, {"instance", true}, {"notReserved", false}, {"RESOURCEGROUP", false}, // Case-sensitive check diff --git a/pkg/graph/variable/variable.go b/pkg/graph/variable/variable.go index 1db98182..5d19a707 100644 --- a/pkg/graph/variable/variable.go +++ b/pkg/graph/variable/variable.go @@ -97,7 +97,7 @@ const ( // ResourceVariableKindDynamic represents a dynamic variable. Dynamic variables // are resolved at runtime and their value can change during the execution. Dynamic // cannot start with 'spec' and they must refer to another resource in the - // ResourceGroup. + // ResourceGraphDefinition. // // For example: // spec: diff --git a/pkg/metadata/finalizers.go b/pkg/metadata/finalizers.go index bc224f5b..6a3301c3 100644 --- a/pkg/metadata/finalizers.go +++ b/pkg/metadata/finalizers.go @@ -25,20 +25,20 @@ import ( const kroFinalizer = v1alpha1.KroDomainName + "/finalizer" -// SetResourceGroupFinalizer adds the Kro finalizer to the object if it's not already present. -func SetResourceGroupFinalizer(obj metav1.Object) { - if !HasResourceGroupFinalizer(obj) { +// SetResourceGraphDefinitionFinalizer adds the Kro finalizer to the object if it's not already present. +func SetResourceGraphDefinitionFinalizer(obj metav1.Object) { + if !HasResourceGraphDefinitionFinalizer(obj) { obj.SetFinalizers(append(obj.GetFinalizers(), kroFinalizer)) } } -// RemoveResourceGroupFinalizer removes the Kro finalizer from the object. -func RemoveResourceGroupFinalizer(obj metav1.Object) { +// RemoveResourceGraphDefinitionFinalizer removes the Kro finalizer from the object. +func RemoveResourceGraphDefinitionFinalizer(obj metav1.Object) { obj.SetFinalizers(removeString(obj.GetFinalizers(), kroFinalizer)) } -// HasResourceGroupFinalizer checks if the object has the Kro finalizer. -func HasResourceGroupFinalizer(obj metav1.Object) bool { +// HasResourceGraphDefinitionFinalizer checks if the object has the Kro finalizer. +func HasResourceGraphDefinitionFinalizer(obj metav1.Object) bool { return containsString(obj.GetFinalizers(), kroFinalizer) } diff --git a/pkg/metadata/finalizers_test.go b/pkg/metadata/finalizers_test.go index f17cce58..10f7b851 100644 --- a/pkg/metadata/finalizers_test.go +++ b/pkg/metadata/finalizers_test.go @@ -22,7 +22,7 @@ import ( "k8s.io/apimachinery/pkg/types" ) -func TestResourceGroupFinalizer(t *testing.T) { +func TestResourceGraphDefinitionFinalizer(t *testing.T) { cases := []struct { name string initialObject metav1.Object @@ -33,29 +33,29 @@ func TestResourceGroupFinalizer(t *testing.T) { { name: "Set finaliser on empty object", initialObject: &metav1.ObjectMeta{}, - operation: SetResourceGroupFinalizer, - check: HasResourceGroupFinalizer, + operation: SetResourceGraphDefinitionFinalizer, + check: HasResourceGraphDefinitionFinalizer, expected: true, }, { name: "Add finalizer to object w/ existing finalizers", initialObject: &metav1.ObjectMeta{Finalizers: []string{"some-other-finalizer"}}, - operation: SetResourceGroupFinalizer, - check: HasResourceGroupFinalizer, + operation: SetResourceGraphDefinitionFinalizer, + check: HasResourceGraphDefinitionFinalizer, expected: true, }, { name: "Remove finalizer from object w/ finalizer", initialObject: &metav1.ObjectMeta{Finalizers: []string{kroFinalizer}}, - operation: RemoveResourceGroupFinalizer, - check: HasResourceGroupFinalizer, + operation: RemoveResourceGraphDefinitionFinalizer, + check: HasResourceGraphDefinitionFinalizer, expected: false, }, { name: "Remove finalizer from object without finazlier", initialObject: &metav1.ObjectMeta{Finalizers: []string{"some-other-finalizer"}}, - operation: RemoveResourceGroupFinalizer, - check: HasResourceGroupFinalizer, + operation: RemoveResourceGraphDefinitionFinalizer, + check: HasResourceGraphDefinitionFinalizer, expected: false, }, } diff --git a/pkg/metadata/groupversion.go b/pkg/metadata/groupversion.go index 1ce388f4..e08fe2b9 100644 --- a/pkg/metadata/groupversion.go +++ b/pkg/metadata/groupversion.go @@ -58,7 +58,7 @@ func ExtractGVKFromUnstructured(unstructured map[string]interface{}) (schema.Gro }, nil } -func GetResourceGroupInstanceGVK(group, apiVersion, kind string) schema.GroupVersionKind { +func GetResourceGraphDefinitionInstanceGVK(group, apiVersion, kind string) schema.GroupVersionKind { //pluralKind := flect.Pluralize(strings.ToLower(kind)) return schema.GroupVersionKind{ @@ -68,7 +68,7 @@ func GetResourceGroupInstanceGVK(group, apiVersion, kind string) schema.GroupVer } } -func GetResourceGroupInstanceGVR(group, apiVersion, kind string) schema.GroupVersionResource { +func GetResourceGraphDefinitionInstanceGVR(group, apiVersion, kind string) schema.GroupVersionResource { pluralKind := flect.Pluralize(strings.ToLower(kind)) return schema.GroupVersionResource{ Group: fmt.Sprintf("%s.%s", pluralKind, group), diff --git a/pkg/metadata/labels.go b/pkg/metadata/labels.go index 2e9689a8..a058ee7c 100644 --- a/pkg/metadata/labels.go +++ b/pkg/metadata/labels.go @@ -37,10 +37,10 @@ const ( InstanceLabel = LabelKroPrefix + "instance-name" InstanceNamespaceLabel = LabelKroPrefix + "instance-namespace" - ResourceGroupIDLabel = LabelKroPrefix + "resource-group-id" - ResourceGroupNameLabel = LabelKroPrefix + "resource-group-name" - ResourceGroupNamespaceLabel = LabelKroPrefix + "resource-group-namespace" - ResourceGroupVersionLabel = LabelKroPrefix + "resource-group-version" + ResourceGraphDefinitionIDLabel = LabelKroPrefix + "resource-group-id" + ResourceGraphDefinitionNameLabel = LabelKroPrefix + "resource-group-name" + ResourceGraphDefinitionNamespaceLabel = LabelKroPrefix + "resource-group-namespace" + ResourceGraphDefinitionVersionLabel = LabelKroPrefix + "resource-group-version" ) // IsKroOwned returns true if the resource is owned by Kro. @@ -111,13 +111,13 @@ func (gl GenericLabeler) Copy() map[string]string { return newGenericLabeler } -// NewResourceGroupLabeler returns a new labeler that sets the -// ResourceGroupLabel and ResourceGroupIDLabel labels on a resource. -func NewResourceGroupLabeler(rgMeta metav1.Object) GenericLabeler { +// NewResourceGraphDefinitionLabeler returns a new labeler that sets the +// ResourceGraphDefinitionLabel and ResourceGraphDefinitionIDLabel labels on a resource. +func NewResourceGraphDefinitionLabeler(rgMeta metav1.Object) GenericLabeler { return map[string]string{ - ResourceGroupIDLabel: string(rgMeta.GetUID()), - ResourceGroupNameLabel: rgMeta.GetName(), - ResourceGroupNamespaceLabel: rgMeta.GetNamespace(), + ResourceGraphDefinitionIDLabel: string(rgMeta.GetUID()), + ResourceGraphDefinitionNameLabel: rgMeta.GetName(), + ResourceGraphDefinitionNamespaceLabel: rgMeta.GetNamespace(), } } diff --git a/pkg/metadata/owner_reference.go b/pkg/metadata/owner_reference.go index ef2a601c..c38cc790 100644 --- a/pkg/metadata/owner_reference.go +++ b/pkg/metadata/owner_reference.go @@ -22,12 +22,12 @@ import ( ) var ( - KRORGOwnerReferenceKind = "ResourceGroup" + KRORGOwnerReferenceKind = "ResourceGraphDefinition" KRORGOwnerReferenceAPIVersion = v1alpha1.GroupVersion.String() ) // stamped on the CRD and RGIs -func NewResourceGroupOwnerReference(name string, uid types.UID) metav1.OwnerReference { +func NewResourceGraphDefinitionOwnerReference(name string, uid types.UID) metav1.OwnerReference { return metav1.OwnerReference{ Name: name, Kind: KRORGOwnerReferenceKind, diff --git a/pkg/metadata/selectors.go b/pkg/metadata/selectors.go index 28d0fdf6..b66c9fef 100644 --- a/pkg/metadata/selectors.go +++ b/pkg/metadata/selectors.go @@ -29,31 +29,31 @@ func NewInstanceSelector(instance metav1.Object) metav1.LabelSelector { } } -func NewResourceGroupSelector(resourceGroup metav1.Object) metav1.LabelSelector { +func NewResourceGraphDefinitionSelector(resourceGroup metav1.Object) metav1.LabelSelector { return metav1.LabelSelector{ MatchLabels: map[string]string{ - ResourceGroupIDLabel: string(resourceGroup.GetUID()), - // ResourceGroupNameLabel: resourceGroup.GetName(), - // ResourceGroupNamespaceLabel: resourceGroup.GetNamespace(), + ResourceGraphDefinitionIDLabel: string(resourceGroup.GetUID()), + // ResourceGraphDefinitionNameLabel: resourceGroup.GetName(), + // ResourceGraphDefinitionNamespaceLabel: resourceGroup.GetNamespace(), }, } } -func NewInstanceAndResourceGroupSelector(instance metav1.Object, resourceGroup metav1.Object) metav1.LabelSelector { +func NewInstanceAndResourceGraphDefinitionSelector(instance metav1.Object, resourceGroup metav1.Object) metav1.LabelSelector { return metav1.LabelSelector{ MatchLabels: map[string]string{ - InstanceIDLabel: string(instance.GetUID()), - ResourceGroupIDLabel: string(resourceGroup.GetUID()), + InstanceIDLabel: string(instance.GetUID()), + ResourceGraphDefinitionIDLabel: string(resourceGroup.GetUID()), }, } } -func NewNodeAndInstanceAndResourceGroupSelector(node metav1.Object, instance metav1.Object, resourceGroup metav1.Object) metav1.LabelSelector { +func NewNodeAndInstanceAndResourceGraphDefinitionSelector(node metav1.Object, instance metav1.Object, resourceGroup metav1.Object) metav1.LabelSelector { return metav1.LabelSelector{ MatchLabels: map[string]string{ - NodeIDLabel: node.GetName(), - InstanceIDLabel: string(instance.GetUID()), - ResourceGroupIDLabel: string(resourceGroup.GetUID()), + NodeIDLabel: node.GetName(), + InstanceIDLabel: string(instance.GetUID()), + ResourceGraphDefinitionIDLabel: string(resourceGroup.GetUID()), }, } } diff --git a/pkg/runtime/interfaces.go b/pkg/runtime/interfaces.go index 48e98d5c..7a2bc7a5 100644 --- a/pkg/runtime/interfaces.go +++ b/pkg/runtime/interfaces.go @@ -72,7 +72,7 @@ type Interface interface { // ResourceDescriptor provides metadata about a resource. // -// Note: the reason why we do not import resourcegroup/graph.Resource here is +// Note: the reason why we do not import resourcegraphdefinition/graph.Resource here is // to avoid a circular dependency between the runtime and the graph packages. // Had to scratch my head for a while to figure this out. But here is the // quick overview: diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 52ef13af..7ea8ec93 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -27,11 +27,11 @@ import ( "github.com/kro-run/kro/pkg/runtime/resolver" ) -// Compile time proof to ensure that ResourceGroupRuntime implements the +// Compile time proof to ensure that ResourceGraphDefinitionRuntime implements the // Runtime interface. -var _ Interface = &ResourceGroupRuntime{} +var _ Interface = &ResourceGraphDefinitionRuntime{} -// NewResourceGroupRuntime creates and initializes a new ResourceGroupRuntime +// NewResourceGraphDefinitionRuntime creates and initializes a new ResourceGraphDefinitionRuntime // instance. // // It is also responsible of properly creating the ExpressionEvaluationState @@ -41,12 +41,12 @@ var _ Interface = &ResourceGroupRuntime{} // caller (instance controller in this case). // // The output of this function is NOT thread safe. -func NewResourceGroupRuntime( +func NewResourceGraphDefinitionRuntime( instance Resource, resources map[string]Resource, topologicalOrder []string, -) (*ResourceGroupRuntime, error) { - r := &ResourceGroupRuntime{ +) (*ResourceGraphDefinitionRuntime, error) { + r := &ResourceGraphDefinitionRuntime{ instance: instance, resources: resources, topologicalOrder: topologicalOrder, @@ -121,11 +121,11 @@ func NewResourceGroupRuntime( return r, nil } -// ResourceGroupRuntime implements the Interface for managing and synchronizing +// ResourceGraphDefinitionRuntime implements the Interface for managing and synchronizing // resources. Is is the responsibility of the consumer to call Synchronize // appropriately, and decide whether to follow the TopologicalOrder or a // BFS/DFS traversal of the resources. -type ResourceGroupRuntime struct { +type ResourceGraphDefinitionRuntime struct { // instance represents the main resource instance being managed. // This is typically the top-level custom resource that owns or manages // other resources in the graph. @@ -169,7 +169,7 @@ type ResourceGroupRuntime struct { } // TopologicalOrder returns the topological order of resources. -func (rt *ResourceGroupRuntime) TopologicalOrder() []string { +func (rt *ResourceGraphDefinitionRuntime) TopologicalOrder() []string { return rt.topologicalOrder } @@ -178,7 +178,7 @@ func (rt *ResourceGroupRuntime) TopologicalOrder() []string { // It is the responsibility of the caller to ensure that the resource id // exists in the runtime. a.k.a the caller should use the TopologicalOrder // to get the resource ids. -func (rt *ResourceGroupRuntime) ResourceDescriptor(id string) ResourceDescriptor { +func (rt *ResourceGraphDefinitionRuntime) ResourceDescriptor(id string) ResourceDescriptor { return rt.resources[id] } @@ -186,7 +186,7 @@ func (rt *ResourceGroupRuntime) ResourceDescriptor(id string) ResourceDescriptor // the cluster, it also returns the runtime state of the resource. Indicating // whether the resource variables are resolved or not, and whether the resource // readiness conditions are met or not. -func (rt *ResourceGroupRuntime) GetResource(id string) (*unstructured.Unstructured, ResourceState) { +func (rt *ResourceGraphDefinitionRuntime) GetResource(id string) (*unstructured.Unstructured, ResourceState) { // Did the user set the resource? r, ok := rt.resolvedResources[id] if ok { @@ -204,18 +204,18 @@ func (rt *ResourceGroupRuntime) GetResource(id string) (*unstructured.Unstructur // SetResource updates or sets a resource in the runtime. This is typically // called after a resource has been created or updated in the cluster. -func (rt *ResourceGroupRuntime) SetResource(id string, resource *unstructured.Unstructured) { +func (rt *ResourceGraphDefinitionRuntime) SetResource(id string, resource *unstructured.Unstructured) { rt.resolvedResources[id] = resource } // GetInstance returns the main instance object managed by this runtime. -func (rt *ResourceGroupRuntime) GetInstance() *unstructured.Unstructured { +func (rt *ResourceGraphDefinitionRuntime) GetInstance() *unstructured.Unstructured { return rt.instance.Unstructured() } // SetInstance updates the main instance object. // This is typically called after the instance has been updated in the cluster. -func (rt *ResourceGroupRuntime) SetInstance(obj *unstructured.Unstructured) { +func (rt *ResourceGraphDefinitionRuntime) SetInstance(obj *unstructured.Unstructured) { ptr := rt.instance.Unstructured() ptr.Object = obj.Object } @@ -227,7 +227,7 @@ func (rt *ResourceGroupRuntime) SetInstance(obj *unstructured.Unstructured) { // Every time Synchronize is called, it walks through the resources and tries // to resolve as many as possible. If a resource is resolved, it's added to the // resolved resources map. -func (rt *ResourceGroupRuntime) Synchronize() (bool, error) { +func (rt *ResourceGraphDefinitionRuntime) Synchronize() (bool, error) { // if everything is resolved, we're done. // TODO(a-hilaly): Add readiness check here. if rt.allExpressionsAreResolved() && len(rt.resolvedResources) == len(rt.resources) { @@ -257,7 +257,7 @@ func (rt *ResourceGroupRuntime) Synchronize() (bool, error) { // propagateResourceVariables iterates over all resources and evaluates their // variables if all dependencies are resolved. -func (rt *ResourceGroupRuntime) propagateResourceVariables() error { +func (rt *ResourceGraphDefinitionRuntime) propagateResourceVariables() error { for id := range rt.resources { if rt.canProcessResource(id) { // evaluate the resource variables @@ -272,7 +272,7 @@ func (rt *ResourceGroupRuntime) propagateResourceVariables() error { // canProcessResource checks if a resource can be resolved by examining // if all its dependencies are resolved AND if all its variables are resolved. -func (rt *ResourceGroupRuntime) canProcessResource(resource string) bool { +func (rt *ResourceGraphDefinitionRuntime) canProcessResource(resource string) bool { // Check if all dependencies are resolved. a.k.a all variables have been // evaluated. for _, dep := range rt.resources[resource].GetDependencies() { @@ -288,7 +288,7 @@ func (rt *ResourceGroupRuntime) canProcessResource(resource string) bool { // resourceVariablesResolved determines if all variables for a given resource // have been resolved. -func (rt *ResourceGroupRuntime) resourceVariablesResolved(resource string) bool { +func (rt *ResourceGraphDefinitionRuntime) resourceVariablesResolved(resource string) bool { for _, variable := range rt.runtimeVariables[resource] { if variable.Kind.IsDynamic() && !variable.Resolved { return false @@ -301,7 +301,7 @@ func (rt *ResourceGroupRuntime) resourceVariablesResolved(resource string) bool // Static variables are those that can be evaluated immediately, typically // depending only on the initial configuration. This function is usually // called once during runtime initialization to set up the baseline state -func (rt *ResourceGroupRuntime) evaluateStaticVariables() error { +func (rt *ResourceGraphDefinitionRuntime) evaluateStaticVariables() error { env, err := krocel.DefaultEnvironment(krocel.WithResourceIDs([]string{"schema"})) if err != nil { return err @@ -341,7 +341,7 @@ func (e *EvalError) Error() string { // iteratively as resources are resolved. This function is called during each // synchronization cycle to update the runtime state based on newly resolved // resources. -func (rt *ResourceGroupRuntime) evaluateDynamicVariables() error { +func (rt *ResourceGraphDefinitionRuntime) evaluateDynamicVariables() error { // Dynamic variables are those that depend on other resources // and are resolved after all the dependencies are resolved. @@ -404,7 +404,7 @@ func (rt *ResourceGroupRuntime) evaluateDynamicVariables() error { // the current state of all resources. This function aggregates information // from all managed resources to provide an overall status of the runtime, // which is typically reflected in the custom resource's status field. -func (rt *ResourceGroupRuntime) evaluateInstanceStatuses() error { +func (rt *ResourceGraphDefinitionRuntime) evaluateInstanceStatuses() error { rs := resolver.NewResolver(rt.instance.Unstructured().Object, map[string]interface{}{}) // Two pieces of information are needed here: @@ -425,7 +425,7 @@ func (rt *ResourceGroupRuntime) evaluateInstanceStatuses() error { // evaluateResourceExpressions processes all expressions associated with a // specific resource. -func (rt *ResourceGroupRuntime) evaluateResourceExpressions(resource string) error { +func (rt *ResourceGraphDefinitionRuntime) evaluateResourceExpressions(resource string) error { exprValues := make(map[string]interface{}) for _, v := range rt.expressionsCache { if v.Resolved { @@ -450,7 +450,7 @@ func (rt *ResourceGroupRuntime) evaluateResourceExpressions(resource string) err // allExpressionsAreResolved checks if every expression in the runtimes cache // has been successfully evaluated -func (rt *ResourceGroupRuntime) allExpressionsAreResolved() bool { +func (rt *ResourceGraphDefinitionRuntime) allExpressionsAreResolved() bool { for _, v := range rt.expressionsCache { if !v.Resolved { return false @@ -462,7 +462,7 @@ func (rt *ResourceGroupRuntime) allExpressionsAreResolved() bool { // IsResourceReady checks if a resource is ready based on the readyWhenExpressions // defined in the resource. If no readyWhenExpressions are defined, the resource // is considered ready. -func (rt *ResourceGroupRuntime) IsResourceReady(resourceID string) (bool, string, error) { +func (rt *ResourceGraphDefinitionRuntime) IsResourceReady(resourceID string) (bool, string, error) { observed, ok := rt.resolvedResources[resourceID] if !ok { // Users need to make sure that the resource is resolved a.k.a (SetResource) @@ -500,7 +500,7 @@ func (rt *ResourceGroupRuntime) IsResourceReady(resourceID string) (bool, string // IgnoreResource ignores resource that has a conditions expressison that evaluated // to false or whose dependencies are ignored -func (rt *ResourceGroupRuntime) IgnoreResource(resourceID string) { +func (rt *ResourceGraphDefinitionRuntime) IgnoreResource(resourceID string) { rt.ignoredByConditionsResources[resourceID] = true } @@ -510,7 +510,7 @@ func (rt *ResourceGroupRuntime) IgnoreResource(resourceID string) { // Naturally, if a resource is judged to be ignored, it will be marked as ignored // and all its dependencies will be ignored as well. Causing a chain reaction // of ignored resources. -func (rt *ResourceGroupRuntime) areDependenciesIgnored(resourceID string) bool { +func (rt *ResourceGraphDefinitionRuntime) areDependenciesIgnored(resourceID string) bool { for _, p := range rt.resources[resourceID].GetDependencies() { if _, isIgnored := rt.ignoredByConditionsResources[p]; isIgnored { return true @@ -521,7 +521,7 @@ func (rt *ResourceGroupRuntime) areDependenciesIgnored(resourceID string) bool { // WantToCreateResource returns true if all the condition expressions return true // if not it will add itself to the ignored resources -func (rt *ResourceGroupRuntime) WantToCreateResource(resourceID string) (bool, error) { +func (rt *ResourceGraphDefinitionRuntime) WantToCreateResource(resourceID string) (bool, error) { if rt.areDependenciesIgnored(resourceID) { return false, nil } diff --git a/pkg/runtime/runtime_test.go b/pkg/runtime/runtime_test.go index 7b8d4d1a..4e0b8ae6 100644 --- a/pkg/runtime/runtime_test.go +++ b/pkg/runtime/runtime_test.go @@ -212,9 +212,9 @@ func Test_RuntimeWorkflow(t *testing.T) { } // 2. Create runtime - rt, err := NewResourceGroupRuntime(instance, resources, []string{"configmap", "secret", "deployment", "service"}) + rt, err := NewResourceGraphDefinitionRuntime(instance, resources, []string{"configmap", "secret", "deployment", "service"}) if err != nil { - t.Fatalf("NewResourceGroupRuntime() error = %v", err) + t.Fatalf("NewResourceGraphDefinitionRuntime() error = %v", err) } // 3. First sync - should resolve static variables @@ -356,7 +356,7 @@ func Test_RuntimeWorkflow(t *testing.T) { } } -func Test_NewResourceGroupRuntime(t *testing.T) { +func Test_NewResourceGraphDefinitionRuntime(t *testing.T) { // Setup a test instance with a spec instance := newTestResource( withObject(map[string]interface{}{ @@ -439,9 +439,9 @@ func Test_NewResourceGroupRuntime(t *testing.T) { "service": service, } - rt, err := NewResourceGroupRuntime(instance, resources, []string{"deployment", "service"}) + rt, err := NewResourceGraphDefinitionRuntime(instance, resources, []string{"deployment", "service"}) if err != nil { - t.Fatalf("NewResourceGroupRuntime() error = %v", err) + t.Fatalf("NewResourceGraphDefinitionRuntime() error = %v", err) } // Test 1: Check expressionsCache initialization @@ -610,7 +610,7 @@ func Test_GetResource(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ resources: tt.resources, resolvedResources: tt.resolvedResources, runtimeVariables: tt.runtimeVariables, @@ -772,7 +772,7 @@ func Test_Synchronize(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ instance: tt.instance, resources: tt.resources, resolvedResources: tt.resolvedResources, @@ -1002,7 +1002,7 @@ func Test_propagateResourceVariables(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ resources: tt.resources, runtimeVariables: tt.runtimeVariables, expressionsCache: tt.expressionsCache, @@ -1206,7 +1206,7 @@ func Test_canProcessResource(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ resources: tt.resources, runtimeVariables: tt.runtimeVariables, } @@ -1336,7 +1336,7 @@ func Test_resourceVariablesResolved(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ runtimeVariables: tt.runtimeVariables, } @@ -1436,7 +1436,7 @@ func Test_evaluateStaticVariables(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ instance: tt.instance, expressionsCache: tt.expressionsCache, } @@ -1689,7 +1689,7 @@ func Test_evaluateDynamicVariables(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ instance: newTestResource( withObject(map[string]interface{}{}), ), @@ -1908,7 +1908,7 @@ func Test_evaluateInstanceStatuses(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ instance: tt.instance, expressionsCache: tt.expCache, } @@ -2076,7 +2076,7 @@ func Test_evaluateResourceExpressions(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ resources: map[string]Resource{"test": tt.resource}, expressionsCache: tt.expressions, } @@ -2154,7 +2154,7 @@ func Test_allExpressionsAreResolved(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ expressionsCache: tt.expressions, } @@ -2257,7 +2257,7 @@ func Test_IsResourceReady(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ resources: map[string]Resource{"test": tt.resource}, resolvedResources: map[string]*unstructured.Unstructured{}, } @@ -2356,7 +2356,7 @@ func Test_WantToCreateResource(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ ignoredByConditionsResources: tt.ignoredDeps, instance: newTestResource( withObject(map[string]interface{}{ @@ -2452,7 +2452,7 @@ func Test_areDependenciesIgnored(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rt := &ResourceGroupRuntime{ + rt := &ResourceGraphDefinitionRuntime{ resources: map[string]Resource{"test": tt.resource}, ignoredByConditionsResources: tt.ignoredDeps, } diff --git a/pkg/testutil/generator/resourcegroup.go b/pkg/testutil/generator/resourcegraphdefinition.go similarity index 62% rename from pkg/testutil/generator/resourcegroup.go rename to pkg/testutil/generator/resourcegraphdefinition.go index 20b5a35d..806c6284 100644 --- a/pkg/testutil/generator/resourcegroup.go +++ b/pkg/testutil/generator/resourcegraphdefinition.go @@ -23,12 +23,12 @@ import ( krov1alpha1 "github.com/kro-run/kro/api/v1alpha1" ) -// ResourceGroupOption is a functional option for ResourceGroup -type ResourceGroupOption func(*krov1alpha1.ResourceGroup) +// ResourceGraphDefinitionOption is a functional option for ResourceGraphDefinition +type ResourceGraphDefinitionOption func(*krov1alpha1.ResourceGraphDefinition) -// NewResourceGroup creates a new ResourceGroup with the given name and options -func NewResourceGroup(name string, opts ...ResourceGroupOption) *krov1alpha1.ResourceGroup { - rg := &krov1alpha1.ResourceGroup{ +// NewResourceGraphDefinition creates a new ResourceGraphDefinition with the given name and options +func NewResourceGraphDefinition(name string, opts ...ResourceGraphDefinitionOption) *krov1alpha1.ResourceGraphDefinition { + rg := &krov1alpha1.ResourceGraphDefinition{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, @@ -40,15 +40,15 @@ func NewResourceGroup(name string, opts ...ResourceGroupOption) *krov1alpha1.Res return rg } -// WithNamespace sets the namespace of the ResourceGroup -func WithNamespace(namespace string) ResourceGroupOption { - return func(rg *krov1alpha1.ResourceGroup) { - rg.Namespace = namespace +// WithNamespace sets the namespace of the ResourceGraphDefinition +func WithNamespace(namespace string) ResourceGraphDefinitionOption { + return func(rgd *krov1alpha1.ResourceGraphDefinition) { + rgd.Namespace = namespace } } -// WithSchema sets the definition and status of the ResourceGroup -func WithSchema(kind, version string, spec, status map[string]interface{}) ResourceGroupOption { +// WithSchema sets the definition and status of the ResourceGraphDefinition +func WithSchema(kind, version string, spec, status map[string]interface{}) ResourceGraphDefinitionOption { rawSpec, err := json.Marshal(spec) if err != nil { panic(err) @@ -58,8 +58,8 @@ func WithSchema(kind, version string, spec, status map[string]interface{}) Resou panic(err) } - return func(rg *krov1alpha1.ResourceGroup) { - rg.Spec.Schema = &krov1alpha1.Schema{ + return func(rgd *krov1alpha1.ResourceGraphDefinition) { + rgd.Spec.Schema = &krov1alpha1.Schema{ Kind: kind, APIVersion: version, Spec: runtime.RawExtension{ @@ -74,20 +74,20 @@ func WithSchema(kind, version string, spec, status map[string]interface{}) Resou } } -// WithResource adds a resource to the ResourceGroup with the given name and definition +// WithResource adds a resource to the ResourceGraphDefinition with the given name and definition // readyWhen and includeWhen expressions are optional. func WithResource( id string, template map[string]interface{}, readyWhen []string, includeWhen []string, -) ResourceGroupOption { - return func(rg *krov1alpha1.ResourceGroup) { +) ResourceGraphDefinitionOption { + return func(rgd *krov1alpha1.ResourceGraphDefinition) { raw, err := json.Marshal(template) if err != nil { panic(err) } - rg.Spec.Resources = append(rg.Spec.Resources, &krov1alpha1.Resource{ + rgd.Spec.Resources = append(rgd.Spec.Resources, &krov1alpha1.Resource{ ID: id, ReadyWhen: readyWhen, IncludeWhen: includeWhen, diff --git a/test/README.md b/test/README.md index 6471e324..1b08f0c3 100644 --- a/test/README.md +++ b/test/README.md @@ -29,7 +29,7 @@ deployed in production clusters. - `integration/`: Contains integration test suites for kro. - `e2e/`: Contains e2e test suites for kro. - `testdata/`: Directory for test data, such as Kubernetes manifests, - resourcegroups ... + resourcegraphdefinitions ... ## Integration tests @@ -42,16 +42,16 @@ controllers, you should: 3. Test your controller's reconciliation logic 4. Check status updates on your custom resources -### Example testing ResourceGroups +### Example testing ResourceGraphDefinitions -1. Create a ResourceGroup -2. Trigger ResourceGroup reconciliation -3. Check that the ResourceGroup status was updated correctly +1. Create a ResourceGraphDefinition +2. Trigger ResourceGraphDefinition reconciliation +3. Check that the ResourceGraphDefinition status was updated correctly 4. Verify that the correct Create (CRD) call was made to the API server 5. Check that the controller is watching the correct RG instances -6. Create a ResourceGroup instance -7. Trigger the ResourceGroup instance reconciliation -8. Check that the ResourceGroup instance status was updated correctly +6. Create a ResourceGraphDefinition instance +7. Trigger the ResourceGraphDefinition instance reconciliation +8. Check that the ResourceGraphDefinition instance status was updated correctly 9. Verify that the some resources were created in the cluster 10. Trigger a second reconciliation and check that the status was updated correctly @@ -68,35 +68,35 @@ should: 1. Use a real Kubernetes cluster (e.g. kind, minikube, or EKS) 2. Deploy kro controller and it's CRDs 3. Deploy other controllers or resources that will interact with kro resources. -4. Create kro ResourceGroups and ResourceGroupInstances and verify their full +4. Create kro ResourceGraphDefinitions and ResourceGraphDefinitionInstances and verify their full lifecycle. ### E2e test example 1. Deploy kro controller and CRDs 2. Deploy a sample application that uses kro -3. Create a `ResourceGroup` custom resource +3. Create a `ResourceGraphDefinition` custom resource 4. Verify that the corresponding CRD is created in the cluster -5. Create an instance of the `ResourceGroup` -6. Wait for all resources defined in the `ResourceGroup` to be created +5. Create an instance of the `ResourceGraphDefinition` +6. Wait for all resources defined in the `ResourceGraphDefinition` to be created 7. Verify that all resources are correctly created and configured -8. Update the `ResourceGroup` instance +8. Update the `ResourceGraphDefinition` instance 9. Verify that the changes are correctly propagated to the managed resources -10. Delete the `ResourceGroup` instance +10. Delete the `ResourceGraphDefinition` instance 11. Verify that all managed resources are correctly deleted -12. Delete the `ResourceGroup` custom resource +12. Delete the `ResourceGraphDefinition` custom resource 13. Verify that the corresponding CRD is removed from the cluster ### Addional scenarios 1. Cross namespace resource management -2. Scaling testing: Create a large number of ResourceGroups and ResourceGroup +2. Scaling testing: Create a large number of ResourceGraphDefinitions and ResourceGraphDefinition instances to test kro at scale. 3. Failure recovery: Simulate failures in the controller or the Kubernetes API server and verify that kro recovers correctly 4. Controller upgrade testing: Deploy a new version of kro and verify that it - can handle existing `ResourceGroups` and `ResourceGroup` instances -5. ResourceGroup conflict testing: Create multiple `ResourceGroups` with + can handle existing `ResourceGraphDefinitions` and `ResourceGraphDefinition` instances +5. ResourceGraphDefinition conflict testing: Create multiple `ResourceGraphDefinitions` with conflicting resources and verify that kro handles the conflicts correctly 6. Integration with other controllers: Deploy other controllers that interact with kro resources and verify that they work correctly together diff --git a/test/integration/environment/setup.go b/test/integration/environment/setup.go index 3d9acd6a..01fe0934 100644 --- a/test/integration/environment/setup.go +++ b/test/integration/environment/setup.go @@ -31,7 +31,7 @@ import ( krov1alpha1 "github.com/kro-run/kro/api/v1alpha1" kroclient "github.com/kro-run/kro/pkg/client" ctrlinstance "github.com/kro-run/kro/pkg/controller/instance" - ctrlresourcegroup "github.com/kro-run/kro/pkg/controller/resourcegroup" + ctrlresourcegraphdefinition "github.com/kro-run/kro/pkg/controller/resourcegraphdefinition" "github.com/kro-run/kro/pkg/dynamiccontroller" "github.com/kro-run/kro/pkg/graph" ) @@ -65,7 +65,7 @@ func New(controllerConfig ControllerConfig) (*Environment, error) { env.TestEnv = &envtest.Environment{ CRDDirectoryPaths: []string{ - // resourcegroup CRD + // resourcegraphdefinition CRD filepath.Join("../../../..", "config", "crd", "bases"), // ACK ec2 CRDs filepath.Join("../..", "crds", "ack-ec2-controller"), @@ -150,7 +150,7 @@ func (e *Environment) setupController() error { } }() - rgReconciler := ctrlresourcegroup.NewResourceGroupReconciler( + rgReconciler := ctrlresourcegraphdefinition.NewResourceGraphDefinitionReconciler( noopLogger(), e.Client, e.ClientSet, diff --git a/test/integration/suites/ackekscluster/generator.go b/test/integration/suites/ackekscluster/generator.go index 7882e886..cda35ea8 100644 --- a/test/integration/suites/ackekscluster/generator.go +++ b/test/integration/suites/ackekscluster/generator.go @@ -24,10 +24,10 @@ import ( func eksCluster( namespace, name string, ) ( - *krov1alpha1.ResourceGroup, + *krov1alpha1.ResourceGraphDefinition, func(namespace, name, version string) *unstructured.Unstructured, ) { - resourcegroup := generator.NewResourceGroup(name, + resourcegraphdefinition := generator.NewResourceGraphDefinition(name, generator.WithNamespace(namespace), generator.WithSchema( "EKSCluster", "v1alpha1", @@ -80,7 +80,7 @@ func eksCluster( }, } } - return resourcegroup, instanceGenerator + return resourcegraphdefinition, instanceGenerator } func vpcDef(namespace string) map[string]interface{} { diff --git a/test/integration/suites/ackekscluster/suite_test.go b/test/integration/suites/ackekscluster/suite_test.go index c9554b5d..b77f6096 100644 --- a/test/integration/suites/ackekscluster/suite_test.go +++ b/test/integration/suites/ackekscluster/suite_test.go @@ -58,7 +58,7 @@ func TestEKSCluster(t *testing.T) { } var _ = Describe("EKSCluster", func() { - It("should handle complete lifecycle of ResourceGroup and Instance", func() { + It("should handle complete lifecycle of ResourceGraphDefinition and Instance", func() { ctx := context.Background() namespace := fmt.Sprintf("test-%s", rand.String(5)) @@ -70,12 +70,12 @@ var _ = Describe("EKSCluster", func() { } Expect(env.Client.Create(ctx, ns)).To(Succeed()) - // Create ResourceGroup + // Create ResourceGraphDefinition rg, genInstance := eksCluster(namespace, "test-eks-cluster") Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is created and becomes ready - createdRG := &krov1alpha1.ResourceGroup{} + // Verify ResourceGraphDefinition is created and becomes ready + createdRG := &krov1alpha1.ResourceGraphDefinition{} Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -83,7 +83,7 @@ var _ = Describe("EKSCluster", func() { }, createdRG) g.Expect(err).ToNot(HaveOccurred()) - // Verify the ResourceGroup fields + // Verify the ResourceGraphDefinition fields g.Expect(createdRG.Spec.Schema.Kind).To(Equal("EKSCluster")) g.Expect(createdRG.Spec.Schema.APIVersion).To(Equal("v1alpha1")) g.Expect(createdRG.Spec.Resources).To(HaveLen(12)) // All resources from the generator @@ -103,19 +103,19 @@ var _ = Describe("EKSCluster", func() { "clusterNodeGroup", })) - // Verify the ResourceGroup status + // Verify the ResourceGraphDefinition status g.Expect(createdRG.Status.TopologicalOrder).To(HaveLen(12)) // Verify conditions g.Expect(createdRG.Status.Conditions).To(HaveLen(3)) - g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeReconcilerReady)) + g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeReconcilerReady)) g.Expect(createdRG.Status.Conditions[0].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeGraphVerified)) + g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified)) g.Expect(createdRG.Status.Conditions[1].Status).To(Equal(metav1.ConditionTrue)) g.Expect(createdRG.Status.Conditions[2].Type).To( - Equal(krov1alpha1.ResourceGroupConditionTypeCustomResourceDefinitionSynced), + Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced), ) g.Expect(createdRG.Status.Conditions[2].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) // Create instance @@ -464,15 +464,15 @@ var _ = Describe("EKSCluster", func() { return errors.IsNotFound(err) }, 60*time.Second, time.Second).Should(BeTrue()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is deleted + // Verify ResourceGraphDefinition is deleted Eventually(func() bool { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, - }, &krov1alpha1.ResourceGroup{}) + }, &krov1alpha1.ResourceGraphDefinition{}) return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) diff --git a/test/integration/suites/core/conditional_test.go b/test/integration/suites/core/conditional_test.go index b92e0fb5..3a698884 100644 --- a/test/integration/suites/core/conditional_test.go +++ b/test/integration/suites/core/conditional_test.go @@ -52,7 +52,7 @@ var _ = Describe("Conditions", func() { }) It("should not create deployment, service, and configmap due to condition deploymentEnabled == false", func() { - rg := generator.NewResourceGroup("test-conditions", + rg := generator.NewResourceGraphDefinition("test-conditions", generator.WithNamespace(namespace), generator.WithSchema( "TestConditions", "v1alpha1", @@ -195,11 +195,11 @@ var _ = Describe("Conditions", func() { }, nil, []string{"${schema.spec.serviceBenabled}"}), ) - // Create ResourceGroup + // Create ResourceGraphDefinition Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is created and becomes ready - createdRG := &krov1alpha1.ResourceGroup{} + // Verify ResourceGraphDefinition is created and becomes ready + createdRG := &krov1alpha1.ResourceGraphDefinition{} Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -207,7 +207,7 @@ var _ = Describe("Conditions", func() { }, createdRG) g.Expect(err).ToNot(HaveOccurred()) - // Verify the ResourceGroup fields + // Verify the ResourceGraphDefinition fields g.Expect(createdRG.Spec.Schema.Kind).To(Equal("TestConditions")) g.Expect(createdRG.Spec.Schema.APIVersion).To(Equal("v1alpha1")) g.Expect(createdRG.Spec.Resources).To(HaveLen(6)) @@ -221,19 +221,19 @@ var _ = Describe("Conditions", func() { "serviceB", })) - // Verify the ResourceGroup status + // Verify the ResourceGraphDefinition status g.Expect(createdRG.Status.TopologicalOrder).To(HaveLen(6)) // Verify conditions g.Expect(createdRG.Status.Conditions).To(HaveLen(3)) - g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeReconcilerReady)) + g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeReconcilerReady)) g.Expect(createdRG.Status.Conditions[0].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeGraphVerified)) + g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified)) g.Expect(createdRG.Status.Conditions[1].Status).To(Equal(metav1.ConditionTrue)) g.Expect(createdRG.Status.Conditions[2].Type).To( - Equal(krov1alpha1.ResourceGroupConditionTypeCustomResourceDefinitionSynced), + Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced), ) g.Expect(createdRG.Status.Conditions[2].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) @@ -344,15 +344,15 @@ var _ = Describe("Conditions", func() { return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is deleted + // Verify ResourceGraphDefinition is deleted Eventually(func() bool { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, - }, &krov1alpha1.ResourceGroup{}) + }, &krov1alpha1.ResourceGraphDefinition{}) return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) }) diff --git a/test/integration/suites/core/crd_test.go b/test/integration/suites/core/crd_test.go index 6151b14f..cf1d22f6 100644 --- a/test/integration/suites/core/crd_test.go +++ b/test/integration/suites/core/crd_test.go @@ -47,9 +47,9 @@ var _ = Describe("CRD", func() { }) Context("CRD Creation", func() { - It("should create CRD when ResourceGroup is created", func() { - // Create a simple ResourceGroup - rg := generator.NewResourceGroup("test-crd", + It("should create CRD when ResourceGraphDefinition is created", func() { + // Create a simple ResourceGraphDefinition + rg := generator.NewResourceGraphDefinition("test-crd", generator.WithNamespace(namespace), generator.WithSchema( "TestResource", "v1alpha1", @@ -97,9 +97,9 @@ var _ = Describe("CRD", func() { }, 10*time.Second, time.Second).Should(Succeed()) }) - It("should update CRD when ResourceGroup is updated", func() { - // Create initial ResourceGroup - rg := generator.NewResourceGroup("test-crd-update", + It("should update CRD when ResourceGraphDefinition is updated", func() { + // Create initial ResourceGraphDefinition + rg := generator.NewResourceGraphDefinition("test-crd-update", generator.WithNamespace(namespace), generator.WithSchema( "TestUpdate", "v1alpha1", @@ -120,7 +120,7 @@ var _ = Describe("CRD", func() { }, crd) }, 10*time.Second, time.Second).Should(Succeed()) - // Update ResourceGroup with new fields + // Update ResourceGraphDefinition with new fields Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -151,9 +151,9 @@ var _ = Describe("CRD", func() { }, 10*time.Second, time.Second).Should(Succeed()) }) - It("should delete CRD when ResourceGroup is deleted", func() { - // Create ResourceGroup - rg := generator.NewResourceGroup("test-crd-delete", + It("should delete CRD when ResourceGraphDefinition is deleted", func() { + // Create ResourceGraphDefinition + rg := generator.NewResourceGraphDefinition("test-crd-delete", generator.WithNamespace(namespace), generator.WithSchema( "TestDelete", "v1alpha1", @@ -172,7 +172,7 @@ var _ = Describe("CRD", func() { &apiextensionsv1.CustomResourceDefinition{}) }, 10*time.Second, time.Second).Should(Succeed()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) // Verify CRD is deleted diff --git a/test/integration/suites/core/lifecycle_test.go b/test/integration/suites/core/lifecycle_test.go index afbbdf2f..f3723a34 100644 --- a/test/integration/suites/core/lifecycle_test.go +++ b/test/integration/suites/core/lifecycle_test.go @@ -45,8 +45,8 @@ var _ = Describe("Update", func() { } Expect(env.Client.Create(ctx, ns)).To(Succeed()) - // Create ResourceGroup for a simple deployment service - rg := generator.NewResourceGroup("test-update", + // Create ResourceGraphDefinition for a simple deployment service + rg := generator.NewResourceGraphDefinition("test-update", generator.WithNamespace(namespace), generator.WithSchema( "TestUpdate", "v1alpha1", @@ -96,15 +96,15 @@ var _ = Describe("Update", func() { Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is ready - createdRG := &krov1alpha1.ResourceGroup{} + // Verify ResourceGraphDefinition is ready + createdRG := &krov1alpha1.ResourceGraphDefinition{} Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, }, createdRG) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) // Create initial instance diff --git a/test/integration/suites/core/readiness_test.go b/test/integration/suites/core/readiness_test.go index 8cac452e..b5f9ac28 100644 --- a/test/integration/suites/core/readiness_test.go +++ b/test/integration/suites/core/readiness_test.go @@ -53,7 +53,7 @@ var _ = Describe("Readiness", func() { It(`should wait for deployment to have deployment.spec.replicas == deployment.status.availableReplicas before creating service`, func() { - rg := generator.NewResourceGroup("test-readiness", + rg := generator.NewResourceGraphDefinition("test-readiness", generator.WithNamespace(namespace), generator.WithSchema( "TestReadiness", "v1alpha1", @@ -136,11 +136,11 @@ var _ = Describe("Readiness", func() { }, nil, nil), ) - // Create ResourceGroup + // Create ResourceGraphDefinition Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is created and becomes ready - createdRG := &krov1alpha1.ResourceGroup{} + // Verify ResourceGraphDefinition is created and becomes ready + createdRG := &krov1alpha1.ResourceGraphDefinition{} Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -148,7 +148,7 @@ var _ = Describe("Readiness", func() { }, createdRG) g.Expect(err).ToNot(HaveOccurred()) - // Verify the ResourceGroup fields + // Verify the ResourceGraphDefinition fields g.Expect(createdRG.Spec.Schema.Kind).To(Equal("TestReadiness")) g.Expect(createdRG.Spec.Schema.APIVersion).To(Equal("v1alpha1")) g.Expect(createdRG.Spec.Resources).To(HaveLen(2)) @@ -158,19 +158,19 @@ var _ = Describe("Readiness", func() { "service", })) - // Verify the ResourceGroup status + // Verify the ResourceGraphDefinition status g.Expect(createdRG.Status.TopologicalOrder).To(HaveLen(2)) // Verify conditions g.Expect(createdRG.Status.Conditions).To(HaveLen(3)) - g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeReconcilerReady)) + g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeReconcilerReady)) g.Expect(createdRG.Status.Conditions[0].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeGraphVerified)) + g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified)) g.Expect(createdRG.Status.Conditions[1].Status).To(Equal(metav1.ConditionTrue)) g.Expect(createdRG.Status.Conditions[2].Type).To( - Equal(krov1alpha1.ResourceGroupConditionTypeCustomResourceDefinitionSynced), + Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced), ) g.Expect(createdRG.Status.Conditions[2].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) @@ -276,15 +276,15 @@ var _ = Describe("Readiness", func() { return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is deleted + // Verify ResourceGraphDefinition is deleted Eventually(func() bool { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, - }, &krov1alpha1.ResourceGroup{}) + }, &krov1alpha1.ResourceGraphDefinition{}) return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) }) diff --git a/test/integration/suites/core/recover_test.go b/test/integration/suites/core/recover_test.go index bd19348d..75b8b74d 100644 --- a/test/integration/suites/core/recover_test.go +++ b/test/integration/suites/core/recover_test.go @@ -51,8 +51,8 @@ var _ = Describe("Recovery", func() { }) It("should recover from invalid state and use latest valid configuration", func() { - // Create initial valid ResourceGroup - rg := generator.NewResourceGroup("test-recovery", + // Create initial valid ResourceGraphDefinition + rg := generator.NewResourceGraphDefinition("test-recovery", generator.WithNamespace(namespace), generator.WithSchema( "TestRecovery", "v1alpha1", @@ -75,17 +75,17 @@ var _ = Describe("Recovery", func() { }, nil, nil), ) - // Create ResourceGroup + // Create ResourceGraphDefinition Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify initial ResourceGroup becomes active + // Verify initial ResourceGraphDefinition becomes active Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) // Update to invalid state with a cyclic dependency @@ -124,14 +124,14 @@ var _ = Describe("Recovery", func() { g.Expect(err).ToNot(HaveOccurred()) }, 10*time.Second, time.Second).Should(Succeed()) - // Verify ResourceGroup becomes inactive + // Verify ResourceGraphDefinition becomes inactive Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) }, 10*time.Second, time.Second).Should(Succeed()) // Update to new valid state with different configuration @@ -188,14 +188,14 @@ var _ = Describe("Recovery", func() { g.Expect(err).ToNot(HaveOccurred()) }, 10*time.Second, time.Second).Should(Succeed()) - // Verify ResourceGroup becomes active again + // Verify ResourceGraphDefinition becomes active again Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) // Create instance @@ -242,15 +242,15 @@ var _ = Describe("Recovery", func() { return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is deleted + // Verify ResourceGraphDefinition is deleted Eventually(func() bool { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, - }, &krov1alpha1.ResourceGroup{}) + }, &krov1alpha1.ResourceGraphDefinition{}) return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) }) diff --git a/test/integration/suites/core/status_test.go b/test/integration/suites/core/status_test.go index fad70d93..313c0a50 100644 --- a/test/integration/suites/core/status_test.go +++ b/test/integration/suites/core/status_test.go @@ -46,8 +46,8 @@ var _ = Describe("Status", func() { })).To(Succeed()) }) - It("should have correct conditions when ResourceGroup is created", func() { - rg := generator.NewResourceGroup("test-status", + It("should have correct conditions when ResourceGraphDefinition is created", func() { + rg := generator.NewResourceGraphDefinition("test-status", generator.WithNamespace(namespace), generator.WithSchema( "TestStatus", "v1alpha1", @@ -67,7 +67,7 @@ var _ = Describe("Status", func() { Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup status + // Verify ResourceGraphDefinition status Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -77,7 +77,7 @@ var _ = Describe("Status", func() { // Check conditions g.Expect(rg.Status.Conditions).To(HaveLen(3)) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) for _, cond := range rg.Status.Conditions { g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) @@ -87,7 +87,7 @@ var _ = Describe("Status", func() { }) It("should reflect failure conditions when definition is invalid", func() { - rg := generator.NewResourceGroup("test-status-fail", + rg := generator.NewResourceGraphDefinition("test-status-fail", generator.WithNamespace(namespace), generator.WithSchema( "TestStatusFail", "v1alpha1", @@ -107,12 +107,12 @@ var _ = Describe("Status", func() { }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) // Check specific failure condition var crdCondition *krov1alpha1.Condition for _, cond := range rg.Status.Conditions { - if cond.Type == krov1alpha1.ResourceGroupConditionTypeGraphVerified { + if cond.Type == krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified { crdCondition = &cond break } @@ -120,7 +120,7 @@ var _ = Describe("Status", func() { g.Expect(crdCondition).ToNot(BeNil()) g.Expect(crdCondition.Status).To(Equal(metav1.ConditionFalse)) - g.Expect(*crdCondition.Reason).To(ContainSubstring("failed to build resourcegroup")) + g.Expect(*crdCondition.Reason).To(ContainSubstring("failed to build resourcegraphdefinition")) }, 10*time.Second, time.Second).Should(Succeed()) }) }) diff --git a/test/integration/suites/core/topology_test.go b/test/integration/suites/core/topology_test.go index 656eb46b..c87eee5a 100644 --- a/test/integration/suites/core/topology_test.go +++ b/test/integration/suites/core/topology_test.go @@ -47,7 +47,7 @@ var _ = Describe("Topology", func() { }) It("should correctly order AWS resources in dependency graph", func() { - rg := generator.NewResourceGroup("test-topology", + rg := generator.NewResourceGraphDefinition("test-topology", generator.WithNamespace(namespace), generator.WithSchema( "TestTopology", "v1alpha1", @@ -139,7 +139,7 @@ var _ = Describe("Topology", func() { Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup topology + // Verify ResourceGraphDefinition topology Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -150,7 +150,7 @@ var _ = Describe("Topology", func() { // Verify graph is verified var graphCondition *krov1alpha1.Condition for _, cond := range rg.Status.Conditions { - if cond.Type == krov1alpha1.ResourceGroupConditionTypeGraphVerified { + if cond.Type == krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified { graphCondition = &cond break } @@ -171,7 +171,7 @@ var _ = Describe("Topology", func() { }) It("should detect cyclic dependencies in AWS resource definitions", func() { - rg := generator.NewResourceGroup("test-topology-cyclic", + rg := generator.NewResourceGraphDefinition("test-topology-cyclic", generator.WithNamespace(namespace), generator.WithSchema( "TestTopologyCyclic", "v1alpha1", @@ -216,7 +216,7 @@ var _ = Describe("Topology", func() { var graphCondition *krov1alpha1.Condition for _, cond := range rg.Status.Conditions { - if cond.Type == krov1alpha1.ResourceGroupConditionTypeGraphVerified { + if cond.Type == krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified { graphCondition = &cond break } @@ -224,7 +224,7 @@ var _ = Describe("Topology", func() { g.Expect(graphCondition).ToNot(BeNil()) g.Expect(graphCondition.Status).To(Equal(metav1.ConditionFalse)) g.Expect(*graphCondition.Reason).To(ContainSubstring("This would create a cycle")) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) }, 10*time.Second, time.Second).Should(Succeed()) }) }) diff --git a/test/integration/suites/core/validation_test.go b/test/integration/suites/core/validation_test.go index 30f62322..6f696b4b 100644 --- a/test/integration/suites/core/validation_test.go +++ b/test/integration/suites/core/validation_test.go @@ -47,7 +47,7 @@ var _ = Describe("Validation", func() { Context("Resource IDs", func() { It("should validate correct resource naming conventions", func() { - rg := generator.NewResourceGroup("test-validation", + rg := generator.NewResourceGraphDefinition("test-validation", generator.WithNamespace(namespace), generator.WithSchema( "TestValidation", "v1alpha1", @@ -70,7 +70,7 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) }) @@ -89,7 +89,7 @@ var _ = Describe("Validation", func() { } for _, invalidName := range invalidNames { - rg := generator.NewResourceGroup(fmt.Sprintf("test-validation-%s", rand.String(5)), + rg := generator.NewResourceGraphDefinition(fmt.Sprintf("test-validation-%s", rand.String(5)), generator.WithNamespace(namespace), generator.WithSchema( "TestValidation", "v1alpha1", @@ -109,12 +109,12 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) // Verify validation condition var condition *krov1alpha1.Condition for _, cond := range rg.Status.Conditions { - if cond.Type == krov1alpha1.ResourceGroupConditionTypeGraphVerified { + if cond.Type == krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified { condition = &cond break } @@ -127,7 +127,7 @@ var _ = Describe("Validation", func() { }) It("should reject duplicate resource IDs", func() { - rg := generator.NewResourceGroup("test-validation-dup", + rg := generator.NewResourceGraphDefinition("test-validation-dup", generator.WithNamespace(namespace), generator.WithSchema( "TestValidation", "v1alpha1", @@ -148,12 +148,12 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) // Verify validation condition var condition *krov1alpha1.Condition for _, cond := range rg.Status.Conditions { - if cond.Type == krov1alpha1.ResourceGroupConditionTypeGraphVerified { + if cond.Type == krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified { condition = &cond break } @@ -167,7 +167,7 @@ var _ = Describe("Validation", func() { Context("Kubernetes Object Structure", func() { It("should validate correct kubernetes object structure", func() { - rg := generator.NewResourceGroup("test-k8s-valid", + rg := generator.NewResourceGraphDefinition("test-k8s-valid", generator.WithNamespace(namespace), generator.WithSchema( "TestK8sValidation", "v1alpha1", @@ -193,7 +193,7 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) }) @@ -229,7 +229,7 @@ var _ = Describe("Validation", func() { } for i, invalidObj := range invalidObjects { - rg := generator.NewResourceGroup(fmt.Sprintf("test-k8s-invalid-%d", i), + rg := generator.NewResourceGraphDefinition(fmt.Sprintf("test-k8s-invalid-%d", i), generator.WithNamespace(namespace), generator.WithSchema( "TestK8sValidation", "v1alpha1", @@ -249,7 +249,7 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) }, 10*time.Second, time.Second).Should(Succeed()) } }) @@ -265,7 +265,7 @@ var _ = Describe("Validation", func() { } for _, kind := range validKinds { - rg := generator.NewResourceGroup(fmt.Sprintf("test-kind-%s", rand.String(5)), + rg := generator.NewResourceGraphDefinition(fmt.Sprintf("test-kind-%s", rand.String(5)), generator.WithNamespace(namespace), generator.WithSchema( kind, "v1alpha1", @@ -284,7 +284,7 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) } }) @@ -300,7 +300,7 @@ var _ = Describe("Validation", func() { } for _, kind := range invalidKinds { - rg := generator.NewResourceGroup(fmt.Sprintf("test-kind-%s", rand.String(5)), + rg := generator.NewResourceGraphDefinition(fmt.Sprintf("test-kind-%s", rand.String(5)), generator.WithNamespace(namespace), generator.WithSchema( kind, "v1alpha1", @@ -319,15 +319,15 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) }, 10*time.Second, time.Second).Should(Succeed()) } }) }) Context("Proper Cleanup", func() { - It("should not panic when deleting an inactive ResourceGroup", func() { - rg := generator.NewResourceGroup("test-cleanup", + It("should not panic when deleting an inactive ResourceGraphDefinition", func() { + rg := generator.NewResourceGraphDefinition("test-cleanup", generator.WithNamespace(namespace), generator.WithSchema( "TestCleanup", "v1alpha1", @@ -353,7 +353,7 @@ var _ = Describe("Validation", func() { Namespace: namespace, }, rg) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGroupStateInactive)) + g.Expect(rg.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateInactive)) g.Expect(rg.Status.TopologicalOrder).To(BeEmpty()) }, 10*time.Second, time.Second).Should(Succeed()) diff --git a/test/integration/suites/deploymentservice/generator.go b/test/integration/suites/deploymentservice/generator.go index 8099282d..f17f0cb1 100644 --- a/test/integration/suites/deploymentservice/generator.go +++ b/test/integration/suites/deploymentservice/generator.go @@ -21,14 +21,14 @@ import ( "github.com/kro-run/kro/pkg/testutil/generator" ) -// deploymentService creates a ResourceGroup for testing deployment+service combinations +// deploymentService creates a ResourceGraphDefinition for testing deployment+service combinations func deploymentService( namespace, name string, ) ( - *krov1alpha1.ResourceGroup, + *krov1alpha1.ResourceGraphDefinition, func(namespace, name string, port int) *unstructured.Unstructured, ) { - resourcegroup := generator.NewResourceGroup(name, + resourcegraphdefinition := generator.NewResourceGraphDefinition(name, generator.WithNamespace(namespace), generator.WithSchema( "DeploymentService", "v1alpha1", @@ -60,7 +60,7 @@ func deploymentService( }, } } - return resourcegroup, instanceGenerator + return resourcegraphdefinition, instanceGenerator } func deploymentDef() map[string]interface{} { diff --git a/test/integration/suites/deploymentservice/suite_test.go b/test/integration/suites/deploymentservice/suite_test.go index e793d0e8..3a7d6588 100644 --- a/test/integration/suites/deploymentservice/suite_test.go +++ b/test/integration/suites/deploymentservice/suite_test.go @@ -58,7 +58,7 @@ func TestDeploymentservice(t *testing.T) { } var _ = Describe("DeploymentService", func() { - It("should handle complete lifecycle of ResourceGroup and Instance", func() { + It("should handle complete lifecycle of ResourceGraphDefinition and Instance", func() { ctx := context.Background() namespace := fmt.Sprintf("test-%s", rand.String(5)) @@ -70,12 +70,12 @@ var _ = Describe("DeploymentService", func() { } Expect(env.Client.Create(ctx, ns)).To(Succeed()) - // Create ResourceGroup + // Create ResourceGraphDefinition rg, genInstance := deploymentService(namespace, "test-deployment-service") Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is created and becomes ready - createdRG := &krov1alpha1.ResourceGroup{} + // Verify ResourceGraphDefinition is created and becomes ready + createdRG := &krov1alpha1.ResourceGraphDefinition{} Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -83,23 +83,23 @@ var _ = Describe("DeploymentService", func() { }, createdRG) g.Expect(err).ToNot(HaveOccurred()) - // Verify the ResourceGroup fields + // Verify the ResourceGraphDefinition fields g.Expect(createdRG.Spec.Schema.Kind).To(Equal("DeploymentService")) g.Expect(createdRG.Spec.Schema.APIVersion).To(Equal("v1alpha1")) g.Expect(createdRG.Spec.Resources).To(HaveLen(2)) - // Verify the ResourceGroup status + // Verify the ResourceGraphDefinition status g.Expect(createdRG.Status.Conditions).To(HaveLen(3)) - g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeReconcilerReady)) + g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeReconcilerReady)) g.Expect(createdRG.Status.Conditions[0].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeGraphVerified)) + g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified)) g.Expect(createdRG.Status.Conditions[1].Status).To(Equal(metav1.ConditionTrue)) g.Expect(createdRG.Status.Conditions[2].Type).To( - Equal(krov1alpha1.ResourceGroupConditionTypeCustomResourceDefinitionSynced), + Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced), ) g.Expect(createdRG.Status.Conditions[2].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) g.Expect(createdRG.Status.TopologicalOrder).To(HaveLen(2)) g.Expect(createdRG.Status.TopologicalOrder).To(Equal([]string{"deployment", "service"})) }, 10*time.Second, time.Second).Should(Succeed()) @@ -206,15 +206,15 @@ var _ = Describe("DeploymentService", func() { return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is deleted + // Verify ResourceGraphDefinition is deleted Eventually(func() bool { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, - }, &krov1alpha1.ResourceGroup{}) + }, &krov1alpha1.ResourceGraphDefinition{}) return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) diff --git a/test/integration/suites/networkingstack/generator.go b/test/integration/suites/networkingstack/generator.go index 88901c24..f9235296 100644 --- a/test/integration/suites/networkingstack/generator.go +++ b/test/integration/suites/networkingstack/generator.go @@ -24,10 +24,10 @@ import ( func networkingStack( name, namespace string, ) ( - *krov1alpha1.ResourceGroup, + *krov1alpha1.ResourceGraphDefinition, func(namespace, name string) *unstructured.Unstructured, ) { - resourcegroup := generator.NewResourceGroup(name, + resourcegraphdefinition := generator.NewResourceGraphDefinition(name, generator.WithNamespace(namespace), generator.WithSchema( "NetworkingStack", "v1alpha1", @@ -66,7 +66,7 @@ func networkingStack( }, } } - return resourcegroup, instanceGenerator + return resourcegraphdefinition, instanceGenerator } func vpcDef() map[string]interface{} { diff --git a/test/integration/suites/networkingstack/suite_test.go b/test/integration/suites/networkingstack/suite_test.go index f41d84e2..78e357c0 100644 --- a/test/integration/suites/networkingstack/suite_test.go +++ b/test/integration/suites/networkingstack/suite_test.go @@ -57,7 +57,7 @@ func TestNetworkingStack(t *testing.T) { } var _ = Describe("NetworkingStack", func() { - It("should handle complete lifecycle of ResourceGroup and Instance", func() { + It("should handle complete lifecycle of ResourceGraphDefinition and Instance", func() { ctx := context.Background() namespace := fmt.Sprintf("test-%s", rand.String(5)) @@ -69,12 +69,12 @@ var _ = Describe("NetworkingStack", func() { } Expect(env.Client.Create(ctx, ns)).To(Succeed()) - // Create ResourceGroup + // Create ResourceGraphDefinition rg, genInstance := networkingStack("test-networking-stack", namespace) Expect(env.Client.Create(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is created and becomes ready - createdRG := &krov1alpha1.ResourceGroup{} + // Verify ResourceGraphDefinition is created and becomes ready + createdRG := &krov1alpha1.ResourceGraphDefinition{} Eventually(func(g Gomega) { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, @@ -82,12 +82,12 @@ var _ = Describe("NetworkingStack", func() { }, createdRG) g.Expect(err).ToNot(HaveOccurred()) - // Verify the ResourceGroup fields + // Verify the ResourceGraphDefinition fields g.Expect(createdRG.Spec.Schema.Kind).To(Equal("NetworkingStack")) g.Expect(createdRG.Spec.Schema.APIVersion).To(Equal("v1alpha1")) g.Expect(createdRG.Spec.Resources).To(HaveLen(5)) // vpc, 3 subnets, security group - // Verify the ResourceGroup status + // Verify the ResourceGraphDefinition status g.Expect(createdRG.Status.TopologicalOrder).To(HaveLen(5)) g.Expect(createdRG.Status.TopologicalOrder).To(Equal([]string{ "vpc", @@ -97,16 +97,16 @@ var _ = Describe("NetworkingStack", func() { "subnetAZC", })) g.Expect(createdRG.Status.Conditions).To(HaveLen(3)) - g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeReconcilerReady)) + g.Expect(createdRG.Status.Conditions[0].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeReconcilerReady)) g.Expect(createdRG.Status.Conditions[0].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGroupConditionTypeGraphVerified)) + g.Expect(createdRG.Status.Conditions[1].Type).To(Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeGraphVerified)) g.Expect(createdRG.Status.Conditions[1].Status).To(Equal(metav1.ConditionTrue)) g.Expect(createdRG.Status.Conditions[2].Type).To( - Equal(krov1alpha1.ResourceGroupConditionTypeCustomResourceDefinitionSynced), + Equal(krov1alpha1.ResourceGraphDefinitionConditionTypeCustomResourceDefinitionSynced), ) g.Expect(createdRG.Status.Conditions[2].Status).To(Equal(metav1.ConditionTrue)) - g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGroupStateActive)) + g.Expect(createdRG.Status.State).To(Equal(krov1alpha1.ResourceGraphDefinitionStateActive)) }, 10*time.Second, time.Second).Should(Succeed()) // Create instance @@ -258,15 +258,15 @@ var _ = Describe("NetworkingStack", func() { return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) - // Delete ResourceGroup + // Delete ResourceGraphDefinition Expect(env.Client.Delete(ctx, rg)).To(Succeed()) - // Verify ResourceGroup is deleted + // Verify ResourceGraphDefinition is deleted Eventually(func() bool { err := env.Client.Get(ctx, types.NamespacedName{ Name: rg.Name, Namespace: namespace, - }, &krov1alpha1.ResourceGroup{}) + }, &krov1alpha1.ResourceGraphDefinition{}) return errors.IsNotFound(err) }, 20*time.Second, time.Second).Should(BeTrue()) diff --git a/website/docs/api/out.md b/website/docs/api/out.md index 73fb037d..07bd90f4 100644 --- a/website/docs/api/out.md +++ b/website/docs/api/out.md @@ -1,5 +1,5 @@ --- -sidebar_label: "ResourceGroup API" +sidebar_label: "ResourceGraphDefinition API" sidebar_position: 100 --- @@ -15,8 +15,8 @@ Package v1alpha1 contains API Schema definitions for the x v1alpha1 API group ### Resource Types -- [ResourceGroup](#resourcegroup) -- [ResourceGroupList](#resourcegrouplist) +- [ResourceGraphDefinition](#resourcegraphdefinition) +- [ResourceGraphDefinitionList](#resourcegraphdefinitionlist) #### Condition @@ -26,7 +26,7 @@ API resource _Appears in:_ -- [ResourceGroupStatus](#resourcegroupstatus) +- [ResourceGraphDefinitionStatus](#resourcegraphdefinitionstatus) | Field | Description | Default | Validation | | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ----------------- | @@ -49,7 +49,7 @@ _Appears in:_ _Appears in:_ -- [ResourceGroupSpec](#resourcegroupspec) +- [ResourceGraphDefinitionSpec](#resourcegraphdefinitionspec) | Field | Description | Default | Validation | | ---------------------------------------- | ----------- | ------- | ---------- | @@ -62,51 +62,51 @@ _Appears in:_ _Appears in:_ -- [ResourceGroupSpec](#resourcegroupspec) +- [ResourceGraphDefinitionSpec](#resourcegraphdefinitionspec) | Field | Description | Default | Validation | | -------------------------------------------- | ----------- | ------- | ------------------- | | `name` _string_ | | | Required: {}
| | `definition` _[RawExtension](#rawextension)_ | | | Required: {}
| -#### ResourceGroup +#### ResourceGraphDefinition -ResourceGroup is the Schema for the resourcegroups API +ResourceGraphDefinition is the Schema for the resourcegraphdefinitions API _Appears in:_ -- [ResourceGroupList](#resourcegrouplist) +- [ResourceGraphDefinitionList](#resourcegraphdefinitionlist) | Field | Description | Default | Validation | | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ---------- | | `apiVersion` _string_ | `kro.run/v1alpha1` | | | -| `kind` _string_ | `ResourceGroup` | | | +| `kind` _string_ | `ResourceGraphDefinition` | | | | `kind` _string_ | Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | | | | `apiVersion` _string_ | APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | | | | `metadata` _[ObjectMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.3/#objectmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | -| `spec` _[ResourceGroupSpec](#resourcegroupspec)_ | | | | -| `status` _[ResourceGroupStatus](#resourcegroupstatus)_ | | | | +| `spec` _[ResourceGraphDefinitionSpec](#resourcegraphdefinitionspec)_ | | | | +| `status` _[ResourceGraphDefinitionStatus](#resourcegraphdefinitionstatus)_ | | | | -#### ResourceGroupList +#### ResourceGraphDefinitionList -ResourceGroupList contains a list of ResourceGroup +ResourceGraphDefinitionList contains a list of ResourceGraphDefinition | Field | Description | Default | Validation | | ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ---------- | | `apiVersion` _string_ | `kro.run/v1alpha1` | | | -| `kind` _string_ | `ResourceGroupList` | | | +| `kind` _string_ | `ResourceGraphDefinitionList` | | | | `kind` _string_ | Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | | | | `apiVersion` _string_ | APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | | | | `metadata` _[ListMeta](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.3/#listmeta-v1-meta)_ | Refer to Kubernetes API documentation for fields of `metadata`. | | | -| `items` _[ResourceGroup](#resourcegroup) array_ | | | | +| `items` _[ResourceGraphDefinition](#resourcegraphdefinition) array_ | | | | -#### ResourceGroupSpec +#### ResourceGraphDefinitionSpec -ResourceGroupSpec defines the desired state of ResourceGroup +ResourceGraphDefinitionSpec defines the desired state of ResourceGraphDefinition _Appears in:_ -- [ResourceGroup](#resourcegroup) +- [ResourceGraphDefinition](#resourcegraphdefinition) | Field | Description | Default | Validation | | ----------------------------------------- | ----------- | ------- | ------------------- | @@ -115,24 +115,24 @@ _Appears in:_ | `definition` _[Definition](#definition)_ | | | Required: {}
| | `resources` _[Resource](#resource) array_ | | | Optional: {}
| -#### ResourceGroupState +#### ResourceGraphDefinitionState _Underlying type:_ _string_ _Appears in:_ -- [ResourceGroupStatus](#resourcegroupstatus) +- [ResourceGraphDefinitionStatus](#resourcegraphdefinitionstatus) -#### ResourceGroupStatus +#### ResourceGraphDefinitionStatus -ResourceGroupStatus defines the observed state of ResourceGroup +ResourceGraphDefinitionStatus defines the observed state of ResourceGraphDefinition _Appears in:_ -- [ResourceGroup](#resourcegroup) +- [ResourceGraphDefinition](#resourcegraphdefinition) | Field | Description | Default | Validation | | --------------------------------------------------- | --------------------------------------------------------------------------- | ------- | ---------- | -| `state` _[ResourceGroupState](#resourcegroupstate)_ | State is the state of the resourcegroup | | | -| `topologicalOrder` _string array_ | TopologicalOrder is the topological order of the resourcegroup graph | | | +| `state` _[ResourceGraphDefinitionState](#resourcegraphdefinitionstate)_ | State is the state of the resourcegraphdefinition | | | +| `topologicalOrder` _string array_ | TopologicalOrder is the topological order of the resourcegraphdefinition graph | | | | `conditions` _[Condition](#condition) array_ | Conditions represent the latest available observations of an object's state | | | diff --git a/website/docs/docs/concepts/00-resource-groups.md b/website/docs/docs/concepts/00-resource-groups.md index ca91acdd..89884a31 100644 --- a/website/docs/docs/concepts/00-resource-groups.md +++ b/website/docs/docs/concepts/00-resource-groups.md @@ -2,15 +2,15 @@ sidebar_position: 1 --- -# ResourceGroups +# ResourceGraphDefinitions -ResourceGroups are the fundamental building blocks in **kro**. They provide a +ResourceGraphDefinitions are the fundamental building blocks in **kro**. They provide a way to define, organize, and manage sets of related Kubernetes resources as a single, reusable unit. -## What is a ResourceGroup? +## What is a ResourceGraphDefinition? -A **ResourceGroup** is a custom resource that lets you create new Kubernetes +A **ResourceGraphDefinition** is a custom resource that lets you create new Kubernetes APIs for deploying multiple resources together. It acts as a blueprint, defining: @@ -20,19 +20,19 @@ defining: - When resources should be included (conditions) - What status to expose (status) -When you create a **ResourceGroup**, kro generates a new API (a.k.a Custom +When you create a **ResourceGraphDefinition**, kro generates a new API (a.k.a Custom Resource Defintion) in your cluster that others can use to deploy resources in a consistent, controlled way. -## Anatomy of a ResourceGroup +## Anatomy of a ResourceGraphDefinition -A ResourceGroup, like any Kubernetes resource, consists of three main parts: +A ResourceGraphDefinition, like any Kubernetes resource, consists of three main parts: 1. **Metadata**: name, namespace, labels, etc. -2. **Spec**: Defines the structure and properties of the ResourceGroup -3. **Status**: Reflects the current state of the ResourceGroup +2. **Spec**: Defines the structure and properties of the ResourceGraphDefinition +3. **Status**: Reflects the current state of the ResourceGraphDefinition -The `spec` section of a ResourceGroup contains two main components: +The `spec` section of a ResourceGraphDefinition contains two main components: - **Schema**: Defines what an instance of your API looks like: - What users can configure during creation and update @@ -48,9 +48,9 @@ This structure translates to YAML as follows: ```yaml apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: - name: my-resourcegroup # Metadata section + name: my-resourcegraphdefinition # Metadata section spec: schema: # Define your API apiVersion: v1alpha1 # API version @@ -101,19 +101,19 @@ leverages a human-friendly and readable syntax that is OpenAPI spec compatible. No need to write complex OpenAPI schemas - just define your fields and types in a straightforward way. For the complete specification of this format, check out the [Simple Schema specification](./10-simple-schema.md). Status fields use CEL -expressions to reference fields from resources defined in your ResourceGroup. +expressions to reference fields from resources defined in your ResourceGraphDefinition. kro automatically: - Infers the correct types from your expressions - Validates that referenced resources exist - Updates these fields as your resources change -## ResourceGroup Processing +## ResourceGraphDefinition Processing -When you create a **ResourceGroup**, kro processes it in several steps to ensure +When you create a **ResourceGraphDefinition**, kro processes it in several steps to ensure correctness and set up the necessary components: -1. **Validation**: kro validates your **ResourceGroup** to ensure it's well +1. **Validation**: kro validates your **ResourceGraphDefinition** to ensure it's well formed and follows the correct syntax, maximizing the chances of successful deployment, and catching as many errors as possible early on. It: @@ -125,7 +125,7 @@ correctness and set up the necessary components: - Validates all CEL expressions in status fields and conditions 2. **API Generation**: kro generates and registers a new CRD in your cluster - based on your schema. For example, if your **ResourceGroup** defines a + based on your schema. For example, if your **ResourceGraphDefinition** defines a `WebApplication` API, kro creates a CRD that: - Provides API validation based on your schema definition @@ -141,17 +141,17 @@ correctness and set up the necessary components: - Handles the complete lifecycle for create, update, and delete operations - Keeps status information up to date based on actual resource states -For instance, when you create a `WebApplication` ResourceGroup, kro generates +For instance, when you create a `WebApplication` ResourceGraphDefinition, kro generates the `webapplications.kro.run` CRD. When users create instances of this API, kro manages all the underlying resources (Deployments, Services, Custom Resources, etc.) automatically. -kro continuously monitors your ResourceGroup for changes, updating the API and +kro continuously monitors your ResourceGraphDefinition for changes, updating the API and its behavior accordingly. -## ResourceGroup Instance Example +## ResourceGraphDefinition Instance Example -After the **ResourceGroup** is validated and registered in the cluster, users +After the **ResourceGraphDefinition** is validated and registered in the cluster, users can can create instances of it. Here's an example of how an instance for the `SimpleWebApp` might look: diff --git a/website/docs/docs/concepts/10-simple-schema.md b/website/docs/docs/concepts/10-simple-schema.md index 10ed828a..62db74fd 100644 --- a/website/docs/docs/concepts/10-simple-schema.md +++ b/website/docs/docs/concepts/10-simple-schema.md @@ -10,7 +10,7 @@ compatible. Here's a comprehensive example: ```yaml apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: web-application spec: diff --git a/website/docs/docs/concepts/15-instances.md b/website/docs/docs/concepts/15-instances.md index 2f119b5e..eb9f5754 100644 --- a/website/docs/docs/concepts/15-instances.md +++ b/website/docs/docs/concepts/15-instances.md @@ -4,7 +4,7 @@ sidebar_position: 15 # Instances -Once **kro** processes your ResourceGroup, it creates a new API in your cluster. +Once **kro** processes your ResourceGraphDefinition, it creates a new API in your cluster. Users can then create instances of this API to deploy resources in a consistent, controlled way. @@ -95,7 +95,7 @@ Every instance includes: - `Error`: Problems detected 3. **Resource Status**: Status from your resources - - Values you defined in your ResourceGroup's status section + - Values you defined in your ResourceGraphDefinition's status section - Automatically updated as resources change ## Best Practices diff --git a/website/docs/docs/faq.md b/website/docs/docs/faq.md index 414bcd9f..3ce0eeb1 100644 --- a/website/docs/docs/faq.md +++ b/website/docs/docs/faq.md @@ -10,27 +10,27 @@ sidebar_position: 100 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 + 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 + 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 + customization, and dependency management simpler. 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. + 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_ + 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. @@ -41,7 +41,7 @@ sidebar_position: 100 _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 + 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. @@ -66,7 +66,7 @@ sidebar_position: 100 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 + use. 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)?** diff --git a/website/docs/docs/getting-started/01-Installation.md b/website/docs/docs/getting-started/01-Installation.md index b1445c3e..2c5c8077 100644 --- a/website/docs/docs/getting-started/01-Installation.md +++ b/website/docs/docs/getting-started/01-Installation.md @@ -106,5 +106,5 @@ helm uninstall kro -n kro ``` Keep in mind that this command will remove all kro resources from your cluster, -except for the ResourceGroup CRD and any other custom resources you may have +except for the ResourceGraphDefinition CRD and any other custom resources you may have created. diff --git a/website/docs/docs/getting-started/02-deploy-a-resource-group.md b/website/docs/docs/getting-started/02-deploy-a-resource-group.md index 93c673ae..23907f4d 100644 --- a/website/docs/docs/getting-started/02-deploy-a-resource-group.md +++ b/website/docs/docs/getting-started/02-deploy-a-resource-group.md @@ -2,21 +2,21 @@ sidebar_position: 2 --- -# Deploy Your First ResourceGroup +# Deploy Your First ResourceGraphDefinition This guide will walk you through creating your first Resource Group in **kro**. -We'll create a simple `ResourceGroup` that demonstrates key kro features. +We'll create a simple `ResourceGraphDefinition` that demonstrates key kro features. -## What is a **ResourceGroup**? +## What is a **ResourceGraphDefinition**? -A `ResourceGroup` lets you create new Kubernetes APIs that deploy multiple +A `ResourceGraphDefinition` lets you create new Kubernetes APIs that deploy multiple resources together as a single, reusable unit. In this example, we’ll create a -`ResourceGroup` that packages a reusable set of resources, including a +`ResourceGraphDefinition` that packages a reusable set of resources, including a `Deployment`, `Service`, and `Ingress`. These resources are available in any Kubernetes cluster. Users can then call the API to deploy resources as a single unit, ensuring they're always created together with the right configuration. -Under the hood, when you create a `ResourceGroup`, kro: +Under the hood, when you create a `ResourceGraphDefinition`, kro: 1. Treats your resources as a Directed Acyclic Graph (DAG) to understand their dependencies @@ -32,14 +32,14 @@ Before you begin, make sure you have the following: cluster. - `kubectl` installed and configured to interact with your Kubernetes cluster. -## Create your Application ResourceGroup +## Create your Application ResourceGraphDefinition Let's create a Resource Group that combines a `Deployment`, a `Service` and -`Ingress`. Save this as `resourcegroup.yaml`: +`Ingress`. Save this as `resourcegraphdefinition.yaml`: -```yaml title="resourcegroup.yaml" +```yaml title="resourcegraphdefinition.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: my-application spec: @@ -124,26 +124,26 @@ spec: number: 80 ``` -### Deploy the ResourceGroup +### Deploy the ResourceGraphDefinition -1. **Create a ResourceGroup manifest file**: Create a new file with the - `ResourceGroup` definition. You can use the example above. +1. **Create a ResourceGraphDefinition manifest file**: Create a new file with the + `ResourceGraphDefinition` definition. You can use the example above. -2. **Apply the `ResourceGroup`**: Use the `kubectl` command to deploy the - ResourceGroup to your Kubernetes cluster: +2. **Apply the `ResourceGraphDefinition`**: Use the `kubectl` command to deploy the + ResourceGraphDefinition to your Kubernetes cluster: ```bash - kubectl apply -f resourcegroup.yaml + kubectl apply -f resourcegraphdefinition.yaml ``` -3. **Inpsect the `ResourceGroup`**: Check the status of the resources created by - the ResourceGroup using the `kubectl` command: +3. **Inpsect the `ResourceGraphDefinition`**: Check the status of the resources created by + the ResourceGraphDefinition using the `kubectl` command: ```bash kubectl get rg my-application -owide ``` - You should see the ResourceGroup in the `Active` state, along with relevant + You should see the ResourceGraphDefinition in the `Active` state, along with relevant information to help you understand your application: ```bash @@ -153,7 +153,7 @@ spec: ### Create your Application Instance -Now that your `ResourceGroup` is created, kro has generated a new API +Now that your `ResourceGraphDefinition` is created, kro has generated a new API (Application) that orchestrates creation of the a `Deployment`, a `Service`, and an `Ingress`. Let's use it! diff --git a/website/docs/docs/overview.md b/website/docs/docs/overview.md index 51e427cc..a861bc6a 100644 --- a/website/docs/docs/overview.md +++ b/website/docs/docs/overview.md @@ -39,12 +39,12 @@ _Fugure 1: End user interface - Custom API_ -### ResourceGroup +### ResourceGraphDefinition When you install **Kro** in your cluster, it installs a Custom Resource -Definition (CRD) called **ResourceGroup (RG)**. The **Platform**, **Security**, +Definition (CRD) called **ResourceGraphDefinition (RG)**. The **Platform**, **Security**, and **Compliance** teams, can collaborate to create custom APIs by defining -Custom Resources for the ResourceGroup CRD. +Custom Resources for the ResourceGraphDefinition CRD. In the depicted example, the **Platform Team** has created a **RG** with arbitrary name "Application Stack" that encapsulates the necessary resources, @@ -57,11 +57,11 @@ handles the deployment and configuration of the required resources.
![Platform Team Interface](../../../images/architecture-diagrams/KRO-Platform-Team.png) -_Fugure 2: ResourceGroup (RG) - Platform Team Interface_ +_Fugure 2: ResourceGraphDefinition (RG) - Platform Team Interface_
-### ResourceGroup Instance +### ResourceGraphDefinition Instance Developer teams can create multiple instances of the **Application Stack**, each tailored to their specific requirements. As shown, **Dev Team A** and **Dev Team @@ -74,8 +74,8 @@ requirements.
-![ResourceGroup Instance](../../../images/architecture-diagrams/KRO-Instance.png) -_Fugure 3: ResourceGroup Instance (RGI)_ +![ResourceGraphDefinition Instance](../../../images/architecture-diagrams/KRO-Instance.png) +_Fugure 3: ResourceGraphDefinition Instance (RGI)_
diff --git a/website/docs/examples/ack-eks-cluster.md b/website/docs/examples/ack-eks-cluster.md index e3d7d245..39ea5b66 100644 --- a/website/docs/examples/ack-eks-cluster.md +++ b/website/docs/examples/ack-eks-cluster.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="eks.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscluster.kro.run spec: diff --git a/website/docs/examples/ack-networking-stack.md b/website/docs/examples/ack-networking-stack.md index 4270bad6..def8a3ef 100644 --- a/website/docs/examples/ack-networking-stack.md +++ b/website/docs/examples/ack-networking-stack.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="networking-stack.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: networkingstack.kro.run spec: diff --git a/website/docs/examples/ack-valkey-cachecluster.md b/website/docs/examples/ack-valkey-cachecluster.md index a139e84c..f5b76eba 100644 --- a/website/docs/examples/ack-valkey-cachecluster.md +++ b/website/docs/examples/ack-valkey-cachecluster.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="valkey-cachecluster.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: valkey.kro.run spec: diff --git a/website/docs/examples/deploying-controller.md b/website/docs/examples/deploying-controller.md index 5c38f969..3d0e4c45 100644 --- a/website/docs/examples/deploying-controller.md +++ b/website/docs/examples/deploying-controller.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="controller-rg.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: ekscontrollers.kro.run spec: diff --git a/website/docs/examples/deploying-coredns.md b/website/docs/examples/deploying-coredns.md index e99e4304..d10d6547 100644 --- a/website/docs/examples/deploying-coredns.md +++ b/website/docs/examples/deploying-coredns.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="coredns-rg.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: coredns.kro.run spec: diff --git a/website/docs/examples/examples.md b/website/docs/examples/examples.md index 299e59bf..dfdd4401 100644 --- a/website/docs/examples/examples.md +++ b/website/docs/examples/examples.md @@ -5,14 +5,14 @@ sidebar_position: 0 # Examples This section provides a collection of examples demonstrating how to define and -use ResourceGroups in **kro** for various scenarios. Each example showcases a +use ResourceGraphDefinitions in **kro** for various scenarios. Each example showcases a specific use case and includes a detailed explanation along with the corresponding YAML definitions. ## Basic Examples -- [Empty ResourceGroup (Noop)](./noop.md) Explore the simplest form of a - ResourceGroup that doesn't define any resources, serving as a reference for +- [Empty ResourceGraphDefinition (Noop)](./noop.md) Explore the simplest form of a + ResourceGraphDefinition that doesn't define any resources, serving as a reference for the basic structure. - [Simple Web Application](./web-app.md) Deploy a basic web application with a @@ -25,25 +25,25 @@ corresponding YAML definitions. ## Advanced Examples - [Deploying CoreDNS](./deploying-coredns.md) Learn how to deploy CoreDNS in a - Kubernetes cluster using kro ResourceGroups, including the necessary + Kubernetes cluster using kro ResourceGraphDefinitions, including the necessary Deployment, Service, and ConfigMap. - [Deploying a Controller](./deploying-controller.md) Discover how to deploy a - Kubernetes controller using kro ResourceGroups, including the necessary + Kubernetes controller using kro ResourceGraphDefinitions, including the necessary Deployment, ServiceAccount, and CRDs. - [AWS Networking Stack](./ack-networking-stack.md) Learn how to define and - manage an AWS networking stack using kro ResourceGroups, including VPCs, + manage an AWS networking stack using kro ResourceGraphDefinitions, including VPCs, subnets, and security groups. - [EKS Cluster with ACK CRDs](./ack-eks-cluster.md) Explore how to define and manage an EKS cluster using AWS Controllers for Kubernetes (ACK) CRDs within a - kro ResourceGroup. + kro ResourceGraphDefinition. - [Valkey CacheCluster with ACK CRDs](./ack-valkey-cachecluster.md) Learn how to create and configure a Valkey CacheCluster using ACK CRDs in a kro - ResourceGroup. + ResourceGraphDefinition. - [Pod and RDS DBInstance](./pod-rds-dbinstance.md) Deploy a Pod and an RDS - DBInstance in a kro ResourceGroup, showcasing the use of multiple resources + DBInstance in a kro ResourceGraphDefinition, showcasing the use of multiple resources with dependencies. diff --git a/website/docs/examples/noop.md b/website/docs/examples/noop.md index 81da2c0c..fd4b3214 100644 --- a/website/docs/examples/noop.md +++ b/website/docs/examples/noop.md @@ -2,11 +2,11 @@ sidebar_position: 5 --- -# Empty ResourceGroup +# Empty ResourceGraphDefinition ```yaml title="noop.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: kro.run/v1alpha1 spec: diff --git a/website/docs/examples/pod-rds-dbinstance.md b/website/docs/examples/pod-rds-dbinstance.md index e2cbf916..9fba4b43 100644 --- a/website/docs/examples/pod-rds-dbinstance.md +++ b/website/docs/examples/pod-rds-dbinstance.md @@ -6,7 +6,7 @@ sidebar_position: 20 ```yaml title="deploymentdbinstance-rg.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: deploymentandawspostgres spec: diff --git a/website/docs/examples/web-app-ingress.md b/website/docs/examples/web-app-ingress.md index ad054e39..a62430a4 100644 --- a/website/docs/examples/web-app-ingress.md +++ b/website/docs/examples/web-app-ingress.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="webapp-ingress.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: my-application spec: diff --git a/website/docs/examples/web-app.md b/website/docs/examples/web-app.md index 747f2bdb..90b8215b 100644 --- a/website/docs/examples/web-app.md +++ b/website/docs/examples/web-app.md @@ -6,7 +6,7 @@ sidebar_position: 10 ```yaml title="deploymentservice-rg.yaml" apiVersion: kro.run/v1alpha1 -kind: ResourceGroup +kind: ResourceGraphDefinition metadata: name: deploymentservice spec: