controller

package
v0.0.53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	State      = make(map[string]*AppBundleState)
	StateMutex = &sync.Mutex{}
)
View Source
var AppBundleSelector = "appbundle"

Functions

func CreateExpectedConfigMap

func CreateExpectedConfigMap(ab *atroxyzv1alpha1.AppBundle) (*corev1.ConfigMap, error)

CreateExpectedConfigMap creates the expected config mapfrom the appbundle

func CreateExpectedDeployment

func CreateExpectedDeployment(ab *atroxyzv1alpha1.AppBundle) (*appsv1.Deployment, error)

CreateExpectedDeployment creates expected deployment from appbundle

func CreateExpectedExternalSecret

func CreateExpectedExternalSecret(ab *atroxyzv1alpha1.AppBundle) (*extsec.ExternalSecret, error)

CreateExpectedExternalSecret creates the expected external secret from the appbundle or returns nil if no secret is needed

func CreateExpectedIngress

func CreateExpectedIngress(ab *atroxyzv1alpha1.AppBundle, name string, route *atroxyzv1alpha1.AppBundleRoute) (*netv1.Ingress, error)

CreateExpectedIngress creates the expected ingress from the appbundle and the name given

func CreateExpectedPVC

func CreateExpectedPVC(ab *atroxyzv1alpha1.AppBundle, volume *atroxyzv1alpha1.AppBundleVolume, volumeName string) (*corev1.PersistentVolumeClaim, error)

CreateExpectedPVC creates the expected PVC in order to be compared to an already existing PVC if one exists, reconcille if doesn't.

func CreateExpectedService

func CreateExpectedService(ab *atroxyzv1alpha1.AppBundle, generatedSpecData *GeneratedServiceSpecData) (*corev1.Service, error)

CreateExpectedService creates the expected service from the appbundle

func FormulateDiffMessageForLabels

func FormulateDiffMessageForLabels(oldObjLabels, newObjLabels interface{}) (string, error)

func FormulateDiffMessageForSpecs

func FormulateDiffMessageForSpecs(oldObjSpec, newObjSpec interface{}) (string, error)

func GetAppBundleNamespacedName

func GetAppBundleNamespacedName(ab *atroxyzv1alpha1.AppBundle) types.NamespacedName

func GetAppBundleObjectMetaWithOwnerReference

func GetAppBundleObjectMetaWithOwnerReference(app_bundle *atroxyzv1alpha1.AppBundle) metav1.ObjectMeta

func GetDiffPaths

func GetDiffPaths(oldObj, newObj interface{}) (string, error)

func GetHomePageAnnotations

func GetHomePageAnnotations(annotations map[string]string, ab *atroxyzv1alpha1.AppBundle) map[string]string

func GetObjectMetaForIngress

func GetObjectMetaForIngress(app_bundle *atroxyzv1alpha1.AppBundle) metav1.ObjectMeta

func IsDefault

func IsDefault[T any](value T) bool

func MergeIntoServiceSpec

func MergeIntoServiceSpec(service *corev1.Service, data *GeneratedServiceSpecData)

func RegisterStateIfNotAlreadyRegistered

func RegisterStateIfNotAlreadyRegistered(app types.AppId) error

GetState returns the state of an appbundle object from the cache. Returns bool if the state was initialized and error if any.

func ResolveAppBundleBase

ResolveAppBundleBase resolves the base of an app bundle

func ReturnFirstNonDefault

func ReturnFirstNonDefault[T any](elem ...T) T

ReturnFirstNonNil returns the first non-nil element in a list of pointers

func RunReconciles

func RunReconciles(
	ctx context.Context,
	app_bundle *atroxyzv1alpha1.AppBundle,
	reconciles ...func(context.Context, *atroxyzv1alpha1.AppBundle) error,
) error

RunReconciles takes in a list of reconcile functions, passes argument into each one and runs concurrently.

func SetDefault

func SetDefault[T any](value *T)

func SetDefaultAppBundleLabels

func SetDefaultAppBundleLabels(ab *atroxyzv1alpha1.AppBundle, labels map[string]string) map[string]string

SetDefaultAppBundleLabels attaches default labels to a derivative object of an app bundle

func ShouldRecreateResource

func ShouldRecreateResource(err error) bool

ShouldRecreateResource checks for a specific error message that indicates a resource should be recreated because the field is immutable and updating is not possible.

func StateNeedsUpdating

func StateNeedsUpdating(app types.AppId, alreadyRegistered bool) (bool, error)

