Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClusterPool Inventory #1672

Merged
merged 27 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
37bec88
ClusterPool Inventory
abraverm Jan 2, 2022
b5c84d6
Fixes and improvements based on feedback
abraverm Apr 20, 2022
aad3a77
custom-resource-status
abraverm Apr 25, 2022
90380da
More fixes
abraverm Apr 28, 2022
6854171
Refactor to collections
abraverm May 1, 2022
769cca3
Unit tests
abraverm May 3, 2022
9db55fa
ApplySucceeded condition
abraverm May 11, 2022
9487de4
Fixes based on latest review
abraverm May 12, 2022
f4d21fc
All comments applied
abraverm May 15, 2022
033d978
More fixes and e2e test
abraverm May 29, 2022
b86b1f2
rebase
abraverm May 30, 2022
8c79fed
Another fix
abraverm Jun 8, 2022
97986dc
e2e: save clusterpool and customizations
abraverm Jun 8, 2022
15f9867
e2e: fix typos
abraverm Jun 9, 2022
ec54e1d
e2e: merge customization with original pool, revert unassigned to a list
abraverm Jun 14, 2022
a4158bd
fix rebase
abraverm Jun 18, 2022
8f4fb18
e2e: customize REAL POOL after creation of FAKE POOL
abraverm Jun 18, 2022
4fddbe7
e2e:random name for the new cluster
abraverm Jun 23, 2022
97da831
fix indentation and fail Reserve if not changed
abraverm Jun 24, 2022
cf5e4e0
Add support for ovirt and vshpere
abraverm Jul 5, 2022
8fa20e2
Remove hibernation change, update roles, fix cdc deletion process and…
abraverm Jul 25, 2022
229237f
Unique finalizer per clusterpool
abraverm Jul 26, 2022
47161f7
Remove unsupported hibernation check and fix rebase
abraverm Jul 26, 2022
af52c84
Fix finalizer name
abraverm Jul 26, 2022
f7ef0bf
Fix finalizer process
abraverm Jul 26, 2022
5f0fd62
Fix tests
abraverm Aug 1, 2022
1786bbc
Fix verify
abraverm Aug 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
github.com/openshift/api v0.0.0-20220531073726-6c4f186339a7
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87
k8s.io/api v0.24.1
k8s.io/apimachinery v0.24.1
)
Expand Down
46 changes: 45 additions & 1 deletion apis/go.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions apis/hive/v1/clusterdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ type ClusterPoolReference struct {
// ClaimedTimestamp is the time this cluster was assigned to a ClusterClaim. This is only used for
// ClusterDeployments belonging to ClusterPools.
ClaimedTimestamp *metav1.Time `json:"claimedTimestamp,omitempty"`
// CustomizationRef is the ClusterPool Inventory claimed customization for this ClusterDeployment.
// The Customization exists in the ClusterPool namespace.
// +optional
CustomizationRef *corev1.LocalObjectReference `json:"clusterDeploymentCustomization,omitempty"`
}

// ClusterMetadata contains metadata information about the installed cluster.
Expand Down
99 changes: 99 additions & 0 deletions apis/hive/v1/clusterdeploymentcustomization_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package v1

import (
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

2uasimojo marked this conversation as resolved.
Show resolved Hide resolved
const (
// CustomizationApplyReasonSucceeded indicates that the customization
// worked properly on the last applied cluster deployment.
CustomizationApplyReasonSucceeded = "Succeeded"
// CustomizationApplyReasonBrokenSyntax indicates that Hive failed to apply
// customization patches on install-config. More details would be found in
// ApplySucceded condition message.
CustomizationApplyReasonBrokenSyntax = "BrokenBySyntax"
// CustomizationApplyReasonBrokenCloud indicates that cluster deployment provision has failed
// when using this customization. More details would be found in the ApplySucceeded condition message.
CustomizationApplyReasonBrokenCloud = "BrokenByCloud"
// CustomizationApplyReasonInstallationPending indicates that the customization patches have
// been successfully applied but provisioning is not completed yet.
CustomizationApplyReasonInstallationPending = "InstallationPending"
)

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterDeploymentCustomization is the Schema for clusterdeploymentcustomizations API.
// +kubebuilder:subresource:status
// +k8s:openapi-gen=true
// +kubebuilder:resource:scope=Namespaced
type ClusterDeploymentCustomization struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ClusterDeploymentCustomizationSpec `json:"spec"`
Status ClusterDeploymentCustomizationStatus `json:"status,omitempty"`
}

// ClusterDeploymentCustomizationSpec defines the desired state of ClusterDeploymentCustomization.
type ClusterDeploymentCustomizationSpec struct {
// InstallConfigPatches is a list of patches to be applied to the install-config.
InstallConfigPatches []PatchEntity `json:"installConfigPatches,omitempty"`
}

