Write controller-runtime based k8s controllers that read/write to git, not k8s

Git Backed Controller

The basic idea is to write a k8s controller that runs against git and not k8s apiserver. So the controller is reading and writing objects to git and responding to changes in git. This is accomplished by creating a custom implemenation of the clients and caches in controller-runtime.

Status

This is totally hacked up and just proving an idea. There's most likely a lot of issues with this code. For one the RESTMapping logic is completely wrong as offline you have knowledge if a resource is namespaced or not.

Basic approach

You should just be able to write a controller as normal but in the setup just set the NewClient, NewCache, and MapperProvider to the git based ones.

	git, err := gitbacked.New(ctx, url, gitbacked.Options{
		Branch:       branch,
		SubDirectory: subdir,
		Interval:     interval,
	})
	defer git.Close()

	mgr, err := ctrl.NewManager(&rest.Config{}, ctrl.Options{
		Scheme:         scheme,
		NewClient:      git.NewClient,
		NewCache:       git.NewCache,
		MapperProvider: git.MapperProvider,
	})

Authentication

The controller will pull from and push to the same branch. Right now the code will just call git push so it is expect that that call will work with no user input (ssh keys or some agent based setup is in place).

Example

A more complete example is in the ./example folder.

Similar Resources

In this repository, the development of the gardener extension, which deploys the flux controllers automatically to shoot clusters, takes place.

Gardener Extension for Flux Project Gardener implements the automated management and operation of Kubernetes clusters as a service. Its main principle

Dec 3, 2022

A controller to create K8s Ingresses for Openshift routes.

route-to-ingress-operator A controller to create corresponding ingress.networking.k8s.io/v1 resources for route.openshift.io/v1 TODO int port string p

Jan 7, 2022

Ejemplo de un k8s custom controller para un CRD nuevo

Clonado de kubernetes/sample-controller Para pruebas de un CRD nuevo This repository implements a simple controller for watching Foo resources as defi

Nov 3, 2021

K8S ConfigMap Merging Controller

ConfigMap Merging Controller (cmmc) cmmc is a k8s operator that allows for the merging of ConfigMap resources with data validation. Why? The impetus f

Oct 2, 2022

K8s-delete-protection - Kubernetes admission controller to avoid deleteing master nodes

k8s-delete-protection Admission Controller If you want to make your Kubernetes c

Nov 2, 2022

General Pod Autoscaler(GPA) is a extension for K8s HPA, which can be used not only for serving, also for game.

General Pod Autoscaler(GPA) is a extension for K8s HPA, which can be used not only for serving, also for game.

Introduction General Pod Autoscaler(GPA) is a extension for K8s HPA, which can be used not only for serving, also for game. Features Compatible with a

Aug 19, 2022

Repo CRUD - write e read in mongoDB

Repo CRUD - write e read in mongoDB

Meli User - userwrite Este repo é responsável por um cadastro onde teremos somen

Jan 3, 2022

Git with a cup of tea, painless self-hosted git service

Git with a cup of tea, painless self-hosted git service

Gitea - Git with a cup of tea View the chinese version of this document Purpose The goal of this project is to make the easiest, fastest, and most pai

Jan 2, 2023

Watchtower for Git: automatically keep local Git repositories up to date with their remotes

CrowsNest Watchtower for Git: automatically keep local Git repositories up to date with their remotes. Configuration Flags --run-once or -r: Normally

Oct 30, 2022
The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the operator-sdk or controller-runtime.

k8s-generic-webhook The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the opera

Nov 24, 2022
Image clone controller is a kubernetes controller to safe guard against the risk of container images disappearing

Image clone controller image clone controller is a kubernetes controller to safe guard against the risk of container images disappearing from public r

Oct 10, 2021
A Controller written in kubernetes sample-controller style which watches a custom resource named Bookstore

bookstore-sample-controller A Controller written in kubernetes sample-controller style which watches a custom resource named Bookstore. A resource cre

Jan 20, 2022
upgrade from controller-runtime 0.6.5. Reactor substitute.

Upgrade Kubernetes Controller Runtime from v0.6.5 This blog concentrates on test case migration as the real code migration pretty detailed and straigh

Dec 6, 2021
K8s controller implementing Multi-Cluster Services API based on AWS Cloud Map.

AWS Cloud Map MCS Controller for K8s Introduction AWS Cloud Map multi-cluster service discovery for Kubernetes (K8s) is a controller that implements e

Dec 17, 2022
Litestream-read-replica-demo - A demo application for running live read replication on fly.io with Litestream

Litestream Read Replica Demo A demo application for running live read replicatio

Oct 18, 2022
Linux Controllers for Kubernetes

Tambourine Kubelet replacement with Built in Linux extensions Development Success: Install, Manage, and Observe a new systemd service from Kubernetes.

Jun 2, 2021
Go library to create resilient feedback loop/control controllers.

Gontroller A Go library to create feedback loop/control controllers, or in other words... a Go library to create controllers without Kubernetes resour

Jan 1, 2023
ControllerMesh is a solution that helps developers manage their controllers/operators better.
ControllerMesh is a solution that helps developers manage their controllers/operators better.

ControllerMesh ControllerMesh is a solution that helps developers manage their controllers/operators better. Key Features Canary update: the controlle

Jan 6, 2023
Golang Integration Testing Framework For Kong Kubernetes APIs and Controllers.
Golang Integration Testing Framework For Kong Kubernetes APIs and Controllers.

Kong Kubernetes Testing Framework (KTF) Testing framework used by the Kong Kubernetes Team for the Kong Kubernetes Ingress Controller (KIC). Requireme

Dec 20, 2022