func StringMapsMatch

func StringMapsMatch(map1, map2 map[string]string) bool

func UpdateState

func UpdateState(app types.AppId) error

func UpsertResource

func UpsertResource(ctx context.Context, r ReaderWriter, newObj client.Object, reason string, er error, neverDelete bool) error

UpsertResource creates or updates a resource with nice logging indicating what is happening.

Types

type AppBundleBaseReconciler

type AppBundleBaseReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

AppBundleBaseReconciler reconciles a AppBundleBase object

func (*AppBundleBaseReconciler) Reconcile

func (r *AppBundleBaseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the AppBundleBase object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile

func (*AppBundleBaseReconciler) SetupWithManager

func (r *AppBundleBaseReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type AppBundleBaseState

type AppBundleBaseState struct {
	SpecHash           string
	LastReconciliation time.Time
	NextBackoffInSec   int16
}

AppBundleBaseState is the in-memory cached state of an appbundlebase object.

type AppBundleIdentifier

type AppBundleIdentifier string // Identifier for the app bundle

type AppBundleReconciler

type AppBundleReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

AppBundleReconciler reconciles a AppBundle object

func (*AppBundleReconciler) Reconcile

func (r *AppBundleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.0/pkg/reconcile

func (*AppBundleReconciler) ReconcileConfigMap

func (r *AppBundleReconciler) ReconcileConfigMap(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

ReconcileConfigMap the config map for the appbundle

func (*AppBundleReconciler) ReconcileDeployment

func (r *AppBundleReconciler) ReconcileDeployment(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

ReconcileDeployment checks currently existing deployment with the expected deployment and updates it if necessary. If no deployment exists, it creates one.

func (*AppBundleReconciler) ReconcileExistingPVC

func (*AppBundleReconciler) ReconcileExternalSecret

func (r *AppBundleReconciler) ReconcileExternalSecret(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

ReconcileExternalSecret reconciles the service for the appbundle

func (*AppBundleReconciler) ReconcileIngress

func (r *AppBundleReconciler) ReconcileIngress(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

func (*AppBundleReconciler) ReconcilePVC

ReconcilePVC compares currently existing PVC (if one exists) with what is the expected PVC and upserts if they differ.

func (*AppBundleReconciler) ReconcileRecurringBackupJob

func (r *AppBundleReconciler) ReconcileRecurringBackupJob(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

func (*AppBundleReconciler) ReconcileService

func (r *AppBundleReconciler) ReconcileService(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

ReconcileService reconciles the service for the appbundle

func (*AppBundleReconciler) ReconcileVolumes

func (r *AppBundleReconciler) ReconcileVolumes(ctx context.Context, ab *atroxyzv1alpha1.AppBundle) error

ReconcileVolumes is a generic function that takes in a volume, checks if its a hostPath, emptyDir or a PVC. If hostPath or a emptyDir it just returns, if a PVC it reconciles it using ReconcilePVC function. If backup is requested it is also reconciled using ReconcileBackup function.

func (*AppBundleReconciler) SetupWithManager

func (r *AppBundleReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type AppBundleState

type AppBundleState struct {
	SpecHash           string
	LastReconciliation time.Time
	NextBackoffInSec   int16
}

AppBundleState is the in-memory cached state of an appbundle object.

func GetState

func GetState(app types.AppId) (*AppBundleState, error)

type GeneratedServiceSpecData

type GeneratedServiceSpecData struct {
	SessionAffinity       corev1.ServiceAffinity
	IPFamilies            []corev1.IPFamily
	IPFamilyPolicy        *corev1.IPFamilyPolicy
	InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicy
	// contains filtered or unexported fields
}

GeneratedServiceSpecData is data that is generated by k8s API and hence cannot be "expected" as such is passed into expected function.

func GetGeneratedServiceSpecData

func GetGeneratedServiceSpecData(svc *corev1.Service) *GeneratedServiceSpecData

type ReaderWriter

type ReaderWriter interface {
	client.Reader
	client.Writer
}

type ResourceMutexes

type ResourceMutexes struct {
	sync.Mutex
	// contains filtered or unexported fields
}

type StateAlreadyRegisteredError

type StateAlreadyRegisteredError struct {
	// contains filtered or unexported fields
}

func (StateAlreadyRegisteredError) Error

type StateNotRegisteredError

type StateNotRegisteredError struct {
	// contains filtered or unexported fields
}

func (StateNotRegisteredError) Error

func (e StateNotRegisteredError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL