Documentation ¶
Index ¶
- Constants
- type Component
- type Condition
- type ConditionStatus
- type ConditionType
- type HookFunc
- type ImageSpec
- type IngressProperties
- type InventoryItem
- func (in *InventoryItem) DeepCopy() *InventoryItem
- func (in *InventoryItem) DeepCopyInto(out *InventoryItem)
- func (i InventoryItem) GetName() string
- func (i InventoryItem) GetNamespace() string
- func (i *InventoryItem) GetObjectKind() schema.ObjectKind
- func (i InventoryItem) GroupVersionKind() schema.GroupVersionKind
- func (i InventoryItem) Matches(key types.ObjectKey) bool
- func (i *InventoryItem) SetGroupVersionKind(gvk schema.GroupVersionKind)
- func (i InventoryItem) String() string
- type KubernetesContainerProperties
- type KubernetesPodProperties
- type KubernetesProperties
- type NameInfo
- type Reconciler
- func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error)
- func (r *Reconciler[T]) SetupWithManager(mgr ctrl.Manager) error
- func (r *Reconciler[T]) WithPostDeleteHook(hook HookFunc[T]) *Reconciler[T]
- func (r *Reconciler[T]) WithPostReadHook(hook HookFunc[T]) *Reconciler[T]
- func (r *Reconciler[T]) WithPostReconcileHook(hook HookFunc[T]) *Reconciler[T]
- func (r *Reconciler[T]) WithPreDeleteHook(hook HookFunc[T]) *Reconciler[T]
- func (r *Reconciler[T]) WithPreReconcileHook(hook HookFunc[T]) *Reconciler[T]
- type ServiceProperties
- type Spec
- type State
- type Status
- type TypeInfo
Constants ¶
const ( PhaseScheduledForApplication = "ScheduledForApplication" PhaseScheduledForDeletion = "ScheduledForDeletion" PhaseScheduledForCompletion = "ScheduledForCompletion" PhaseCreating = "Creating" PhaseUpdating = "Updating" PhaseDeleting = "Deleting" PhaseCompleting = "Completing" PhaseReady = "Ready" PhaseCompleted = "Completed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface { client.Object // Return target namespace for the component deployment. // This is the value that will be passed to Generator.Generate() as namespace. // In addition, rendered namespaced resources without namespace will be placed in this namespace. GetDeploymentNamespace() string // Return target name for the component deployment. // This is the value that will be passed to Generator.Generator() as name. GetDeploymentName() string // Return a pointer accessor to the component's spec. // Which, as a consequence, obviously has to implement the types.Unstructurable interface. GetSpec() types.Unstructurable // Return a pointer accessor to the component's status, // resp. to the corresponding sub-struct if the status extends component.Status. GetStatus() *Status }
Component is the central interface that component operators have to implement. Besides being a conroller-runtime client.Object, the implmenting type has to include the Spec and Status structs defined in this package, and has to define according accessor methods, called GetComponentSpec() and GetComponentStatus(). In addition it has to expose its whole spec and status as Unstructurable objects, via methods GetSpec() and GetStatus().
type Condition ¶
type Condition struct { Type ConditionType `json:"type"` // +kubebuilder:validation:Enum=True;False;Unknown Status ConditionStatus `json:"status"` // +optional LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"` // +optional Reason string `json:"reason,omitempty"` // +optional Message string `json:"message,omitempty"` }
Component status Condition.
func (*Condition) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition.
func (*Condition) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ConditionStatus ¶
type ConditionStatus string
Condition Status. Can be one of 'True', 'False', 'Unknown'.
const ( // Condition status 'True'. ConditionTrue ConditionStatus = "True" // Condition status 'False'. ConditionFalse ConditionStatus = "False" // Condition status 'Unknown'. ConditionUnknown ConditionStatus = "Unknown" )
type ConditionType ¶
type ConditionType string
Condition type. Currently, only the 'Ready' type is used.
const ( // Condition type representing the 'Ready' condition. ConditionTypeReady ConditionType = "Ready" )
type HookFunc ¶
HookFunc is the function signature that can be used to establish callbacks at certain points in the reconciliation logic. Hooks will be passed the current (potentially unsaved) state of the component. Post-hooks will only be called if the previous operator (read, reconcile, delete) has been successful.
type ImageSpec ¶
type ImageSpec struct { // +kubebuilder:validation:MinLength=1 Repository string `json:"repository,omitempty"` // +kubebuilder:validation:MinLength=1 Tag string `json:"tag,omitempty"` // +kubebuilder:validation:Enum=Always;Never;IfNotPresent // +kubebuilder:default=IfNotPresent PullPolicy string `json:"pullPolicy,omitempty"` PullSecret string `json:"pullSecret,omitempty"` }
ImageSpec defines the used OCI image
func (*ImageSpec) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSpec.
func (*ImageSpec) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type IngressProperties ¶
type IngressProperties struct { Class string `json:"class,omitempty"` Labels map[string]string `json:"labels,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` }
IngressProperties defines K8s properties to be applied to a managed ingress resource.
func (*IngressProperties) DeepCopy ¶
func (in *IngressProperties) DeepCopy() *IngressProperties
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressProperties.
func (*IngressProperties) DeepCopyInto ¶
func (in *IngressProperties) DeepCopyInto(out *IngressProperties)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type InventoryItem ¶
type InventoryItem struct { // Type of the dependent object. TypeInfo `json:",inline"` // Namespace and name of the dependent object. NameInfo `json:",inline"` // Managed types ManagedTypes []TypeInfo `json:"managedTypes,omitempty"` // Digest of the descriptor of the dependent object. Digest string `json:"digest"` // Phase of the dependent object. Phase string `json:"phase,omitempty"` // Observed status of the dependent object, as observed by kstatus. Status string `json:"status,omitempty"` }
InventoryItem represents a dependent object managed by this operator.
func (*InventoryItem) DeepCopy ¶
func (in *InventoryItem) DeepCopy() *InventoryItem
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InventoryItem.
func (*InventoryItem) DeepCopyInto ¶
func (in *InventoryItem) DeepCopyInto(out *InventoryItem)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (InventoryItem) GetNamespace ¶
func (i InventoryItem) GetNamespace() string
Get inventory item's namespace.
func (*InventoryItem) GetObjectKind ¶
func (i *InventoryItem) GetObjectKind() schema.ObjectKind
Get inventory item's ObjectKind accessor.
func (InventoryItem) GroupVersionKind ¶
func (i InventoryItem) GroupVersionKind() schema.GroupVersionKind
Get inventory item's GroupVersionKind.
func (InventoryItem) Matches ¶
func (i InventoryItem) Matches(key types.ObjectKey) bool
Check whether inventory item matches given ObjectKey, in the sense that Group, Kind, Namespace and Name are the same. Note that this does not compare the group's Version.
func (*InventoryItem) SetGroupVersionKind ¶
func (i *InventoryItem) SetGroupVersionKind(gvk schema.GroupVersionKind)
Set inventory item's GroupVersionKind.
func (InventoryItem) String ¶
func (i InventoryItem) String() string
Return a string representation of the inventory item; makes InventoryItem implement the Stringer interface.
type KubernetesContainerProperties ¶
type KubernetesContainerProperties struct { SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` }
KubernetesContainerProperties defines K8s properties to be applied to the created workloads (container level)
func (*KubernetesContainerProperties) DeepCopy ¶
func (in *KubernetesContainerProperties) DeepCopy() *KubernetesContainerProperties
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesContainerProperties.
func (*KubernetesContainerProperties) DeepCopyInto ¶
func (in *KubernetesContainerProperties) DeepCopyInto(out *KubernetesContainerProperties)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type KubernetesPodProperties ¶
type KubernetesPodProperties struct { NodeSelector map[string]string `json:"nodeSelector,omitempty"` Affinity *corev1.Affinity `json:"affinity,omitempty"` TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"` Tolerations []corev1.Toleration `json:"tolerations,omitempty"` PriorityClassName *string `json:"priorityClassName,omitempty"` PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` Labels map[string]string `json:"podLabels,omitempty"` Annotations map[string]string `json:"podAnnotations,omitempty"` }
KubernetesPodProperties defines K8s properties to be applied to the created workloads (pod level)
func (*KubernetesPodProperties) DeepCopy ¶
func (in *KubernetesPodProperties) DeepCopy() *KubernetesPodProperties
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesPodProperties.
func (*KubernetesPodProperties) DeepCopyInto ¶
func (in *KubernetesPodProperties) DeepCopyInto(out *KubernetesPodProperties)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type KubernetesProperties ¶
type KubernetesProperties struct { KubernetesPodProperties `json:",inline"` KubernetesContainerProperties `json:",inline"` }
KubernetesProperties defines a union of KubernetesPodProperties and KubernetesContainerProperties. Useful in cases where a controller pod has exactly one container.
func (*KubernetesProperties) DeepCopy ¶
func (in *KubernetesProperties) DeepCopy() *KubernetesProperties
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesProperties.
func (*KubernetesProperties) DeepCopyInto ¶
func (in *KubernetesProperties) DeepCopyInto(out *KubernetesProperties)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type NameInfo ¶
type NameInfo struct { // Namespace of the referenced object; empty for non-namespaced objects Namespace string `json:"namespace,omitempty"` // Name of the referenced object. Name string `json:"name"` }
NameInfo represents an object's namespace and name.
type Reconciler ¶
type Reconciler[T Component] struct { // contains filtered or unexported fields }
Reconciler provides the implementation of controller-runtime's Reconciler interface, for a given Component type T.
func NewReconciler ¶
func NewReconciler[T Component](name string, client client.Client, discoveryClient discovery.DiscoveryInterface, recorder record.EventRecorder, scheme *runtime.Scheme, resourceGenerator manifests.Generator) *Reconciler[T]
Create a new Reconciler. Here:
- name should be a meaningful and unique name identifying this reconciler with the Kubernetes cluster; it will be used in annotations, finalizers, and so on
- client should be a controller-runtime client for the current cluster; it should have informer caching disabled for the reconciled type T, as well as for apiextensionsv1.CustomResourceDefinition and apiregistrationv1.APIService
- discoveryClient should be a discovery client for the current cluster
- scheme is required to recognize the core group (corev1), the api group containing T, and apiextensionsv1 and apiregistrationv1; in addition, scheme must know about all concrete (i.e. non-unstructured) types returned by the given resource generator
- resourceGenerator must be an implementation of the manifests.Generator interface.
func (*Reconciler[T]) Reconcile ¶
func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error)
Reconcile contains the actual reconciliation logic.
func (*Reconciler[T]) SetupWithManager ¶
func (r *Reconciler[T]) SetupWithManager(mgr ctrl.Manager) error
Register the reconciler with a given controller-runtime Manager.
func (*Reconciler[T]) WithPostDeleteHook ¶
func (r *Reconciler[T]) WithPostDeleteHook(hook HookFunc[T]) *Reconciler[T]
Register post-delete hook with reconciler. This hook will be called if the reconciled component is in deletion (has a deletionTimestamp set), right after the deletion of the dependent objects happened, and was successful.
func (*Reconciler[T]) WithPostReadHook ¶
func (r *Reconciler[T]) WithPostReadHook(hook HookFunc[T]) *Reconciler[T]
Register post-read hook with reconciler. This hook will be called after the reconciled component object has been retrieved from the Kubernetes API.
func (*Reconciler[T]) WithPostReconcileHook ¶
func (r *Reconciler[T]) WithPostReconcileHook(hook HookFunc[T]) *Reconciler[T]
Register post-reconcile hook with reconciler. This hook will be called if the reconciled component is not in deletion (has no deletionTimestamp set), right after the reconcilation of the dependent objects happened, and was successful.
func (*Reconciler[T]) WithPreDeleteHook ¶
func (r *Reconciler[T]) WithPreDeleteHook(hook HookFunc[T]) *Reconciler[T]
Register pre-delete hook with reconciler. This hook will be called if the reconciled component is in deletion (has a deletionTimestamp set), right before the deletion of the dependent objects starts.
func (*Reconciler[T]) WithPreReconcileHook ¶
func (r *Reconciler[T]) WithPreReconcileHook(hook HookFunc[T]) *Reconciler[T]
Register pre-reconcile hook with reconciler. This hook will be called if the reconciled component is not in deletion (has no deletionTimestamp set), right before the reconcilation of the dependent objects starts.
type ServiceProperties ¶
type ServiceProperties struct { // +kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer;ExternalName // +kubebuilder:default=ClusterIP Type corev1.ServiceType `json:"type,omitempty"` LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"` // +kubebuilder:validation:Enum=Cluster;Local // +kubebuilder:default=Cluster ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty"` Labels map[string]string `json:"labels,omitempty"` Annotations map[string]string `json:"annotations,omitempty"` }
ServiceProperties defines K8s properties to be applied to a managed service resource.
func (*ServiceProperties) DeepCopy ¶
func (in *ServiceProperties) DeepCopy() *ServiceProperties
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceProperties.
func (*ServiceProperties) DeepCopyInto ¶
func (in *ServiceProperties) DeepCopyInto(out *ServiceProperties)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type Spec ¶
type Spec struct { Namespace string `json:"namespace,omitempty"` Name string `json:"name,omitempty"` }
Component Spec. Types implementing the Component interface may include this into their spec.
func (*Spec) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Spec.
func (*Spec) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type State ¶
type State string
Component state. Can be one of 'Ready', 'Processing', 'Error', 'Deleting'.
type Status ¶
type Status struct { ObservedGeneration int64 `json:"observedGeneration"` AppliedGeneration int64 `json:"appliedGeneration,omitempty"` LastObservedAt *metav1.Time `json:"lastObservedAt,omitempty"` LastAppliedAt *metav1.Time `json:"lastAppliedAt,omitempty"` Conditions []Condition `json:"conditions,omitempty"` // +kubebuilder:validation:Enum=Processing;Deleting;Ready;Error State State `json:"state,omitempty"` Inventory []*InventoryItem `json:"inventory,omitempty"` }
Component Status. Types implementing the Component interface must include this into their status.
func (*Status) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Status.
func (*Status) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.