Comments (1)
I plan to write docs for this once the contract is formalized, but in the meantime here's some explanation of the current state.
Suppose you have a CompositeController defined like this:
apiVersion: metacontroller.k8s.io/v1alpha1
kind: CompositeController
metadata:
name: catset-controller
spec:
parentResource:
apiVersion: ctl.enisoc.com/v1
resource: catsets
childResources:
- apiVersion: v1
resources: ["pods", "persistentvolumeclaims"]
clientConfig:
service:
name: catset-controller
namespace: metacontroller
hooks:
sync:
path: /sync
CompositeController Sync Request
Whenever Metacontroller decides that the desired state needs to be recomputed, it will send a JSON object to your sync
hook with the following fields:
-
controller
: The whole CompositeController object from above.i.e. what you'd get from
kubectl get compositecontroller catset-controller -o json
-
parent
: The particular parent object for which it wants you to compute the desired state.i.e. what you'd get from
kubectl get catset <parent-name> -o json
-
children
: A map (associative array) of child objects that already exist.Each field of the
children
object represents one of the types ofchildResources
you specified in your CompositeController spec. The field name for each child type is<Kind>.<apiVersion>
, so in this case there will be fields namedPod.v1
andPersistentVolumeClaim.v1
.The value of each field is another associative array that maps the child object's name to the actual object as it was last observed. For example, if your CatSet already has some Pods, your hook might receive an entry in the
children
map like this:"Pod.v1": { "my-catset-0": { ... }, "my-catset-1": { ... } }
The contents of
my-catset-0
will be just like what you'd get fromkubectl get pod my-catset-0 -o json
.You will only be sent children whose labels match the
spec.selector
field (interpreted the same asspec.selector
in controllers like Deployment) of the parent object. Note that this is the new-style selector that supports set-based requirements.Note that Metacontroller also performs adoption and orphaning like built-in controllers. That means it might adopt (take control of) objects that happen to match your selector, if no other controller has claimed them. It will also orphan (release control of) objects that you currently control, if they no longer match your selector.
Just like with built-in controllers, it's important that users of your custom controller specify a
spec.selector
in the parent object that is sufficiently precise to discriminate its child objects from those of other parents.
CompositeController Sync Response
Your hook should return a JSON object with the following fields:
-
status
: This is an arbitrary JSON object that will entirely replace thestatus
field in the parent object.What you put in here is up to you, but usually it's best to follow conventions established by controllers like Deployment. You should compute
status
based only on the children that already existed when your hook was called; status represents a judgement on the last observed state, not the desired state. -
children
: A list of JSON objects defining the desired children and their desired states.Note that this is a flat list of objects, not an associative array as in the
children
field of the request. Metacontroller groups the objects it sends you by type and name to save you from having to do it yourself, but it's actually redundant since each object contains this information.By default, you can think of each entry in the list as a JSON object to be sent to
kubectl create -f -
orkubectl replace -f -
(depending on whether it already exists).If you optionally set
spec.updateStrategy
(note: this field will likely be renamed soon) toApply
in your CompositeController, then you should instead think of each entry in this list as being sent tokubectl apply -f -
.In either case, any child you receive but do not return will be deleted (similar to
kubectl apply --prune
).Just like when working with kubectl, each object must contain its
apiVersion
andkind
. You can only create/replace/apply objects of the types you specified inchildResources
in your CompositeController spec.
from metacontroller.
Related Issues (20)
- Support for custom sub-resources
- --client-config-path option does not work HOT 1
- Feature Request: Support intentional orphaning of CompositeController children HOT 1
- Propose Metacontroller to be included in Kubernetes core HOT 1
- CRD updates require restart of metacontroller
- CompositeController - Infinite loop reconciling when having multiple volumemounts with same named configmap HOT 2
- Is there a way to trigger a resync? HOT 2
- Is this repo maintained? HOT 34
- New rabbitMQ operator - attaching my project
- [feature request] multiple metacontroller with object sharding strategy HOT 1
- [bug] Metacontroller crash when one of the CompositeControllers misbehave HOT 6
- Converting/Migrating from one Custom Resource to another HOT 3
- Make it easier to take over existing resources HOT 2
- Have a separate resync-after-error period flag HOT 1
- failed to sync CompositeController using apiextensions.k8s.io/v1
- System rapidly making calls to sync hook HOT 1
- Redis Operator Example
- Metacontroller omitting updated status in subsequent sync HOT 1
- Image metacontroller:v0.4.0 is vulnerable, CVEs' found in clair scan HOT 1
- Service-per-pod example: no matches for kind "Deployment" in version "apps/v1beta1"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metacontroller.