controller

package
v0.0.0-...-076cea6 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControllerContainerName = "manager"
)

Variables

This section is empty.

Functions

func SetupThirdPartyCrdReconcilerWithManager

func SetupThirdPartyCrdReconcilerWithManager(
	ctx context.Context,
	k8sClient client.Client,
	crdReconciler ThirdPartyCrdReconciler,
	logger *logr.Logger,
) error

func StartProcessingThirdPartySynchronizationQueue

func StartProcessingThirdPartySynchronizationQueue(
	resourceReconcileQueue *workqueue.Typed[ThirdPartyResourceSyncJob],
	setupLog *logr.Logger,
)

func StopProcessingThirdPartySynchronizationQueue

func StopProcessingThirdPartySynchronizationQueue(
	resourceReconcileQueue *workqueue.Typed[ThirdPartyResourceSyncJob],
	logger *logr.Logger,
)

Types

type ApiClient

type ApiClient interface {
	SetApiEndpointAndDataset(*ApiConfig, *logr.Logger)
	RemoveApiEndpointAndDataset()
}

type ApiConfig

type ApiConfig struct {
	Endpoint string
	Dataset  string
}

type CheckRule

type CheckRule struct {
	Name          string            `json:"name"`
	Expression    string            `json:"expression"`
	For           string            `json:"for,omitempty"`
	Interval      string            `json:"interval,omitempty"`
	KeepFiringFor string            `json:"keepFiringFor,omitempty"`
	Annotations   map[string]string `json:"annotations"` // √
	Labels        map[string]string `json:"labels"`
}

type HttpRequestWithItemName

type HttpRequestWithItemName struct {
	ItemName string
	Request  *http.Request
}

type MonitoringReconciler

type MonitoringReconciler struct {
	client.Client
	Clientset                *kubernetes.Clientset
	Instrumenter             *instrumentation.Instrumenter
	BackendConnectionManager *backendconnection.BackendConnectionManager
	Images                   util.Images
	OperatorNamespace        string
	DanglingEventsTimeouts   *util.DanglingEventsTimeouts
}

func (*MonitoringReconciler) InitializeSelfMonitoringMetrics

func (r *MonitoringReconciler) InitializeSelfMonitoringMetrics(
	meter otelmetric.Meter,
	metricNamePrefix string,
	logger *logr.Logger,
)

func (*MonitoringReconciler) Reconcile

func (r *MonitoringReconciler) 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. It is essential for the controller's reconciliation loop to be idempotent. By following the Operator pattern you will create Controllers which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. Breaking this recommendation goes against the design principles of controller-runtime. and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention. For further info: - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile

func (*MonitoringReconciler) SetupWithManager

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

type OperatorConfigurationReconciler

type OperatorConfigurationReconciler struct {
	client.Client
	Clientset                *kubernetes.Clientset
	ApiClients               []ApiClient
	Scheme                   *runtime.Scheme
	Recorder                 record.EventRecorder
	BackendConnectionManager *backendconnection.BackendConnectionManager
	DeploymentSelfReference  *appsv1.Deployment
	DanglingEventsTimeouts   *util.DanglingEventsTimeouts
	Images                   util.Images
	OperatorNamespace        string
	DevelopmentMode          bool
}

func (*OperatorConfigurationReconciler) InitializeSelfMonitoringMetrics

func (r *OperatorConfigurationReconciler) InitializeSelfMonitoringMetrics(
	meter otelmetric.Meter,
	metricNamePrefix string,
	logger *logr.Logger,
)

func (*OperatorConfigurationReconciler) Reconcile

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. It is essential for the controller's reconciliation loop to be idempotent. By following the Operator pattern you will create Controllers which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. Breaking this recommendation goes against the design principles of controller-runtime. and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention. For further info: - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile

func (*OperatorConfigurationReconciler) SetupWithManager

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

type PersesDashboardCrdReconciler

type PersesDashboardCrdReconciler struct {
	Client    client.Client
	Queue     *workqueue.Typed[ThirdPartyResourceSyncJob]
	AuthToken string
	// contains filtered or unexported fields
}

func (*PersesDashboardCrdReconciler) ControllerName

func (r *PersesDashboardCrdReconciler) ControllerName() string

func (*PersesDashboardCrdReconciler) CreateResourceReconciler

func (r *PersesDashboardCrdReconciler) CreateResourceReconciler(
	pseudoClusterUid types.UID,
	authToken string,
	httpClient *http.Client,
)

func (*PersesDashboardCrdReconciler) DoesCrdExist

func (r *PersesDashboardCrdReconciler) DoesCrdExist() *atomic.Bool

func (*PersesDashboardCrdReconciler) GetAuthToken