// PatchEntity represent a json patch (RFC 6902) to be applied to the install-config
type PatchEntity struct {
2uasimojo marked this conversation as resolved.
Show resolved Hide resolved
// Op is the operation to perform: add, remove, replace, move, copy, test
// +required
Op string `json:"op"`
// Path is the json path to the value to be modified
// +required
Path string `json:"path"`
// From is the json path to copy or move the value from
// +optional
From string `json:"from,omitempty"`
// Value is the value to be used in the operation
// +required
Value string `json:"value"`
}

// ClusterDeploymentCustomizationStatus defines the observed state of ClusterDeploymentCustomization.
type ClusterDeploymentCustomizationStatus struct {
// ClusterDeploymentRef is a reference to the cluster deployment that this customization is applied on.
// +optional
ClusterDeploymentRef *corev1.LocalObjectReference `json:"clusterDeploymentRef,omitempty"`

// ClusterPoolRef is the name of the current cluster pool the CDC used at.
// +optional
ClusterPoolRef *corev1.LocalObjectReference `json:"clusterPoolRef,omitempty"`

// LastAppliedConfiguration contains the last applied patches to the install-config.
2uasimojo marked this conversation as resolved.
Show resolved Hide resolved
// The information will retain for reference in case the customization is updated.
// +optional
LastAppliedConfiguration string `json:"lastAppliedConfiguration,omitempty"`

// Conditions describes the state of the operator's reconciliation functionality.
// +patchMergeKey=type
// +patchStrategy=merge
// +optional
Conditions []conditionsv1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}

const (
ApplySucceededCondition conditionsv1.ConditionType = "ApplySucceeded"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterDeploymentCustomizationList contains a list of ClusterDeploymentCustomizations.
type ClusterDeploymentCustomizationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterDeploymentCustomization `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterDeploymentCustomization{}, &ClusterDeploymentCustomizationList{})
}
32 changes: 32 additions & 0 deletions apis/hive/v1/clusterpool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ type ClusterPoolSpec struct {
// HibernationConfig configures the hibernation/resume behavior of ClusterDeployments owned by the ClusterPool.
// +optional
HibernationConfig *HibernationConfig `json:"hibernationConfig"`

// Inventory maintains a list of entries consumed by the ClusterPool
// to customize the default ClusterDeployment.
// +optional
Inventory []InventoryEntry `json:"inventory,omitempty"`
}

type HibernationConfig struct {
Expand All @@ -110,6 +115,22 @@ type HibernationConfig struct {
ResumeTimeout metav1.Duration `json:"resumeTimeout"`
}

// InventoryEntryKind is the Kind of the inventory entry.
// +kubebuilder:validation:Enum="";ClusterDeploymentCustomization
type InventoryEntryKind string

const ClusterDeploymentCustomizationInventoryEntry InventoryEntryKind = "ClusterDeploymentCustomization"

// InventoryEntry maintains a reference to a custom resource consumed by a clusterpool to customize the cluster deployment.
type InventoryEntry struct {
// Kind denotes the kind of the referenced resource. The default is ClusterDeploymentCustomization, which is also currently the only supported value.
// +kubebuilder:default=ClusterDeploymentCustomization
2uasimojo marked this conversation as resolved.
Show resolved Hide resolved
Kind InventoryEntryKind `json:"kind,omitempty"`
// Name is the name of the referenced resource.
// +required
Name string `json:"name,omitempty"`
}

// ClusterPoolClaimLifetime defines the lifetimes for claims for the cluster pool.
type ClusterPoolClaimLifetime struct {
// Default is the default lifetime of the claim when no lifetime is set on the claim itself.
Expand Down Expand Up @@ -197,6 +218,17 @@ const (
// ClusterPoolAllClustersCurrentCondition indicates whether all unassigned (installing or ready)
// ClusterDeployments in the pool match the current configuration of the ClusterPool.
ClusterPoolAllClustersCurrentCondition ClusterPoolConditionType = "AllClustersCurrent"
// ClusterPoolInventoryValidCondition is set to provide information on whether the cluster pool inventory is valid
ClusterPoolInventoryValidCondition ClusterPoolConditionType = "InventoryValid"
)

const (
// InventoryReasonValid is used when all ClusterDeploymentCustomization are
// available and when used the ClusterDeployments are successfully installed.
InventoryReasonValid = "Valid"
// InventoryReasonInvalid is used when there is something wrong with ClusterDeploymentCustomization, for example
// patching issue, provisioning failure, missing, etc.
InventoryReasonInvalid = "Invalid"
)

// +genclient
Expand Down
158 changes: 158 additions & 0 deletions apis/hive/v1/zz_generated.deepcopy.go

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

Loading