Documentation ¶
Index ¶
- func ConfigK8s(ctx context.Context, namespace string, name string) (values map[string]string, err kv.Error)
- func GetPrometheusPort() (port int)
- func InitiateK8s(ctx context.Context, namespace string, cfgMap string, readyC chan struct{}, ...)
- func IsAliveK8s() (err kv.Error)
- func K8sUpdateSecret(config string, secret string, content []byte) (err kv.Error)
- func ListenK8s(ctx context.Context, namespace string, globalMap string, podMap string, ...) (err kv.Error)
- func MonitorK8s(ctx context.Context, errC chan<- kv.Error)
- func StartPrometheusExporter(ctx context.Context, promAddr string, getRsc ResourceAvailable, ...) (err kv.Error)
- func StartTelemetry(ctx context.Context, options StartTelemetryOpts, logger *log.Logger) (newCtx context.Context, err kv.Error)
- type K8sStateUpdate
- type Listeners
- type Resource
- type ResourceAvailable
- type Resources
- type StartTelemetryOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigK8s ¶
func ConfigK8s(ctx context.Context, namespace string, name string) (values map[string]string, err kv.Error)
ConfigK8s is used to pull the values from a named config map in k8s
This function will return an empty map and and error value on failure.
func GetPrometheusPort ¶
func GetPrometheusPort() (port int)
Allows testing software to query which port is being used by the prometheus metrics server resident inside the current server process
func InitiateK8s ¶
func InitiateK8s(ctx context.Context, namespace string, cfgMap string, readyC chan struct{}, staleMsg time.Duration, logger *log.Logger, errorC chan kv.Error)
initiateK8s runs until either ctx is Done or the listener is running successfully
func IsAliveK8s ¶
IsAliveK8s is used to extract any kv.in the state of the k8s client api connection.
A nil returned indicates k8s is working and in use, otherwise a descriptive error is returned.
func K8sUpdateSecret ¶
func ListenK8s ¶
func ListenK8s(ctx context.Context, namespace string, globalMap string, podMap string, updateC chan<- K8sStateUpdate, errC chan<- kv.Error) (err kv.Error)
ListenK8s will register a listener to watch for pod specific configMaps in k8s and will relay state changes to a channel, the global state map should exist at the bare minimum. A state change in either map superseded any previous state.
This is a blocking function that will return either upon an error in API calls to the cluster API or when the ctx is Done().
func MonitorK8s ¶
MonitorK8s is used to send appropriate errors into an error reporting channel on a regular basis if the k8s connectivity state changes
func StartPrometheusExporter ¶
func StartPrometheusExporter(ctx context.Context, promAddr string, getRsc ResourceAvailable, update time.Duration, logger *log.Logger) (err kv.Error)
StartPrometheusExporter loops doing prometheus exports for resource consumption statistics etc on a regular basis
The update interval must be equal to or large than five seconds or an error will be returned
func StartTelemetry ¶
func StartTelemetry(ctx context.Context, options StartTelemetryOpts, logger *log.Logger) (newCtx context.Context, err kv.Error)
StartTelemetry is used to initialize OpenTelemetry tracing, the ctx (context) is used to close the root span when the sever closes the channel. The options structure contains parameters for the OTel code.
Types ¶
type K8sStateUpdate ¶
K8sStateUpdate encapsulates the known kubernetes state within which the server finds itself.
type Listeners ¶
type Listeners struct { Master chan K8sStateUpdate sync.Mutex // contains filtered or unexported fields }
Listeners is used to handle the broadcasting of cluster events when Kubernetes is being used
func K8sStateUpdates ¶
func K8sStateUpdates() (l *Listeners)
func NewStateBroadcast ¶
NewStateBroadcast is used to instantiate a Kubernetes event broadcaster
type Resource ¶
type Resource struct { Cpus uint `json:"cpus"` Gpus uint `json:"gpus"` Hdd string `json:"hdd"` Ram string `json:"ram"` GpuMem string `json:"gpuMem"` GpuCount uint `json:"gpuCount"` }
Resource describes the needed resources for a runner task in a data structure that can be marshalled as json
type ResourceAvailable ¶
type ResourceAvailable interface {
FetchMachineResources() (rsc *Resource)
}
type Resources ¶
type Resources struct{}
Resources is a receiver for resource related methods used to describe machine level capabilities
func (*Resources) FetchMachineResources ¶
FetchMachineResources extracts the current system state in terms of memory etc and coverts this into the resource specification used to pass machine characteristics around.
type StartTelemetryOpts ¶
type StartTelemetryOpts struct { NodeName string // Logical host name for OTel entries ServiceName string // ProjectID string // A project identification string, typically the Go module name ApiKey string // The OTel server API key Dataset string // The OTel dataset identifier for all OTel information ApiEndpoint string // The TCP/IP endpoint for the OTel server, or collector Cooldown time.Duration // The duration of time to wait after a termination signal is received to allow other modules to send events etc and end their own spans Bag *baggage.Baggage // KV Pairs to propagate to all spans }
StartTelemetryOpts is used to specify parameters for starting the OpenTelemetry module