func (r *PersesDashboardCrdReconciler) GetAuthToken() string

func (*PersesDashboardCrdReconciler) Group

func (*PersesDashboardCrdReconciler) InitializeSelfMonitoringMetrics

func (r *PersesDashboardCrdReconciler) InitializeSelfMonitoringMetrics(
	meter otelmetric.Meter,
	metricNamePrefix string,
	logger *logr.Logger,
)

func (*PersesDashboardCrdReconciler) Kind

func (*PersesDashboardCrdReconciler) KindDisplayName

func (r *PersesDashboardCrdReconciler) KindDisplayName() string

func (*PersesDashboardCrdReconciler) Manager

func (*PersesDashboardCrdReconciler) QualifiedKind

func (r *PersesDashboardCrdReconciler) QualifiedKind() string

func (*PersesDashboardCrdReconciler) Reconcile

func (*PersesDashboardCrdReconciler) RemoveApiEndpointAndDataset

func (r *PersesDashboardCrdReconciler) RemoveApiEndpointAndDataset()

func (*PersesDashboardCrdReconciler) ResourceReconciler

func (*PersesDashboardCrdReconciler) SetApiEndpointAndDataset

func (r *PersesDashboardCrdReconciler) SetApiEndpointAndDataset(
	apiConfig *ApiConfig,
	logger *logr.Logger)

func (*PersesDashboardCrdReconciler) SetCrdExists

func (r *PersesDashboardCrdReconciler) SetCrdExists(exists bool)

func (*PersesDashboardCrdReconciler) SetupWithManager

func (r *PersesDashboardCrdReconciler) SetupWithManager(
	ctx context.Context,
	mgr ctrl.Manager,
	startupK8sClient client.Client,
	logger *logr.Logger,
) error

func (*PersesDashboardCrdReconciler) SkipNameValidation

func (r *PersesDashboardCrdReconciler) SkipNameValidation() bool

func (*PersesDashboardCrdReconciler) Version

func (r *PersesDashboardCrdReconciler) Version() string

type PersesDashboardReconciler

type PersesDashboardReconciler struct {
	client.Client
	// contains filtered or unexported fields
}

func (*PersesDashboardReconciler) ControllerName

func (r *PersesDashboardReconciler) ControllerName() string

func (*PersesDashboardReconciler) ControllerStopFunctionLock

func (r *PersesDashboardReconciler) ControllerStopFunctionLock() *sync.Mutex

func (*PersesDashboardReconciler) GetApiConfig

func (r *PersesDashboardReconciler) GetApiConfig() *atomic.Pointer[ApiConfig]

func (*PersesDashboardReconciler) GetAuthToken

func (r *PersesDashboardReconciler) GetAuthToken() string

func (*PersesDashboardReconciler) GetControllerStopFunction

func (r *PersesDashboardReconciler) GetControllerStopFunction() *context.CancelFunc

func (*PersesDashboardReconciler) GetHttpRetryDelay

func (r *PersesDashboardReconciler) GetHttpRetryDelay() time.Duration

func (*PersesDashboardReconciler) HttpClient

func (r *PersesDashboardReconciler) HttpClient() *http.Client

func (*PersesDashboardReconciler) InitializeSelfMonitoringMetrics

func (r *PersesDashboardReconciler) InitializeSelfMonitoringMetrics(
	meter otelmetric.Meter,
	metricNamePrefix string,
	logger *logr.Logger,
)

func (*PersesDashboardReconciler) IsSynchronizationEnabled

func (r *PersesDashboardReconciler) IsSynchronizationEnabled(monitoringResource *dash0v1alpha1.Dash0Monitoring) bool

func (*PersesDashboardReconciler) IsWatching

func (r *PersesDashboardReconciler) IsWatching() bool

func (*PersesDashboardReconciler) K8sClient

func (r *PersesDashboardReconciler) K8sClient() client.Client

func (*PersesDashboardReconciler) KindDisplayName

func (r *PersesDashboardReconciler) KindDisplayName() string

func (*PersesDashboardReconciler) MapResourceToHttpRequests

func (r *PersesDashboardReconciler) MapResourceToHttpRequests(
	preconditionChecksResult *preconditionValidationResult,
	action apiAction,
	logger *logr.Logger,
) (int, []HttpRequestWithItemName, map[string][]string, map[string]string)

func (*PersesDashboardReconciler) Queue

func (*PersesDashboardReconciler) Reconcile

func (*PersesDashboardReconciler) SetControllerStopFunction

func (r *PersesDashboardReconciler) SetControllerStopFunction(controllerStopFunction *context.CancelFunc)

func (*PersesDashboardReconciler) ShortName

