Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultJobTemplate() *corev1.PodTemplateSpec
- func LoadJobTemplate(ctx context.Context, c client.Client, namespace, name string) (*corev1.PodTemplateSpec, error)
- func MergeJobTemplate(template *corev1.PodTemplateSpec, opts JobBuildOptions) *batchv1.Job
- func NewManager(config *rest.Config, options ManagerOptions) (ctrl.Manager, error)
- func Run(ctx context.Context, mgr ctrl.Manager) error
- type ActivityPolicyReconciler
- type JobBuildOptions
- type ManagerOptions
- type ReindexJobReconciler
Constants ¶
const ( // ReindexContainerName is the name of the main container in the Job template. ReindexContainerName = "reindex" // JobTemplateConfigMapKey is the key in the ConfigMap containing the template. JobTemplateConfigMapKey = "template.yaml" )
Variables ¶
var ActivityPolicyGVR = schema.GroupVersionResource{ Group: v1alpha1.GroupName, Version: "v1alpha1", Resource: "activitypolicies", }
ActivityPolicyGVR is the GroupVersionResource for ActivityPolicy.
var ( // Scheme defines the runtime type system for API object serialization. Scheme = runtime.NewScheme() )
Functions ¶
func DefaultJobTemplate ¶
func DefaultJobTemplate() *corev1.PodTemplateSpec
DefaultJobTemplate returns the minimal default PodTemplateSpec when no ConfigMap is provided. This maintains backward compatibility with deployments that don't use a template ConfigMap.
func LoadJobTemplate ¶
func LoadJobTemplate(ctx context.Context, c client.Client, namespace, name string) (*corev1.PodTemplateSpec, error)
LoadJobTemplate loads a PodTemplateSpec from a ConfigMap. The ConfigMap should contain a "template.yaml" key with a PodTemplateSpec.
func MergeJobTemplate ¶
func MergeJobTemplate(template *corev1.PodTemplateSpec, opts JobBuildOptions) *batchv1.Job
MergeJobTemplate creates a Job by merging the template with controller-managed fields. Controller-managed fields (always injected, cannot be overridden):
- Job name: {reindexJobName}-job
- Job namespace: from options
- Container image: from options
- Container args: template args first, then controller args appended
- Labels: app: activity-reindex, reindex.activity.miloapis.com/job: {name}
- BackoffLimit: 3
- TTLSecondsAfterFinished: 300
Template-configurable fields are preserved from the template.
func NewManager ¶
NewManager creates a new controller manager using controller-runtime.
Types ¶
type ActivityPolicyReconciler ¶
type ActivityPolicyReconciler struct {
client.Client
Scheme *runtime.Scheme
RESTMapper meta.RESTMapper
}
ActivityPolicyReconciler reconciles ActivityPolicy resources.
func (*ActivityPolicyReconciler) Reconcile ¶
func (r *ActivityPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile handles the reconciliation of an ActivityPolicy resource.
func (*ActivityPolicyReconciler) SetupWithManager ¶
func (r *ActivityPolicyReconciler) SetupWithManager(mgr ctrl.Manager, maxConcurrentReconciles int) error
SetupWithManager sets up the controller with the Manager.
type JobBuildOptions ¶
type JobBuildOptions struct {
// ReindexJobName is the name of the ReindexJob resource.
ReindexJobName string
// JobNamespace is the namespace where the Job will be created.
JobNamespace string
// ActivityImage is the container image for the reindex worker.
ActivityImage string
// ControllerArgs are the arguments built from NATS config (appended after template args).
ControllerArgs []string
// ResourceRequirements are the resource limits/requests for the container.
ResourceRequirements corev1.ResourceRequirements
// ServiceAccountName overrides the template's service account if set.
ServiceAccountName string
}
JobBuildOptions contains the dynamic values injected by the controller.
type ManagerOptions ¶
type ManagerOptions struct {
// Workers is the number of worker threads for processing items.
Workers int
// MetricsAddr is the address to bind the metrics endpoint.
MetricsAddr string
// HealthProbeAddr is the address to bind the health probe endpoint.
HealthProbeAddr string
// JetStream is the NATS JetStream context for publishing activities (required)
JetStream nats.JetStreamContext
// JobClient is the Kubernetes client for Job operations in the infrastructure cluster
JobClient client.Client
// ReindexJob configuration
ReindexJobNamespace string
ReindexServiceAccount string
ReindexMemoryLimit string
ReindexCPULimit string
MaxConcurrentReindexJobs int
ActivityImage string
NATSURL string
NATSTLSEnabled bool
NATSTLSCertFile string
NATSTLSKeyFile string
NATSTLSCAFile string
// JobTemplate is the PodTemplateSpec for reindex worker Jobs.
// If nil, a default template is used.
JobTemplate *corev1.PodTemplateSpec
}
ManagerOptions contains configuration for the controller manager.
type ReindexJobReconciler ¶
type ReindexJobReconciler struct {
client.Client
JobClient client.Client
Scheme *runtime.Scheme
JetStream nats.JetStreamContext
Recorder record.EventRecorder
// Configuration for Kubernetes Jobs
JobNamespace string
ActivityImage string
ReindexServiceAccount string
ReindexMemoryLimit string
ReindexCPULimit string
MaxConcurrentJobs int
// JobTemplate is the PodTemplateSpec used as a base for worker Jobs.
// This allows operators to configure volumes, security context, etc.
// If nil, a minimal default template is used.
JobTemplate *corev1.PodTemplateSpec
// NATS configuration for worker pods
NATSURL string
NATSTLSEnabled bool
NATSTLSCertFile string
NATSTLSKeyFile string
NATSTLSCAFile string
}
ReindexJobReconciler reconciles ReindexJob resources.
func (*ReindexJobReconciler) Reconcile ¶
func (r *ReindexJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile handles the reconciliation of a ReindexJob resource.
func (*ReindexJobReconciler) SetupWithManager ¶
func (r *ReindexJobReconciler) SetupWithManager(mgr ctrl.Manager, maxConcurrentReconciles int) error
SetupWithManager sets up the controller with the Manager.