k8sjs
v0.1.3
Published
A package that enables outputting of JS templated Kubernetes manifests.
Downloads
10
Maintainers
Readme
k8sjs
A package for applying JS templated Kubernetes manifests created with k8sresources
.
Usage
Installation
npm install --global k8sjs k8sresources;
Applying a JS file template
You will need kubectl
on your machine before this will work. To check if the plugin was installed successfully, use kubectl plugin list
.
To test a deployment, create a file with the following contents:
const {createDeployment} = require('k8sresources');
const deployment = createDeployment('apps/v1', {name: 'test'});
deployment.spec.template.spec.containers.push(
{
image: 'zephinzer/demo-echoserver:latest',
imagePullPolicy: 'IfNotPresent',
name: 'echoserver',
},
);
module.exports = deployment;
Then run:
kubectl js template ./yourfile.js | kubectl apply -f -
# or for typescript files...
kubectl ts template ./yourfile.ts | kubectl apply -f -
To just view the templated output, avoid applying it:
kubectl js template ./yourfile.js
# or for typescript files...
kubectl ts template ./yourfile.ts
Development Runbook
Development
- Install dependencies with
npm install
- Run
npm link
to link the binaries - Open a separate terminal and run
npm run dev
to start the file watcher/compiler - Run
kubectl js template
to test your changes (wait fortsc --project .
to complete running first)
Publishing
- Bump the version in the
package.json
- Build the project using
npm run build
- Commit all changes and push to the Git remote
- Run
npm publish
to publish to the NPM registry
License
This code is licensed under the MIT license.