/jq-controller

A generic kubernetes controller based on jq. Quickly prototype your own operators using jq filters!

Primary LanguagejqApache License 2.0Apache-2.0

jq-controller

Docker

A generic kubernetes controller based on jq. Quickly prototype your own operators using jq filters!

The controller will kubectl apply whatever comes as a result of applying the jq filter on the input resource(s) you specify.

how it works

To give you a general idea of what it does, below is a simplified view of jq-controller operation flow:

kubectl get --watch ${WATCH_TARGET} -o json \
| jq <your transform filter> \
| kubectl apply -f -

So, for example, if you specify:

  • WATCH_TARGET=configmap/jq-input
  • content of configmap/jq-input:
 apiVersion: v1
 kind: ConfigMap
 metadata:
   name: jq-input
 data:
   var: Whatever, really
  • the value of your jq filter:
 {
    "apiVersion": "v1",
    "kind": "ConfigMap",
    "metadata": {
        "name": "jq-output"
    },
    "data": {
        "extracted": .var
    }
 }

then the controller will create the following configmap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: jq-output
data:
  extracted: Whatever, really

And this is what the manifests under examples/privileged-insecure/ will actually do if you kubectl apply them :)