func (r *PersesDashboardReconciler) ShortName() string

func (*PersesDashboardReconciler) UpdateSynchronizationResultsInStatus

func (r *PersesDashboardReconciler) UpdateSynchronizationResultsInStatus(
	monitoringResource *dash0v1alpha1.Dash0Monitoring,
	qualifiedName string,
	status dash0v1alpha1.SynchronizationStatus,
	_ int,
	_ []string,
	synchronizationErrors map[string]string,
	validationIssuesMap map[string][]string,
) interface{}

type PrometheusRuleCrdReconciler

type PrometheusRuleCrdReconciler struct {
	Client    client.Client
	Queue     *workqueue.Typed[ThirdPartyResourceSyncJob]
	AuthToken string
	// contains filtered or unexported fields
}

func (*PrometheusRuleCrdReconciler) ControllerName

func (r *PrometheusRuleCrdReconciler) ControllerName() string

func (*PrometheusRuleCrdReconciler) CreateResourceReconciler

func (r *PrometheusRuleCrdReconciler) CreateResourceReconciler(
	pseudoClusterUid types.UID,
	authToken string,
	httpClient *http.Client,
)

func (*PrometheusRuleCrdReconciler) DoesCrdExist

func (r *PrometheusRuleCrdReconciler) DoesCrdExist() *atomic.Bool

func (*PrometheusRuleCrdReconciler) GetAuthToken

func (r *PrometheusRuleCrdReconciler) GetAuthToken() string

func (*PrometheusRuleCrdReconciler) Group

func (*PrometheusRuleCrdReconciler) InitializeSelfMonitoringMetrics

func (r *PrometheusRuleCrdReconciler) InitializeSelfMonitoringMetrics(
	meter otelmetric.Meter,
	metricNamePrefix string,
	logger *logr.Logger,
)

func (*PrometheusRuleCrdReconciler) Kind

func (*PrometheusRuleCrdReconciler) KindDisplayName

func (r *PrometheusRuleCrdReconciler) KindDisplayName() string

func (*PrometheusRuleCrdReconciler) Manager

func (*PrometheusRuleCrdReconciler) QualifiedKind

func (r *PrometheusRuleCrdReconciler) QualifiedKind() string

func (*PrometheusRuleCrdReconciler) Reconcile

func (*PrometheusRuleCrdReconciler) RemoveApiEndpointAndDataset

func (r *PrometheusRuleCrdReconciler) RemoveApiEndpointAndDataset()

func (*PrometheusRuleCrdReconciler) ResourceReconciler

func (*PrometheusRuleCrdReconciler) SetApiEndpointAndDataset

func (r *PrometheusRuleCrdReconciler) SetApiEndpointAndDataset(
	apiConfig *ApiConfig,
	logger *logr.Logger)

func (*PrometheusRuleCrdReconciler) SetCrdExists

func (r *PrometheusRuleCrdReconciler) SetCrdExists(exists bool)

func (*PrometheusRuleCrdReconciler) SetupWithManager

func (r *PrometheusRuleCrdReconciler) SetupWithManager(
	ctx context.Context,
	mgr ctrl.Manager,
	startupK8sClient client.Client,
	logger *logr.Logger,
) error

func (*PrometheusRuleCrdReconciler) SkipNameValidation

func (r *PrometheusRuleCrdReconciler) SkipNameValidation() bool

func (*PrometheusRuleCrdReconciler) Version

func (r *PrometheusRuleCrdReconciler) Version() string

type PrometheusRuleReconciler

type PrometheusRuleReconciler struct {
	client.Client
	// contains filtered or unexported fields
}

func (*PrometheusRuleReconciler) ControllerName

func (r *PrometheusRuleReconciler) ControllerName() string

func (*PrometheusRuleReconciler) ControllerStopFunctionLock

func (r *PrometheusRuleReconciler) ControllerStopFunctionLock() *sync.Mutex

func (*PrometheusRuleReconciler) GetApiConfig

func (r *PrometheusRuleReconciler) GetApiConfig() *atomic.Pointer[ApiConfig]

func (*PrometheusRuleReconciler) GetAuthToken

func (r *PrometheusRuleReconciler) GetAuthToken() string

func (*PrometheusRuleReconciler) GetControllerStopFunction

func (r *PrometheusRuleReconciler) GetControllerStopFunction() *context.CancelFunc

func (*PrometheusRuleReconciler) GetHttpRetryDelay

func (r *PrometheusRuleReconciler) GetHttpRetryDelay() time.Duration

func (*PrometheusRuleReconciler) HttpClient

func (r *PrometheusRuleReconciler) HttpClient() *http.Client

