kubernetes
kubernetes copied to clipboard
Higher level API to build objects
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.
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.