controller

package
v0.6.41 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 88 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentRunFinalizer = "deployments.plural.sh/agentrun-protection"

	EnvConsoleURL  = "PLRL_CONSOLE_URL"
	EnvDeployToken = "PLRL_DEPLOY_TOKEN"
	EnvAgentRunID  = "PLRL_AGENT_RUN_ID"

	EnvOpenCodeProvider         = "PLRL_OPENCODE_PROVIDER"
	EnvOpenCodeEndpoint         = "PLRL_OPENCODE_ENDPOINT"
	EnvOpenCodeModel            = "PLRL_OPENCODE_MODEL"
	EnvOpenCodeToken            = "PLRL_OPENCODE_TOKEN"
	EnvOpenCodeOpenAICompatible = "PLRL_OPENCODE_OPENAI_COMPATIBLE"

	EnvClaudeModel              = "PLRL_CLAUDE_MODEL"
	EnvClaudeToken              = "PLRL_CLAUDE_TOKEN"
	EnvClaudeArgs               = "PLRL_CLAUDE_ARGS"
	EnvClaudeBashDefaultTimeout = "PLRL_CLAUDE_BASH_DEFAULT_TIMEOUT"
	EnvClaudeBashMaxTimeout     = "PLRL_CLAUDE_BASH_MAX_TIMEOUT"
	EnvClaudeEndpoint           = "PLRL_CLAUDE_ENDPOINT"

	EnvGeminiModel             = "PLRL_GEMINI_MODEL"
	EnvGeminiAPIKey            = "PLRL_GEMINI_API_KEY"
	EnvGeminiInactivityTimeout = "PLRL_GEMINI_INACTIVITY_TIMEOUT"
	EnvGeminiEndpoint          = "PLRL_GEMINI_ENDPOINT"

	EnvCodexModel    = "PLRL_CODEX_MODEL"
	EnvCodexAPIKey   = "PLRL_CODEX_API_KEY"
	EnvCodexEndpoint = "PLRL_CODEX_ENDPOINT"

	EnvDindEnabled    = "PLRL_DIND_ENABLED"
	EnvBrowserEnabled = "PLRL_BROWSER_ENABLED"
	EnvExecTimeout    = "PLRL_EXEC_TIMEOUT"

	EnvGitProxy = "PLRL_GIT_PROXY"

	EnvExaConnection   = "PLRL_EXA_CONNECTION"
	EnvMcpExcludeTools = "PLRL_EXCLUDE_TOOLS"
)
View Source
const (
	AgentRuntimeFinalizer = "deployments.plural.sh/agent-runtime-protection"
)
View Source
const PluralCAPIClusterFinalizer = "deployments.plural.sh/plural-capi-cluster-protection"
View Source
const (
	SentinelRunJobFinalizer = "deployments.plural.sh/sentinel-run-job-protection"
)
View Source
const StackRunJobFinalizer = "deployments.plural.sh/stack-run-job-protection"
View Source
const (
	VirtualClusterFinalizer = "deployments.plural.sh/virtualcluster-protection"
)

Variables

This section is empty.

Functions

func CreateConfigMap

func CreateConfigMap(ctx context.Context, client k8sClient.Client, restore *velerov1.Restore) error

func ExtractResourceRequests

func ExtractResourceRequests(obj *unstructured.Unstructured) map[string]*ResourceRequests

ExtractResourceRequests fetches CPU and memory requests from an Unstructured Kubernetes workload object.

func GetObjectFromOwnerReference

func GetObjectFromOwnerReference(ctx context.Context, client k8sClient.Client, ref v1.OwnerReference, namespace string) (*unstructured.Unstructured, error)

func IsJobStatusConditionPresentAndEqual

func IsJobStatusConditionPresentAndEqual(conditions []batchv1.JobCondition, conditionType batchv1.JobConditionType, status corev1.ConditionStatus) bool

IsJobStatusConditionPresentAndEqual returns true when conditionType is present and equal to status.

func IsJobStatusConditionTrue

func IsJobStatusConditionTrue(conditions []batchv1.JobCondition, conditionType batchv1.JobConditionType) bool

IsJobStatusConditionTrue returns true when the conditionType is present and set to `metav1.ConditionTrue`

func Job

Job reconciles a k8s job object.

func LogOverriddenCRDValues

func LogOverriddenCRDValues(ctx context.Context, spec v1alpha1.AgentConfigurationSpec)

Types

type AgentConfigurationReconciler

type AgentConfigurationReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

func (*AgentConfigurationReconciler) Reconcile

