Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kubermatic/reconciler
Simple codegen-based Go library to reconcile Kubernetes resources
https://github.com/kubermatic/reconciler
Last synced: 9 days ago
JSON representation
Simple codegen-based Go library to reconcile Kubernetes resources
- Host: GitHub
- URL: https://github.com/kubermatic/reconciler
- Owner: kubermatic
- License: apache-2.0
- Created: 2022-11-29T10:30:24.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T10:00:52.000Z (6 months ago)
- Last Synced: 2024-10-21T04:34:05.648Z (30 days ago)
- Language: Go
- Size: 98.6 KB
- Stars: 6
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# reconciler
This repository contains a simple library to make reconciling Kubernetes
resources a bit less tedious. It wraps the typical get-update-else-create
loop in a convenient interface and relies on code generation. A set of
default reconciler functions are shipped with this library.## Usage: Library
For common resources like Deployments, ConfigMaps or Secrets you can use
the reconcilers that ship with this library directly.```go
func myNamedConfigMapReconcilerFactory() (name string, reconciler reconciling.ConfigMapReconciler) {
return "my-configmap", func myConfigMapReconciler(cm *corev1.ConfigMap) (*corev1.ConfigMap, error) {
cm.Data["field"] = "new-value"return cm, nil
}
}reconcilers := []reconciling.NamedConfigMapReconcilerFactory{
myNamedConfigMapReconcilerFactory(),
}if err := reconciling.ReconcileConfigMaps(ctx, client, "namespace", reconcilers); err != nil {
log.Fatalf("Failed to reconcile ConfigMap: %v", err)
}
```## Usage: Code Generation
For non-standard APIs you can use `reconciler-gen` to generate your own reconciler code.
Create a YAML config file like so:```yaml
package: reconciling
boilerplate: boilerplate.go.txt
resourceTypes:
- { package: k8s.io/kube-aggregator/pkg/apis/apiregistration/v1, resourceName: APIService }
- { package: kubevirt.io/api/instancetype/v1alpha1, resourceName: VirtualMachineInstancetype }
```Then run `reconciler-gen`:
```bash
go run k8c.io/reconciler/cmd/reconciler-gen --config reconciling.yaml > zz_generated_reconcile.go
```