runtime

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HostPodLabel is a marker label that must be present on host Pods.
	// No specific value is required — its presence is enough to opt the Pod
	// into lifecycle tracking. The operator maps the Pod to its Host CRD via
	// pod.Status.PodIP, which matches Host.Hostname (set from req.Hostname in
	// the NATS heartbeat). Using PodIP means the HostGroup deployment template
	// does not need to know the wasmCloud host ID ahead of time.
	HostPodLabel = "wasmcloud.com/hostgroup"
)
View Source
const HostRoundtripTimeout = 1 * time.Minute

HostRoundtripTimeout is the max timeout for host RPC calls. Callers can set lower context timeouts as needed.

Variables

This section is empty.

Functions

func MaterializeConfigLayer

func MaterializeConfigLayer(ctx context.Context,
	kubeClient client.Client, namespace string, configLayer *runtimev1alpha1.ConfigLayer,
) (map[string]string, error)

func MaterializeImagePullSecret

func MaterializeImagePullSecret(ctx context.Context,
	kubeClient client.Client,
	namespace string,
	name string,
	image string,
) (*runtimev2.ImagePullSecret, error)

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps merges multiple maps of strings into a single map.

func ResolveConfigFrom

func ResolveConfigFrom(ctx context.Context, kubeClient client.Client, namespace string, configFrom []corev1.LocalObjectReference) (map[string]string, error)

func ResolveSecretFrom

func ResolveSecretFrom(ctx context.Context, kubeClient client.Client, namespace string, secretFrom []corev1.LocalObjectReference) (map[string]string, error)

func RoundTrip

func RoundTrip[Req proto.Message, Resp proto.Message](ctx context.Context, bus wasmbus.Bus, subject string, req Req, resp Resp) error

RoundTrip sends a request and waits for a response.

Types

type ArtifactReconciler

type ArtifactReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

ArtifactReconciler reconciles a Workload object

func (*ArtifactReconciler) Reconcile

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

func (*ArtifactReconciler) SetupWithManager

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

type HostPodReconciler added in v2.0.2

type HostPodReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	// OperatorNamespace is the namespace where Host CRDs live.
	OperatorNamespace string
}

HostPodReconciler bridges Pod lifecycle to Host CRD lifecycle.

It adds a finalizer to every Pod labeled with HostPodLabel. When a Pod is deleted (DeletionTimestamp set), the finalizer fires and the corresponding Host CRD — identified by matching Host.Hostname to pod.Status.PodIP — is deleted before Kubernetes removes the Pod from etcd.

Deleting the Host CRD triggers the HostReconciler finalizer, which in turn deletes all Workload objects assigned to that host. This replaces the previous path where the operator waited for up to UnreachableTimeout + hostReconcileInterval (≈2 min) to discover a dead host via missed heartbeats.

Pod side may be cross-namespace: host Pods can run in any namespace listed in operator.hostNamespaces. Host side is single-namespace: every Host CRD lives in the operator's own namespace.

func (*HostPodReconciler) Reconcile added in v2.0.2

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

Reconcile is called whenever a Pod with HostPodLabel changes.

+kubebuilder:rbac:groups="",resources=pods,verbs=get;list;patch;watch +kubebuilder:rbac:groups=runtime.wasmcloud.dev,resources=hosts,verbs=get;list;delete

func (*HostPodReconciler) SetupWithManager added in v2.0.2

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

SetupWithManager registers the controller and the Host field index it depends on.

type HostReconciler

type HostReconciler struct {
	client.Client
	Scheme             *runtime.Scheme
	Bus                wasmbus.Bus
	UnreachableTimeout time.Duration
	CPUThreshold       float64
	MemoryThreshold    float64
	// OperatorNamespace is the namespace the operator itself runs in. Every
	// Host object is created here regardless of where the underlying host
	// pod runs; tenant attribution lives on the Host's Environment field.
	OperatorNamespace string
	// contains filtered or unexported fields
}

HostReconciler reconciles a Host object

func (*HostReconciler) Reconcile

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

func (*HostReconciler) SetupWithManager

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

type WashHostClient

type WashHostClient struct {
	Bus    wasmbus.Bus
	HostID string
}

func NewWashHostClient

func NewWashHostClient(bus wasmbus.Bus, hostID string) *WashHostClient

func (*WashHostClient) Heartbeat

func (*WashHostClient) Start

func (*WashHostClient) Status

func (*WashHostClient) Stop

type WorkloadDeploymentReconciler

type WorkloadDeploymentReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

WorkloadDeploymentReconciler reconciles a WorkloadReplicaSet object

func (*WorkloadDeploymentReconciler) Reconcile

func (*WorkloadDeploymentReconciler) SetupWithManager

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

type WorkloadReconciler

type WorkloadReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Bus      wasmbus.Bus
	Recorder events.EventRecorder
	// OperatorNamespace is the namespace every Host CRD lives in. The
	// scheduler always lists Hosts in this namespace; tenant boundaries
	// are enforced via the Host.Environment field, not via Host.Namespace.
	OperatorNamespace string
	// AllowSharedHosts controls whether a Workload may schedule onto a Host
	// whose Environment differs from the Workload's own namespace (via
	// Spec.Environment). When false, cross-tenant scheduling is rejected
	// and a Warning Event is recorded on the Workload.
	AllowSharedHosts bool
	// contains filtered or unexported fields
}

WorkloadReconciler reconciles a Workload object

func (*WorkloadReconciler) Reconcile

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

func (*WorkloadReconciler) SetupWithManager

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

type WorkloadReplicaSetReconciler

type WorkloadReplicaSetReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	// contains filtered or unexported fields
}

WorkloadReplicaSetReconciler reconciles a WorkloadReplicaSet object

func (*WorkloadReplicaSetReconciler) Reconcile

func (*WorkloadReplicaSetReconciler) SetupWithManager

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

type WorkloadRouteReconciler added in v2.0.3

type WorkloadRouteReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	// OperatorNamespace is where every Host CRD lives.
	OperatorNamespace string
}

WorkloadRouteReconciler maintains EndpointSlices for Kubernetes Services referenced by WorkloadDeployments. When a Workload becomes ready, this reconciler ensures the Service's EndpointSlice contains the pod IP of the host running that workload.

func (*WorkloadRouteReconciler) Reconcile added in v2.0.3

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

Reconcile is keyed on namespace/service-name (not workload name) so that a single reconciliation pass can collect all Ready workloads for a given Service and produce an authoritative EndpointSlice.

func (*WorkloadRouteReconciler) SetupWithManager added in v2.0.3

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

SetupWithManager sets up the controller with the Manager. +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices,verbs=create;delete;get;list;patch;update;watch +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch

Source Files

  • artifact_controller.go
  • host_client.go
  • host_controller.go
  • host_pod_controller.go
  • utils.go
  • workload_controller.go
  • workload_deployment_controller.go
  • workload_replicaset_controller.go
  • workload_route_controller.go

Jump to

Keyboard shortcuts

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