func (*PrometheusRuleReconciler) InitializeSelfMonitoringMetrics

func (r *PrometheusRuleReconciler) InitializeSelfMonitoringMetrics(
	meter otelmetric.Meter,
	metricNamePrefix string,
	logger *logr.Logger,
)

func (*PrometheusRuleReconciler) IsSynchronizationEnabled

func (r *PrometheusRuleReconciler) IsSynchronizationEnabled(monitoringResource *dash0v1alpha1.Dash0Monitoring) bool

func (*PrometheusRuleReconciler) IsWatching

func (r *PrometheusRuleReconciler) IsWatching() bool

func (*PrometheusRuleReconciler) K8sClient

func (r *PrometheusRuleReconciler) K8sClient() client.Client

func (*PrometheusRuleReconciler) KindDisplayName

func (r *PrometheusRuleReconciler) KindDisplayName() string

func (*PrometheusRuleReconciler) MapResourceToHttpRequests

func (r *PrometheusRuleReconciler) MapResourceToHttpRequests(
	preconditionChecksResult *preconditionValidationResult,
	action apiAction,
	logger *logr.Logger,
) (int, []HttpRequestWithItemName, map[string][]string, map[string]string)

func (*PrometheusRuleReconciler) Queue

func (*PrometheusRuleReconciler) Reconcile

func (*PrometheusRuleReconciler) SetControllerStopFunction

func (r *PrometheusRuleReconciler) SetControllerStopFunction(controllerStopFunction *context.CancelFunc)

func (*PrometheusRuleReconciler) ShortName

func (r *PrometheusRuleReconciler) ShortName() string

func (*PrometheusRuleReconciler) UpdateSynchronizationResultsInStatus

func (r *PrometheusRuleReconciler) UpdateSynchronizationResultsInStatus(
	monitoringResource *dash0v1alpha1.Dash0Monitoring,
	qualifiedName string,
	status dash0v1alpha1.SynchronizationStatus,
	itemsTotal int,
	succesfullySynchronized []string,
	synchronizationErrorsPerItem map[string]string,
	validationIssuesPerItem map[string][]string,
) interface{}

type ThirdPartyCrdReconciler

type ThirdPartyCrdReconciler interface {
	handler.TypedEventHandler[client.Object, reconcile.Request]
	reconcile.TypedReconciler[reconcile.Request]

	Manager() ctrl.Manager
	GetAuthToken() string
	KindDisplayName() string
	Group() string
	Kind() string
	Version() string
	QualifiedKind() string
	ControllerName() string
	DoesCrdExist() *atomic.Bool
	SetCrdExists(bool)
	SkipNameValidation() bool
	CreateResourceReconciler(types.UID, string, *http.Client)
	ResourceReconciler() ThirdPartyResourceReconciler
}

type ThirdPartyResourceReconciler

type ThirdPartyResourceReconciler interface {
	handler.TypedEventHandler[*unstructured.Unstructured, reconcile.Request]
	reconcile.TypedReconciler[reconcile.Request]

	KindDisplayName() string
	ShortName() string
	ControllerStopFunctionLock() *sync.Mutex
	GetControllerStopFunction() *context.CancelFunc
	SetControllerStopFunction(*context.CancelFunc)
	IsWatching() bool
	GetAuthToken() string
	GetApiConfig() *atomic.Pointer[ApiConfig]
	ControllerName() string
	K8sClient() client.Client
	Queue() *workqueue.Typed[ThirdPartyResourceSyncJob]
	HttpClient() *http.Client
	GetHttpRetryDelay() time.Duration
	IsSynchronizationEnabled(*dash0v1alpha1.Dash0Monitoring) bool

	// MapResourceToHttpRequests converts a third-party resource object to a list of HTTP requests that can be sent to
	// the Dash0 API. It returns:
	// - the total number of eligible items in the third-party Kubernetes resource,
	// - the request objects for which the conversion was successful,
	// - validation issues for items that were invalid and
	// - synchronization errors that occurred during the conversion.
	MapResourceToHttpRequests(
		*preconditionValidationResult,
		apiAction,
		*logr.Logger,
	) (
		int,
		[]HttpRequestWithItemName,
		map[string][]string,
		map[string]string,
	)
	UpdateSynchronizationResultsInStatus(
		monitoringResource *dash0v1alpha1.Dash0Monitoring,
		qualifiedName string,
		status dash0v1alpha1.SynchronizationStatus,
		itemsTotal int,
		succesfullySynchronized []string,
		synchronizationErrorsPerItem map[string]string,
		validationIssuesPerItem map[string][]string,
	) interface{}
}

type ThirdPartyResourceSyncJob

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

Jump to

Keyboard shortcuts

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