splunk / qbec

configure kubernetes objects on multiple clusters using jsonnet
https://qbec.io
Apache License 2.0
172 stars 37 forks source link

qbec show - use output for kubectl patch #229

Closed Rom888 closed 3 years ago

Rom888 commented 3 years ago

I have a Daemonset installed and configured in a cluster by other tool, and I need to patch it using qbec show output. I created components/patch.jsonnet, however qbec show stage -c patch gives an error: ✘ extract objects: non-kubernetes object found while evaluating path "$[0].op"

It would be valuable to have a way to process jsonnet json patch files and use them for patches, something like this:

qbec show stage --patch=patch.jsonnet | kubectl patch  daemonset ds1 --type='json' --patch="$(cat)"

This is simplified json patch example:

    local p = import '../../params.libsonnet';
    local params = p.components.nginxIngress;
    [
      {
        op: 'add',
        path: '/spec/template/spec/volumes/0/name',
        value: 'modsec-logs',
      },
      {
        op: 'add',
        path: '/spec/template/spec/containers/0/volumeMounts/0/name',
        value: 'modsec-logs',
      },
    ]
gotwarlost commented 3 years ago

you can use qbec eval for this which doesn't make any assumptions about output and is equivalent to jsonnet eval