0.2.6 • Published 6 years ago
k8sresources v0.2.6
k8sresources
This repository contains constructors for common Kubernetes resources.
Usage
Installation for Development
npm install -D k8sresources @types/node;For appliying with kubectl
To apply the JavaScript-based templates, use the k8sjs package.
Install it using:
npm install -g k8sjsAnd you can generate the template using:
kubectl js template ./path/to/yourfile.jsTo apply it directly:
kubectl js template ./path/to/yourfile.js | kubectl apply -f -To dump the output into a yaml manifest:
kubectl js template ./path/to/yourfile.js > ./path/to/yourfile.yamlUsing
With JavaScript
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;
// if you'd like to see the output:
// console.info(JSON.stringify(deployment, null, 2));With TypeScript
import {createDeployment} from 'k8sresources';
const deployment = createDeployment('apps/v1', {name: 'test'});
deployment.spec.template.spec.containers.push(
{
image: 'zephinzer/demo-echoserver:latest',
imagePullPolicy: 'IfNotPresent',
name: 'echoserver',
},
);
export default deployment;
// if you'd like to see the output:
// console.info(JSON.stringify(deployment, null, 2));Roadmap
Version 1
This package should be able to generate templates for the following Kubernetes resources:
Application
Configuration
- ConfigMaps
- Secrets
Storage
- PersistentVolume
- PersistentVolumeClaim
RBAC
- ServiceAccount
- Role
- RoleBinding
- ClusterRole
- ClusterRoleBinding
Development Runbook
Development of Code
- Code is located in the
./srcdirectory - Before testing changes, run
npm run build - Use the code in
./examplesto test out your changes
Building
- The build process is a little hacky, final build is stored in
./lib - To trigger the build process, use
npm run build.
Publishing
- Bump the version in the root
package.json - Run the build:
npm run build - Navigate into the
./libdirectory - Publish the NPM package:
npm publish
License
This code is licensed under the MIT license.