func (r *AgentConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

Reconcile AgentConfiguration custom resources to ensure that Console stays in sync with Kubernetes cluster.

func (*AgentConfigurationReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type AgentRunReconciler

type AgentRunReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	ConsoleClient    pluralclient.Client
	ConsoleURL       string
	DeployToken      string
	CacheSyncTimeout time.Duration
}

AgentRunReconciler is a controller for the AgentRun custom resource. It manages the lifecycle of individual agent runs by: 1. Creating pods to execute agent tasks 2. Monitoring pod status and updating AgentRun status 3. Reporting status back to Console API

func (*AgentRunReconciler) Reconcile

func (r *AgentRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, retErr error)

func (*AgentRunReconciler) SetupWithManager

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

SetupWithManager configures the controller with the manager.

type AgentRuntimeReconciler

type AgentRuntimeReconciler struct {
	client.Client
	ConsoleClient    consoleclient.Client
	Scheme           *runtime.Scheme
	CacheSyncTimeout time.Duration
	Ctx              context.Context
	ClusterID        string
}

AgentRuntimeReconciler reconciles a AgentRuntime object

func (*AgentRuntimeReconciler) Publish

func (r *AgentRuntimeReconciler) Publish(runID string, kick bool)

func (*AgentRuntimeReconciler) Reconcile

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

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile

func (*AgentRuntimeReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type ArgoRolloutReconciler

type ArgoRolloutReconciler struct {
	k8sClient.Client
	Scheme        *runtime.Scheme
	ConsoleClient client.Client
	ConsoleURL    string
	HttpClient    *http.Client
	ArgoClientSet roclientset.Interface
	DynamicClient dynamic.Interface
	KubeClient    kubernetes.Interface
	SvcReconciler v1.Reconciler
}

ArgoRolloutReconciler reconciles a Argo Rollout custom resource.

func (*ArgoRolloutReconciler) Reconcile

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

Reconcile Argo Rollout custom resources to ensure that Console stays in sync with Kubernetes cluster.

func (*ArgoRolloutReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type BackupReconciler

type BackupReconciler struct {
	k8sClient.Client
	Scheme        *runtime.Scheme
	ConsoleClient client.Client
}

BackupReconciler reconciles a Velero Backup custom resource.

func (*BackupReconciler) Reconcile

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

Reconcile Velero Backup custom resources to ensure that Console stays in sync with Kubernetes cluster.

func (*BackupReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type BundleData

type BundleData struct {
	Description       string `json:"description" yaml:"description"`
	Severity          string `json:"severity" yaml:"severity"`
	BundleName        string `json:"bundleName" yaml:"bundleName"`
	BundleDisplayName string `json:"bundleDisplayName" yaml:"bundleDisplayName"`
	Remediation       string `json:"remediation" yaml:"remediation"`
}

type CloudProvider

type CloudProvider interface {
	UpgradeInsights(context.Context, v1alpha1.UpgradeInsights) ([]console.UpgradeInsightAttributes, []console.CloudAddonAttributes, error)
}

func NewCloudProvider

func NewCloudProvider(distro *console.ClusterDistro, kubeClient runtimeclient.Client, clusterName string) (CloudProvider, error)

type ClusterDrainReconciler

type ClusterDrainReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ClusterDrainReconciler reconciles a ClusterDrain object

func (*ClusterDrainReconciler) Reconcile

func (r *ClusterDrainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

Reconcile executes the drain logic once per ClusterDrain object

func (*ClusterDrainReconciler) SetupWithManager

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

SetupWithManager registers the controller

type ConstraintReconciler

type ConstraintReconciler struct {
	k8sClient.Client
	Scheme        *runtime.Scheme
	ConsoleClient consoleclient.Client
	Reader        k8sClient.Reader
	Constraints   map[string]console.PolicyConstraintAttributes
}

func (*ConstraintReconciler) ConstraintPodStatusToUnstructured

func (*ConstraintReconciler) Reconcile

func (*ConstraintReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type CrdRegisterControllerReconciler

type CrdRegisterControllerReconciler struct {
	k8sClient.Client
	Scheme           *runtime.Scheme
	ReconcilerGroups map[schema.GroupVersionKind]SetupWithManager
	Mgr              ctrl.Manager
	DiscoveryCache   discoverycache.Cache
	// contains filtered or unexported fields
}

CrdRegisterControllerReconciler reconciles a custom resource.

func (*CrdRegisterControllerReconciler) Reconcile

Reconcile Custom resources to ensure that Console stays in sync with Kubernetes cluster.

func (*CrdRegisterControllerReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type CustomHealthReconciler

type CustomHealthReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

CustomHealthReconciler reconciles a LuaScript object

func (*CustomHealthReconciler) Reconcile

func (r *CustomHealthReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile

func (*CustomHealthReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type DebounceReconciler

type DebounceReconciler struct {
	client.Client
	// contains filtered or unexported fields
}

DebounceReconciler is a Reconciler that debounces reconcile requests.

func NewDebounceReconciler

func NewDebounceReconciler(client client.Client, duration time.Duration, actual reconcile.Reconciler) *DebounceReconciler

NewDebounceReconciler creates a new DebounceReconciler.

func (*DebounceReconciler) Reconcile

Reconcile implements the reconcile.Reconciler interface.

func (*DebounceReconciler) Start

func (r *DebounceReconciler) Start(ctx context.Context)

Start begins the debouncing mechanism.

type DefaultScope

type DefaultScope[T client.Object] struct {
	// contains filtered or unexported fields
}

func (*DefaultScope[T]) PatchObject

func (in *DefaultScope[T]) PatchObject() error

type EKSCloudProvider

type EKSCloudProvider struct {
	// contains filtered or unexported fields
}

type HelmReleaseReconciler

type HelmReleaseReconciler struct {
	client.Client
	Scheme    *runtime.Scheme
	ClientSet kubernetes.Interface
}

func (*HelmReleaseReconciler) Reconcile

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

Reconcile executes the drain logic once per HelmRelease object

func (*HelmReleaseReconciler) SetupWithManager

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

SetupWithManager registers the controller

type IngressReplicaReconciler

type IngressReplicaReconciler struct {
	k8sClient.Client
	Scheme *runtime.Scheme
}

IngressReplicaReconciler reconciles a IngressReplica resource.

func (*IngressReplicaReconciler) Reconcile

func (r *IngressReplicaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

Reconcile IngressReplica ensure that stays in sync with Kubernetes cluster.

func (*IngressReplicaReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type K8sObjectIdentifier

type K8sObjectIdentifier struct {
	GVK       schema.GroupVersionKind // Group, Version, Kind
	Namespace string                  // Namespace (empty for cluster-scoped objects)
	Name      string                  // Name
}

func (K8sObjectIdentifier) String

func (gvk K8sObjectIdentifier) String() string

type KubecostExtractorReconciler

type KubecostExtractorReconciler struct {
	client.Client
	Scheme           *runtime.Scheme
	KubeClient       kubernetes.Interface
	ExtConsoleClient consoleclient.Client
	Tasks            cmap.ConcurrentMap[string, context.CancelFunc]
	ServiceIDCache   *ServiceIDCache
	Proxy            bool
}

KubecostExtractorReconciler reconciles a KubecostExtractor object

func (*KubecostExtractorReconciler) Reconcile

func (r *KubecostExtractorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.16.3/pkg/reconcile

func (*KubecostExtractorReconciler) RunOnInterval

func (r *KubecostExtractorReconciler) RunOnInterval(ctx context.Context, key string, interval time.Duration, condition wait.ConditionWithContextFunc)

func (*KubecostExtractorReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type MetricsAggregateReconciler

type MetricsAggregateReconciler struct {
	k8sClient.Client
	Scheme         *runtime.Scheme
	DiscoveryCache discoverycache.Cache
}

MetricsAggregateReconciler reconciles a MetricsAggregate resource.

func (*MetricsAggregateReconciler) Reconcile

func (r *MetricsAggregateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

Reconcile IngressReplica ensure that stays in sync with Kubernetes cluster.

func (*MetricsAggregateReconciler) SetupWithManager

func (r *MetricsAggregateReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type PipelineGateReconciler

type PipelineGateReconciler struct {
	runtimeclient.Client
	ConsoleClient consoleclient.Client
	Scheme        *runtime.Scheme
	GateCache     *cache.Cache[console.PipelineGateFragment]
}

PipelineGateReconciler reconciles a PipelineGate object

func (*PipelineGateReconciler) Reconcile

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

func (*PipelineGateReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type PluralCAPIClusterController

type PluralCAPIClusterController struct {
	k8sClient.Client
	Scheme     *runtime.Scheme
	ConsoleUrl string
	// contains filtered or unexported fields
}

func (*PluralCAPIClusterController) Reconcile

func (in *PluralCAPIClusterController) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, reterr error)

func (*PluralCAPIClusterController) SetupWithManager

func (in *PluralCAPIClusterController) SetupWithManager(mgr ctrl.Manager) error

type ResourceRequests

type ResourceRequests struct {
	CPU    float64
	Memory float64
}

type RestoreReconciler

type RestoreReconciler struct {
	k8sClient.Client
	Scheme        *runtime.Scheme
	ConsoleClient client.Client
}

RestoreReconciler reconciles a Velero Restore custom resource.

func (*RestoreReconciler) Reconcile

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

Reconcile Velero Restore custom resources to ensure that Console stays in sync with Kubernetes cluster.

func (*RestoreReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type Scope

type Scope[T client.Object] interface {
	PatchObject() error
}

func NewDefaultScope

func NewDefaultScope[T client.Object](ctx context.Context, client client.Client, object T) (Scope[T], error)

type SentinelRunJobReconciler

type SentinelRunJobReconciler struct {
	client.Client
	ConsoleClient consoleclient.Client
	Scheme        *runtime.Scheme
	ConsoleURL    string
	DeployToken   string
}

func (*SentinelRunJobReconciler) GenerateRunJob

func (r *SentinelRunJobReconciler) GenerateRunJob(run *console.SentinelRunJobFragment, jobSpec *batchv1.JobSpec, name, namespace string) (*batchv1.Job, error)

func (*SentinelRunJobReconciler) GetRunResourceName

func (r *SentinelRunJobReconciler) GetRunResourceName(run *console.SentinelRunJobFragment) string

GetRunResourceName returns a resource name used for a job and a secret connected to a given run.

func (*SentinelRunJobReconciler) Reconcile

func (r *SentinelRunJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, retErr error)

func (*SentinelRunJobReconciler) SetupWithManager

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

SetupWithManager configures the controller with the manager.

type ServiceIDCache

type ServiceIDCache struct {
	// contains filtered or unexported fields
}

func NewServiceIDCache

func NewServiceIDCache(clearAfter time.Duration) *ServiceIDCache

NewServiceIDCache self-cleaning cache

func (*ServiceIDCache) Get

func (*ServiceIDCache) Set

func (c *ServiceIDCache) Set(key K8sObjectIdentifier, value string)

type SetupWithManager

type SetupWithManager func(mgr ctrl.Manager) error

type StackRunJobReconciler

type StackRunJobReconciler struct {
	k8sClient.Client
	Scheme        *runtime.Scheme
	ConsoleClient client.Client
	ConsoleURL    string
	DeployToken   string
}

StackRunJobReconciler reconciles a Job resource.

func (*StackRunJobReconciler) GenerateRunJob

func (r *StackRunJobReconciler) GenerateRunJob(run *console.StackRunMinimalFragment, jobSpec *batchv1.JobSpec, name, namespace string) (*batchv1.Job, error)

func (*StackRunJobReconciler) GetRunResourceName

func (r *StackRunJobReconciler) GetRunResourceName(run *console.StackRunMinimalFragment) string

GetRunResourceName returns a resource name used for a job and a secret connected to a given run.

func (*StackRunJobReconciler) Reconcile

func (r *StackRunJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ reconcile.Result, retErr error)

Reconcile StackRun's Job ensure that Console stays in sync with Kubernetes cluster.

func (*StackRunJobReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager.

type StatusViolation

type StatusViolation struct {
	Group     string `json:"group"`
	Version   string `json:"version"`
	Kind      string `json:"kind"`
	Name      string `json:"name"`
	Namespace string `json:"namespace,omitempty"`
	Message   string `json:"message"`
}

type UpgradeInsightsController

type UpgradeInsightsController struct {
	k8sClient.Client

	Scheme        *runtime.Scheme
	ConsoleClient client.Client
	// contains filtered or unexported fields
}

UpgradeInsightsController reconciler a v1alpha1.UpgradeInsights resource. Implements reconcile.Reconciler interface.

func (*UpgradeInsightsController) Reconcile

func (in *UpgradeInsightsController) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, reterr error)

func (*UpgradeInsightsController) SetupWithManager

func (in *UpgradeInsightsController) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type VirtualClusterController

type VirtualClusterController struct {
	k8sClient.Client

	Scheme           *runtime.Scheme
	ExtConsoleClient client.Client
	ConsoleUrl       string
	// contains filtered or unexported fields
}

VirtualClusterController reconciler a v1alpha1.VirtualCluster resource. Implements reconcile.Reconciler interface.

func (*VirtualClusterController) Reconcile

func (in *VirtualClusterController) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, reterr error)

func (*VirtualClusterController) SetupWithManager

func (in *VirtualClusterController) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type VulnerabilityReportReconciler

type VulnerabilityReportReconciler struct {
	k8sClient.Client
	Scheme        *runtime.Scheme
	ConsoleClient client.Client
	Ctx           context.Context
	// contains filtered or unexported fields
}

VulnerabilityReportReconciler reconciles a Trivy VulnerabilityReport resource.

func (*VulnerabilityReportReconciler) Reconcile

func (*VulnerabilityReportReconciler) SetupWithManager

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

Jump to

Keyboard shortcuts

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