Giter Club home page Giter Club logo

operator-runtime's Introduction

DataInfra Logo
Operator Runtime

Build Status Slack Go Reference GitHub issues Go Report Card

Operator runtime is a library to build kubernetes operators which adhere to Dsoi-Spec. This library provides high level abstractions and standardisation to focus on building robust reconcile loops for data application with multiple node types. Operator's built using operator runtime

๐ŸŽฏ Motivation

  • At DataInfra, we are building cloud native data infrastructure toolings to power self served data platforms, we build a lot of kubernetes operator's for distributed systems. Building reconcile loops for different nodetypes/components is extremely time consuming, error prone and becomes repetitive for mulitple applications. There arn't any useful abstractions which can be consumed by the reconcilation loops, while building operator's we wanted to focus on application building blocks, using the operator runtime we abstracted out the underlying k8s object reconcilation internals.

Using this library we introduce standardisation across

1. Builder Abstractions to build kubernetes objects and reconcile.
2. Triggering Reconcilation on state changes using hashes.
3. Building an internal store for reducing k8s API calls.
4. Event Emitters 

Abstractions

  • This library abstracts out controller runtime client.Client by wrapping it with CRUD methods and inbuilt event recorders.
  • To build objects initalise the Builder and leverage the ReconcileInterface to reconcile objects.

Build Objects

  • Operator builder exposes k8s objects, these objects can be built and passed to the NewBuilder. Example:
  // construct builder
	builder := builder.NewBuilder(
		builder.ToNewBuilderConfigMap(pinotConfigMap),
		builder.ToNewBuilderDeploymentStatefulSet(pinotDeploymentOrStatefulset),
		builder.ToNewBuilderStorageConfig(pinotStorage),
		builder.ToNewBuilderRecorder(builder.BuilderRecorder{Recorder: r.Recorder, ControllerName: "pinotOperator"}),
		builder.ToNewBuilderContext(builder.BuilderContext{Context: ctx}),
		builder.ToNewBuilderService(pinotService),
		builder.ToNewBuilderStore(*builder.NewStore(ib.client, ib.commonLabels, pt.Namespace, pt)),
	)
  • The library makes configmap hashes and passes them as env to deployment and sts objects, which force trigger rollout of pods when the intenral k8s client updates objects.

Reconcile Objects

  • once builder is constructed, the ReconcileInterface can be called in the build and reoncile objects
  // reconcile configmap
	result, err := builder.ReconcileConfigMap()
	if err != nil {
		return err
	}

Internal Store

  • Reconcile store
if err := builder.ReconcileStore(); err != nil {
	return err
}
  • Interal Store is an in memory which maintains key values for an object name and its kind. This store acts as an abstracted desired state, and is used as a matchmaker against the current state of CR.
type InternalStore struct {
	ObjectNameKind map[string]string
	CommonBuilder
}

operator-runtime's People

Contributors

adheipsingh 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.