Documentation
¶
Index ¶
- Constants
- Variables
- type Backoff
- type ClientOption
- type ClientOptionConfigHost
- type ClientOptionScheme
- type ClientOptionSkipVerifyTLS
- type ClientOptionTimeout
- type ClientOptionUserAgent
- type ClientOptions
- type Config
- func (cc *Config) CACertHashes(ctx context.Context) ([]string, error)
- func (cc *Config) Client(ctx context.Context, opts ...ClientOption) (client.Client, error)
- func (cc *Config) Clientset(ctx context.Context, opts ...ClientOption) (*kubernetes.Clientset, []byte, error)
- func (cc *Config) ClusterNamespaceName() string
- func (cc *Config) Kubeconfig(ctx context.Context) (*clientcmdv1.Config, error)
- func (cc *Config) Server(ctx context.Context) (string, error)
- type Health
- type Option
- type OptionDisableFor
- type OptionHostClient
- type OptionInitialSyncTimeout
- type OptionRequeueAfter
- type OptionScheme
- type OptionSyncPeriod
- type OptionTimeout
- type OptionUserAgent
- type Options
- type RemoteCache
- func (rc *RemoteCache) GetClient(cluster client.ObjectKey) (client.Client, error)
- func (rc *RemoteCache) ListClients() ([]client.Client, error)
- func (rc *RemoteCache) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)
- func (rc *RemoteCache) Watch(ctx context.Context, cluster client.ObjectKey, watcher Watcher) error
- type SourceWatcher
- type TypedWatcherOptions
- type Watcher
- type WatcherOptions
Constants ¶
const ( // HealthStatusHealthy is the status of the dpu cluster when it is healthy HealthStatusHealthy = "Healthy" // HealthStatusUnhealthy is the status of the dpu cluster when it is unhealthy HealthStatusUnhealthy = "Unhealthy" // HealthStatusUnknown is the status of the dpu cluster when it is unknown HealthStatusUnknown = "Unknown" )
const ( // DefaultMaxRetries is the default maximum number of retries DefaultMaxRetries = 5 // DefaultMaxBackoff is the default maximum backoff duration DefaultMaxBackoff = 10 * time.Minute )
Variables ¶
var ErrDPUClusterNotConnected = fmt.Errorf("dpu cluster is not connected")
ErrDPUClusterNotConnected is returned when a dpu cluster that is not connected.
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff is a struct that implements a backoff algorithm.
func NewBackoff ¶
NewBackoff creates a new Backoff instance. It takes a duration, a factor and a jitter as parameters.
func (*Backoff) GetNextBackOff ¶
GetNextBackOff returns the backoff duration for the given attempt. The backoff is calculated as:
temp = backoff * factor ^ attempt interval = temp * (1 - jitter) + rand.Int64N(2 * jitter * temp)
e.g backoff = 1s, factor = 2, jitter = 0.1 interval will be >= 0.9s and < 1.1s which means 10% jitter
type ClientOption ¶
type ClientOption interface {
Apply(options *ClientOptions)
}
type ClientOptionConfigHost ¶
type ClientOptionConfigHost struct {
Host string
}
ClientOptionConfigHost overrides the host used for the REST config.
func (ClientOptionConfigHost) Apply ¶
func (o ClientOptionConfigHost) Apply(options *ClientOptions)
type ClientOptionScheme ¶
ClientOptionScheme is the scheme used for the client.
func (ClientOptionScheme) Apply ¶
func (o ClientOptionScheme) Apply(options *ClientOptions)
type ClientOptionSkipVerifyTLS ¶
type ClientOptionSkipVerifyTLS struct {
SkipVerifyTLS bool
}
ClientOptionSkipVerifyTLS is the option to skip TLS verification for the REST config.
func (ClientOptionSkipVerifyTLS) Apply ¶
func (o ClientOptionSkipVerifyTLS) Apply(options *ClientOptions)
type ClientOptionTimeout ¶
ClientOptionTimeout is the timeout used for the REST config, client and cache.
func (ClientOptionTimeout) Apply ¶
func (o ClientOptionTimeout) Apply(options *ClientOptions)
type ClientOptionUserAgent ¶
type ClientOptionUserAgent struct {
UserAgent string
}
ClientOptionUserAgent is the user agent used for the REST config, client and cache.
func (ClientOptionUserAgent) Apply ¶
func (o ClientOptionUserAgent) Apply(options *ClientOptions)
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
ClientOptions holds the options for the client.
type Config ¶
type Config struct { // Cluster is the DPU cluster for which the config is being fetched. Cluster *provisioningv1.DPUCluster // contains filtered or unexported fields }
Config hold the cluster configuration. It provides methods to get the client, clientset, and rest config for the cluster.
func GetConfigs ¶
GetConfigs returns a list of Configs for all DPU clusters.
func K8sClusterToDPUClusterConfig ¶
func K8sClusterToDPUClusterConfig(c client.Reader, cluster *provisioningv1.K8sCluster) *Config
K8sClusterToDPUClusterConfig converts a provisioningv1.K8sCluster to a provisioningv1.DPUCluster. It is used to further fetch/list objects from the DPUCluster.
func NewConfig ¶
func NewConfig(c client.Reader, cluster *provisioningv1.DPUCluster) *Config
NewConfig returns a new Config.
func (*Config) CACertHashes ¶
CACertHashes returns the hashes of the CAs contained in the cluster config. These hashes are used to authenticate with kubelet when joining nodes to the cluster. The reference implementation for this function is from kubeadm: https://github.com/kubernetes/kubernetes/blob/78cb3862f11225135afdf76f3424e2d7b33104c7/cmd/kubeadm/app/cmd/util/join.go#L52
func (*Config) Clientset ¶
func (cc *Config) Clientset(ctx context.Context, opts ...ClientOption) (*kubernetes.Clientset, []byte, error)
Clientset returns a new clientset for the cluster.
func (*Config) ClusterNamespaceName ¶
func (*Config) Kubeconfig ¶
Kubeconfig returns the kubeconfig for the cluster.
type Health ¶
type Health struct { Backoff // contains filtered or unexported fields }
Health is the struct that implements the health check for the dpu cluster.
func NewHealthServer ¶
func NewHealthServer(client discovery.ServerVersionInterface, maxBackoff time.Duration, maxRetries int, interval time.Duration) *Health
NewHealthServer creates a new Health instance.
func (*Health) Check ¶
Check checks the health of the dpu cluster. It returns the status of the dpu cluster and an error if the check fails after all retries. If the check is successful, it returns the status as "Healthy" and nil error.
func (*Health) GetNextCheckTime ¶
GetNextCheckTime returns the next check time for the health check. It uses the backoff algorithm to calculate the next check time.
type OptionDisableFor ¶
OptionDisableFor is a list of objects for which the cache should be disabled.
func (OptionDisableFor) Apply ¶
func (o OptionDisableFor) Apply(options *Options)
type OptionHostClient ¶
OptionHostClient is the client for the host cluster. It is used to fetch the kubeconfig secret.
func (OptionHostClient) Apply ¶
func (o OptionHostClient) Apply(options *Options)
type OptionInitialSyncTimeout ¶
OptionInitialSyncTimeout is the timeout used when waiting for the cache to sync after cache start.
func (OptionInitialSyncTimeout) Apply ¶
func (o OptionInitialSyncTimeout) Apply(options *Options)
type OptionRequeueAfter ¶
OptionRequeueAfter tells the remoteCacheReconciler to requeue after the given duration.
func (OptionRequeueAfter) Apply ¶
func (o OptionRequeueAfter) Apply(options *Options)
type OptionScheme ¶
OptionScheme is the scheme used for the client and the cache.
func (OptionScheme) Apply ¶
func (o OptionScheme) Apply(options *Options)
type OptionSyncPeriod ¶
OptionSyncPeriod is the sync period of the cache.
func (OptionSyncPeriod) Apply ¶
func (o OptionSyncPeriod) Apply(options *Options)
type OptionTimeout ¶
OptionTimeout is the timeout used for the REST config, client and cache.
func (OptionTimeout) Apply ¶
func (o OptionTimeout) Apply(options *Options)
type OptionUserAgent ¶
type OptionUserAgent struct {
UserAgent string
}
OptionUserAgent is the user agent used for the REST config, client and cache.
func (OptionUserAgent) Apply ¶
func (o OptionUserAgent) Apply(options *Options)
type Options ¶
type Options struct { ClientOptions // contains filtered or unexported fields }
type RemoteCache ¶
type RemoteCache struct { // Lock to synchronize acess to accessors. sync.RWMutex // contains filtered or unexported fields }
RemoteCache reconcile dpuClusters CRs and manges caches for those dpuClusters. It provides a way to watch dpuClusters and get cachedClients for dpuClusters. Specific objects can be watched in the dpu cluster.
func SetupRemoteCacheWithManager ¶
func SetupRemoteCacheWithManager(ctx context.Context, mgr ctrl.Manager, opts ...Option) (*RemoteCache, error)
SetupRemoteCacheWithManager sets up a remoteCacheReconciler with the given Manager and Options. This will add a reconciler to the Manager and returns a remoteCacheReconciler which can be used to retrieve e.g. Clients for a given Cluster.
func (*RemoteCache) GetClient ¶
GetClient returns a client for the given dpu cluster. It is a cached client that read from the given dpu cluster cache.
func (*RemoteCache) ListClients ¶
func (rc *RemoteCache) ListClients() ([]client.Client, error)
ListClients returns a list of cached clients for all dpu clusters present in RemoteCache.
func (*RemoteCache) Reconcile ¶
func (rc *RemoteCache) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error)
Reconcile reconciles Clusters and manages corresponding accessors.
func (*RemoteCache) Watch ¶
Watch can be used to watch specific resources in the dpu cluster. e.g.:
err := RemoteCache.Watch(ctx, util.ObjectKey(cluster), clustercache.NewWatcher(clustercache.WatcherOptions{ Name: "watch-DPUNodes", Watcher: r.controller, Kind: &provisionningv1aplha1.DPUNode{}, EventHandler: handler.EnqueueRequestsFromMapFunc(r.dpuNodeToVPC), })
type SourceWatcher ¶
type SourceWatcher[request comparable] interface { Watch(src source.TypedSource[request]) error }
SourceWatcher is a scoped-down interface from Controller that only has the Watch func.
type TypedWatcherOptions ¶
type TypedWatcherOptions[object client.Object, request comparable] struct { // Name represents a unique Watch request for the specified Cluster. Name string // Watcher is the watcher (controller) whose Reconcile() function will be called for events. Watcher SourceWatcher[request] // Kind is the type of resource to watch. Kind object // EventHandler contains the event handlers to invoke for resource events. EventHandler handler.TypedEventHandler[object, request] // Predicates is used to filter resource events. Predicates []predicate.TypedPredicate[object] }
TypedWatcherOptions specifies the parameters used to establish a new watch for a dpu cluster. A source.TypedKind source (configured with Kind, TypedEventHandler and Predicates) will be added to the Watcher. To watch for events, the source.TypedKind will create an informer on the Cache that we have created and cached for the given Cluster.
type Watcher ¶
Watcher is an interface that can start a Watch.
func NewWatcher ¶
func NewWatcher[object client.Object, request comparable](options TypedWatcherOptions[object, request]) Watcher
NewWatcher creates a Watcher for the dpu cluster. A source.TypedKind source (configured with Kind, TypedEventHandler and Predicates) will be added to the SourceWatcher. To watch for events, the source.TypedKind will create an informer on the Cache that we have created and cached for the given Cluster.
type WatcherOptions ¶
type WatcherOptions = TypedWatcherOptions[client.Object, ctrl.Request]
WatcherOptions specifies the parameters used to establish a new watch for a dpu cluster. A source.TypedKind source (configured with Kind, TypedEventHandler and Predicates) will be added to the Watcher. To watch for events, the source.TypedKind will create an informer on the Cache that we have created and cached for the given Cluster.