Giter Club home page Giter Club logo

reconciler's Introduction

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.

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:

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:

go run k8c.io/reconciler/cmd/reconciler-gen --config reconciling.yaml > zz_generated_reconcile.go

reconciler's People

Contributors

xrstf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.