Documentation ¶
Index ¶
- Constants
- func SetTraceProvider(cfg OpenTelemetryConfig) error
- type ListWatchOptions
- type MetricsConfig
- type OTelConnType
- type OpenTelemetryConfig
- type Operator
- func (o *Operator) ClientGenerator() resource.ClientGenerator
- func (o *Operator) ConvertKind(gk metav1.GroupKind, converter k8s.Converter) error
- func (o *Operator) MutateKind(kind resource.Kind, controller resource.MutatingAdmissionController) error
- func (o *Operator) ReconcileKind(kind resource.Kind, reconciler operator.Reconciler, options ListWatchOptions) error
- func (o *Operator) RegisterMetricsCollectors(collectors ...prometheus.Collector) error
- func (o *Operator) Run(stopCh <-chan struct{}) error
- func (o *Operator) ValidateKind(kind resource.Kind, controller resource.ValidatingAdmissionController) error
- func (o *Operator) WatchKind(kind resource.Kind, watcher SyncWatcher, options ListWatchOptions) error
- type OperatorConfig
- type Reconciler
- type SyncWatcher
- type TracingConfig
- type Watcher
- func (w *Watcher) Add(ctx context.Context, object resource.Object) error
- func (w *Watcher) Delete(ctx context.Context, object resource.Object) error
- func (w *Watcher) Sync(ctx context.Context, object resource.Object) error
- func (w *Watcher) Update(ctx context.Context, old resource.Object, new resource.Object) error
- type WebhookConfig
Constants ¶
const ( OTelConnTypeGRPC = OTelConnType("grpc") OTelConnTypeHTTP = OTelConnType("http") )
Variables ¶
This section is empty.
Functions ¶
func SetTraceProvider ¶
func SetTraceProvider(cfg OpenTelemetryConfig) error
SetTraceProvider creates a trace.TracerProvider and sets it as the global TracerProvider which is used by default for all app-sdk packages unless overridden.
Types ¶
type ListWatchOptions ¶
type MetricsConfig ¶
type MetricsConfig struct { metrics.ExporterConfig Enabled bool Namespace string }
MetricsConfig contains configuration information for exposing prometheus metrics
type OTelConnType ¶
type OTelConnType string
type OpenTelemetryConfig ¶
type OpenTelemetryConfig struct { Host string Port int ConnType OTelConnType ServiceName string }
type Operator ¶
type Operator struct { Name string // ErrorHandler, if non-nil, is called when a recoverable error is encountered in underlying components. // This is typically used for logging and/or metrics. ErrorHandler func(ctx context.Context, err error) // contains filtered or unexported fields }
Operator is a simple operator implementation. Instead of manually registering controllers like with operator.Operator, use WatchKind to add a watcher for a specific kind (schema) and configuration (such as namespace, label filters), ReconcileKind to add a reconciler for a specific kind (schema) and configuration (such as namespace, label filers), and ValidateKind or MutateKind to add admission control for a kind (schema).
func NewOperator ¶
func NewOperator(cfg OperatorConfig) (*Operator, error)
NewOperator creates a new Operator
func (*Operator) ClientGenerator ¶
func (o *Operator) ClientGenerator() resource.ClientGenerator
ClientGenerator returns the ClientGenerator used by the Operator for getting clients for a particular schema
func (*Operator) ConvertKind ¶
ConvertKind provides a conversion path for the provided GroupKind in the converting webhook, using the provided k8s.Converter for the conversion logic.
func (*Operator) MutateKind ¶
func (o *Operator) MutateKind(kind resource.Kind, controller resource.MutatingAdmissionController) error
MutateKind provides a mutation path for the provided kind (schema) in the mutating webhook, using the provided MutatingAdmissionController for the mutation logic.
func (*Operator) ReconcileKind ¶
func (o *Operator) ReconcileKind(kind resource.Kind, reconciler operator.Reconciler, options ListWatchOptions) error
ReconcileKind will watch the specified kind (schema) with opinionated logic, passing the events on to the provided Reconciler. You can configure the query used for watching the kind using ListWatchOptions.
func (*Operator) RegisterMetricsCollectors ¶
func (o *Operator) RegisterMetricsCollectors(collectors ...prometheus.Collector) error
RegisterMetricsCollectors registers Prometheus collectors with the exporter used by the operator, and will expose those metrics via the metrics endpoint configured in the operator config on Operator.Run
func (*Operator) Run ¶
Run will start the operator and run until stopCh is closed or receives message. While running, the operator will:
* Watch/Reconcile all configured resources
* Expose all configured webhooks as an HTTPS server
* Expose a prometheus metrics endpoint if configured
func (*Operator) ValidateKind ¶
func (o *Operator) ValidateKind(kind resource.Kind, controller resource.ValidatingAdmissionController) error
ValidateKind provides a validation path for the provided kind (schema) in the validating webhook, using the provided ValidatingAdmissionController for the validation logic.
func (*Operator) WatchKind ¶
func (o *Operator) WatchKind(kind resource.Kind, watcher SyncWatcher, options ListWatchOptions) error
WatchKind will watch the specified kind (schema) with opinionated logic, passing the relevant events on to the SyncWatcher. You can configure the query used for watching the kind using ListWatchOptions.
type OperatorConfig ¶
type OperatorConfig struct { Name string KubeConfig rest.Config Webhooks WebhookConfig Metrics MetricsConfig Tracing TracingConfig ErrorHandler func(ctx context.Context, err error) }
OperatorConfig is used to configure an Operator on creation
type Reconciler ¶
type Reconciler struct {
ReconcileFunc func(context.Context, operator.ReconcileRequest) (operator.ReconcileResult, error)
}
Reconciler is a simple Reconciler implementation that calls ReconcileFunc if non-nil on Reconcile requests.
func (*Reconciler) Reconcile ¶
func (s *Reconciler) Reconcile(ctx context.Context, req operator.ReconcileRequest) (operator.ReconcileResult, error)
Reconcile calls ReconcileFunc if non-nil and returns the response, or returns an empty ReconcileResult and nil error if ReconcileFunc is nil.
type SyncWatcher ¶
type SyncWatcher interface { operator.ResourceWatcher // Sync is called for resources which _may_ have experienced updates Sync(context.Context, resource.Object) error }
SyncWatcher extends operator.ResourceWatcher with a Sync method which can be called by the operator.OpinionatedWatcher
type TracingConfig ¶
type TracingConfig struct { Enabled bool OpenTelemetryConfig }
TracingConfig contains configuration information for OpenTelemetry tracing
type Watcher ¶
type Watcher struct { AddFunc func(context.Context, resource.Object) error UpdateFunc func(context.Context, resource.Object, resource.Object) error DeleteFunc func(context.Context, resource.Object) error SyncFunc func(context.Context, resource.Object) error }
Watcher is a struct that implements operator.ResourceWatcher and SyncWatcher, but takes no action on its own. For each method in (Add, Update, Delete) the corresponding exported function field is called, if non-nil.
type WebhookConfig ¶
type WebhookConfig struct { Enabled bool // Port is the port to open the webhook server on Port int // TLSConfig is the TLS Cert and Key to use for the HTTPS endpoints exposed for webhooks TLSConfig k8s.TLSConfig // DefaultValidator is an optional Default ValidatingAdmissionController to use if a specific one for the incoming // kind cannot be found DefaultValidator resource.ValidatingAdmissionController // DefaultMutator is an optional Default MutatingAdmissionController to use if a specific one for the incoming // kind cannot be found DefaultMutator resource.MutatingAdmissionController // Validators is an optional map of schema => ValidatingAdmissionController to use for the schema on admission. // This can be empty or nil and specific ValidatingAdmissionControllers can be set later with Operator.ValidateKind Validators map[*resource.Kind]resource.ValidatingAdmissionController // Mutators is an optional map of schema => MutatingAdmissionController to use for the schema on admission. // This can be empty or nil and specific MutatingAdmissionControllers can be set later with Operator.MutateKind Mutators map[*resource.Kind]resource.MutatingAdmissionController // Converters is an optional map of GroupKind => Converter to use for CRD version conversion requests. // This can be empty or nil and specific MutatingAdmissionControllers can be set later with Operator.MutateKind Converters map[metav1.GroupKind]k8s.Converter }
WebhookConfig is a configuration for exposed kubernetes webhooks for an Operator