Wrangler is a Go framework that simplifies the process of writing Kubernetes controllers by abstracting away the complexity of working with generated clientsets, informers, listers, and workqueues. The repository addresses a fundamental pain point in Kubernetes development: there is no standard controller interface in Kubernetes itself, so developers must manually combine multiple components and implement custom event handling logic. Wrangler provides a unified pattern that promotes best practices and reduces boilerplate code.
The framework includes a code generator that produces clientsets, informers, listers, and per-resource-type controllers from custom resource definitions. These generated components are built on top of lasso, another Rancher project that provides the underlying infrastructure for managing controllers and caches. Wrangler wraps lasso's resource-type-agnostic factories to deliver resource-specific clients and controllers through a simple, flat API. When a controller is requested from a Wrangler-generated factory, the factory either returns an existing controller or creates, persists, and returns a new one.
A key design decision in Wrangler is how it handles event handlers. Rather than registering handlers directly to Kubernetes informers, Wrangler uses lasso to aggregate multiple handlers into a single function that processes objects serially. This serialized execution ensures that each handler receives the updated version of an object and prevents conflicts that would arise from parallel handler execution. Developers register OnChange handlers to controllers and then start the controller with a specified number of worker threads.
Wrangler provides multiple ways to interact with Kubernetes objects. The client interface supports Create, Update, UpdateStatus, Delete, Get, Watch, Patch, List, and Watch operations. The cache interface, also called a lister, attempts to retrieve data locally before making API requests, reducing load on the Kubernetes API server. Additionally, Wrangler offers an Apply client that works similarly to kubectl apply, enabling declarative state management without assuming object existence and supporting multiple owner references in a way that differs from standard client operations.
The repository is actively maintained with a structured versioning strategy tied to Rancher releases. Currently maintained versions include 1.0.x for Rancher 2.6.x with security fixes and 1.1.x for Rancher 2.7.x with bug and security fixes. Releases follow semantic versioning and are cut from release branches rather than the default branch, with bug fixes cherry-picked to older release branches as needed. The release process is automated through GitHub Actions workflows that validate versions, create annotated tags, and generate releases.
Wrangler is used across multiple Rancher projects including the main rancher repository, eks-operator, aks-operator, and gke-operator. GitGenius activity tracking shows median issue and pull request response latency of 0.1 hours with a mean of 46.0 hours across tracked items. Primary contributors and triagers include anmazzotti, ericpromislow, and apoorvajagtap. The repository shares contributors with rancher/rancher, rancher-sandbox/rancher-desktop, and rancher/fleet, indicating tight integration within the Rancher ecosystem.