controller

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package controller implements the Kubernetes controllers (reconcilers) for the NGINX Operator CRDs. Each controller watches its respective CRD and reconciles the desired state into the cluster.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NginxRouteReconciler

type NginxRouteReconciler struct {
	client.Client
	Scheme    *runtime.Scheme
	ConfigGen *config.Generator
}

NginxRouteReconciler reconciles NginxRoute objects. When an NginxRoute is created, updated, or deleted, this controller triggers a re-reconciliation of the referenced NginxServer to regenerate the full config.

The reconciliation loop:

  1. Fetches the NginxRoute resource
  2. Validates the spec
  3. Ensures the referenced NginxServer exists
  4. Triggers NginxServer reconciliation by updating its annotation
  5. Updates NginxRoute status

func (*NginxRouteReconciler) Reconcile

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

Reconcile handles NginxRoute create/update/delete events. It validates the route configuration and triggers the parent NginxServer to regenerate its NGINX configuration.

func (*NginxRouteReconciler) SetupWithManager

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

SetupWithManager sets up the NginxRoute controller with the Manager. It watches NginxRoute resources and triggers NginxServer reconciliation when routes change.

type NginxServerReconciler

type NginxServerReconciler struct {
	client.Client
	Scheme      *runtime.Scheme
	ConfigGen   *config.Generator
	ResourceMgr *nginx.ResourceManager
	ReloaderTag string
}

NginxServerReconciler reconciles NginxServer objects. It creates and manages Deployments, Services, and ConfigMaps for NGINX instances.

The reconciliation loop:

  1. Fetches the NginxServer resource
  2. Handles finalizer for cleanup
  3. Collects associated NginxRoute and NginxUpstream resources
  4. Generates NGINX configuration
  5. Creates/updates ConfigMap, Deployment, and Service
  6. Updates status with current state

func (*NginxServerReconciler) Reconcile

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

Reconcile is the main reconciliation loop for NginxServer resources. It ensures the actual cluster state matches the desired state defined in the CRD.

func (*NginxServerReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager. It watches NginxServer resources and also watches owned Deployments, Services, and ConfigMaps.

type NginxUpstreamReconciler

type NginxUpstreamReconciler struct {
	client.Client
	Scheme    *runtime.Scheme
	ConfigGen *config.Generator
}

NginxUpstreamReconciler reconciles NginxUpstream objects. When an NginxUpstream is created, updated, or deleted, this controller triggers a re-reconciliation of the referenced NginxServer.

The reconciliation loop:

  1. Fetches the NginxUpstream resource
  2. Validates the spec
  3. Ensures the referenced NginxServer exists
  4. Handles service discovery if enabled
  5. Triggers NginxServer reconciliation
  6. Updates status

func (*NginxUpstreamReconciler) Reconcile

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

Reconcile handles NginxUpstream create/update/delete events.

func (*NginxUpstreamReconciler) SetupWithManager

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

SetupWithManager sets up the NginxUpstream controller with the Manager.

Jump to

Keyboard shortcuts

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