kubernetes/sample-controller

Repository for sample controller. Complements sample-apiserver

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 38 minutes ago
Type:Template / ExampleCategory(s):Kubernetes & OperatorsCloud Native & Infrastructure
Added to GitGenius on September 19th, 2026
Created on October 19th, 2017
Open Issues & Pull Requests: 1 (+0)
GitHub issues: Disabled - open counts may still include pull requests.
Number of forks: 1,216
Total Stargazers: 3,515 (+0)
Total Subscribers: 66 (+0)

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

GitHub issues are disabled for this repository, so issue analytics and the issue explorer are not available.

Detailed Description

sample-controller is a reference implementation of a Kubernetes controller that demonstrates how to build a custom resource controller using CustomResourceDefinitions.

The tool addresses the problem of understanding how to implement a production-style Kubernetes controller. It shows the fundamental patterns: registering a custom resource type called Foo via CustomResourceDefinition, performing basic operations like create, get, and list on instances of that resource, and setting up a controller to handle create, update, and delete events. The implementation uses the client-go library extensively and leverages code generators from k8s.io/code-generator to produce typed clients, informers, listers, and deep-copy functions automatically rather than maintaining them by hand.

Developers building custom controllers for Kubernetes should use this as a template. It suits anyone implementing a controller for a single custom resource type and provides a foundation that can be extended for more complex scenarios. The example demonstrates practical use cases such as provisioning external databases or creating higher-level abstractions around Kubernetes primitives. The repository requires a Kubernetes cluster version greater than 1.9 due to its use of apps/v1 deployments.

This is a staged repository automatically published from the main Kubernetes codebase, meaning all contributions flow through the primary Kubernetes repository rather than being made directly here. The repository is read-only for importing purposes. The project includes documentation explaining the interaction points between the sample controller and the client-go library mechanisms, and provides an update-codegen script that developers should run to generate their own code rather than copying the generated files when creating controllers based on this implementation.