k8sjs
v0.1.3
Published
A package that enables outputting of JS templated Kubernetes manifests.
Downloads
18
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.tsDevelopment Runbook
Development
- Install dependencies with
npm install - Run
npm linkto link the binaries - Open a separate terminal and run
npm run devto start the file watcher/compiler - Run
kubectl js templateto 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 publishto publish to the NPM registry
License
This code is licensed under the MIT license.
