Documentation
¶
Index ¶
- Constants
- Variables
- func CreateObjectIfNotExist(ctx context.Context, c client.Client, source, newObject client.Object) (client.Object, error)
- func IsDeploymentReady(deployment *appsv1.Deployment) bool
- func IsObjectSpecEqual(objectA, objectB client.Object) (bool, error)
- func IsStatefulSetReady(sts *appsv1.StatefulSet) bool
- func SetControllerAndAnnotation(owner, controlled client.Object, scheme *runtime.Scheme, spec interface{}) error
- type ComponentOperator
- type DefaultDeployer
- func (d *DefaultDeployer) Apply(ctx context.Context, objects []client.Object) error
- func (d *DefaultDeployer) CheckAndUpdateStatus(_ context.Context, _ client.Object) (bool, error)
- func (d *DefaultDeployer) CleanUp(_ context.Context, _ client.Object) error
- func (d *DefaultDeployer) PostSyncHooks() []Hook
- func (d *DefaultDeployer) PreSyncHooks() []Hook
- func (d *DefaultDeployer) Render(_ client.Object) ([]client.Object, error)
- func (d *DefaultDeployer) Sync(ctx context.Context, crdObject client.Object, operator ComponentOperator) error
- type Deployer
- type Hook
- type Syncer
Constants ¶
View Source
const (
LastAppliedResourceSpec = "controller.greptime.io/last-applied-resource-spec"
)
Variables ¶
View Source
var (
ErrSyncNotReady = fmt.Errorf("the sync process is not ready")
)
Functions ¶
func CreateObjectIfNotExist ¶
func CreateObjectIfNotExist(ctx context.Context, c client.Client, source, newObject client.Object) (client.Object, error)
CreateObjectIfNotExist creates Kubernetes object if it does not exist, otherwise returns the existing object.
func IsDeploymentReady ¶
func IsDeploymentReady(deployment *appsv1.Deployment) bool
IsDeploymentReady checks if the deployment is ready. TODO(zyy17): Maybe it's not a accurate way to detect the statefulset is ready.
func IsObjectSpecEqual ¶
IsObjectSpecEqual checks if the spec of the object is equal to other one.
func IsStatefulSetReady ¶
func IsStatefulSetReady(sts *appsv1.StatefulSet) bool
IsStatefulSetReady checks if the statefulset is ready. TODO(zyy17): Maybe it's not a accurate way to detect the deployment is ready.
Types ¶
type ComponentOperator ¶
type ComponentOperator interface {
// Render generates the multiple Kubernetes objects base on the CRD object.
Render(crdObject client.Object) ([]client.Object, error)
// Apply creates or update the Kubernetes objects that generated by Render().
// If the object is not existed, it will be created.
// If the object is existed, it will be updated if the object is different.
Apply(ctx context.Context, objects []client.Object) error
// CleanUp cleans up the resources that created by the deployer.
CleanUp(ctx context.Context, crdObject client.Object) error
// CheckAndUpdateStatus checks if the status of Kubernetes objects are ready and update the status.
CheckAndUpdateStatus(ctx context.Context, crdObject client.Object) (bool, error)
// PreSyncHooks returns the hooks that will be executed before the core login of Sync().
PreSyncHooks() []Hook
// PostSyncHooks returns the hooks that will be executed after the core login of Sync().
PostSyncHooks() []Hook
}
ComponentOperator is the interface that define the behaviors of a deployer.
type DefaultDeployer ¶
DefaultDeployer implement some common behaviors of the ComponentOperator interface.
func (*DefaultDeployer) CheckAndUpdateStatus ¶
func (*DefaultDeployer) PostSyncHooks ¶
func (d *DefaultDeployer) PostSyncHooks() []Hook
func (*DefaultDeployer) PreSyncHooks ¶
func (d *DefaultDeployer) PreSyncHooks() []Hook
func (*DefaultDeployer) Sync ¶
func (d *DefaultDeployer) Sync(ctx context.Context, crdObject client.Object, operator ComponentOperator) error
type Deployer ¶
type Deployer interface {
Syncer
ComponentOperator
}
Deployer is the interface that abstracts the deployment of a component.
Click to show internal directories.
Click to hide internal directories.