kubernetes icon indicating copy to clipboard operation
kubernetes copied to clipboard

Higher level API to build objects

Open dlespiau opened this issue 7 years ago • 1 comments

We have https://github.com/jkcfg/kubernetes/blob/master/src/kubernetes.js to build a Deployment in one or a few lines. It's more convenient than having to type the whole object. We need to:

  • Explore that high level API and come up with something that isn't too opinionated.
  • See if we can find enough commonality to auto-generate that higher level object.
  • Use typescript to write it.

dlespiau avatar Dec 28 '18 11:12 dlespiau

On a tangent, https://github.com/koki/short is a nice idea -- boil the (standard) API objects down to the minimal, unambiguous form. So you'd construct values looking like this:

const dep = {
  deployment: {
    name: 'foo-dep',
    namespace: 'foo-ns',
    labels: { ... },
    annotations: {...}
    containers: [
      ...
    ]
  }
}

which is somewhat less verbose already than the equivalent

const deployment = {
  kind: 'Deployment',
  apiVersion: 'apps/v1',
  metadata: {
    name: 'foo-dep',
    namespace: 'foo-ns',
    labels: { ...},
    annotations: { ... },
  },
  spec: {
    template: {
       spec: {
         containers: [
           ...
         ]
      }
    }
  }
}

It'd be fairly easy to do this at least in the direction of short version -> full YAML, with a bridge to the fully-typed objects.

squaremo avatar Feb 18 '19 11:02 squaremo