A Kubernetes config generation tool that deals with boilerplate code and let's you focus on the important details
Clone or download
Pull request Compare This branch is 15 commits ahead of sesispla:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.vscode
docs
generators
tests
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
LICENSE
package.json
readme.md

readme.md

Yeoman generator for Kubernetes boilerplate code

kubegen is a tool to create boilerplate Kubernetes Deployment, Service, PVC, Ingress yamls

kubegen is a Yeoman generator, so you'll need to have NodeJS installed.

This is based on the work done by sesispla that is available here - https://github.com/sesispla/generator-kubegen

Pre-requisite

Ensure recent version of Node (>=8.11.1) is installed. The version of Node in Ubuntu is pretty old.
The program has been tested on Mac and Linux only

sudo apt-get install python-software-properties
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

Detailed instructions mentioned in the following link for installing recent versions of Node on Ubuntu:
Install latest Node on Ubuntu

For Power LE (ppc64le) platform, you'll need to download Node binaries from the following link
and following the instructions mentioned here

Installation

To install kubegen, you need to execute the following command:

git clone https://github.com/bpradipt/generator-kubegen
sudo npm install -g yo
sudo npm install -g ./generator-kubegen

For validating the generated YAMLs, you can use kubeval. On Mac you can install using Homebrew

brew tap garethr/kubeval
brew install kubeval

For details refer to the source repository - https://github.com/garethr/kubeval

Usage

Follwing commands are available at the moment:

Command Description Arguments
yo kubegen Starts a full Kubernetes file generation wizard. All generated files are stored in a specified folder. --apply: Spawns a "kubectl apply -f " to all files generated immediately
yo kubegen Starts a full Kubernetes file generation wizard. All generated files are stored in a specified folder. --validate: Spawns a "kubeval -v 1.9.3 <file.yaml>" to all files generated immediately
yo kubegen:deployment Starts the Deployment subgenerator. 'deployment.yml' file is created, in the specified folder.
yo kubegen:service Starts the Service subgenerator. 'service.yml' file is created, in the specified folder.
yo kubegen:ingress Starts the Replication Controller subgenerator. 'deployment.yml' file is created, in the specified folder.
yo kubegen:lego Starts the Let's Encrypt subgenerator. All the internal components required by a TLS Ingress with kube-lego is created by this subgen
yo kubegen:pvc Starts the Persistent Volume Claim subgenerator. 'pvc.yml' file is created, in the specified folder.
$ yo kubegen

 |  |/  / |  |  |  | |   _  \  |   ____| /  _____||   ____||  \ |  |
 |  '  /  |  |  |  | |  |_)  | |  |__   |  |  __  |  |__   |   \|  |
 |    <   |  |  |  | |   _  <  |   __|  |  | |_ | |   __|  |  . `  |
 |  .  \  |  `--'  | |  |_)  | |  |____ |  |__| | |  |____ |  |\   |
 |__|\__\  \______/  |______/  |_______| \______| |_______||__| \__|

Welcome to Kubernetes Generator (kubegen)!. Generate Deployment/Service/PVC/Ingress YAMLs
Validate the generated YAML schema using kubeval - https://github.com/garethr/kubeval

? Directory to store the YAML? (app-demo)

Note: You'll need to run it as a non-root user

Contributing

Contribution is welcome! Just:

  • Fork this project
  • install the NPM dependencies:
npm install
  • Link this folder to npm
npm link
/usr/local/lib/node_modules/generator-kubegen -> /Users/User/generator-kubegen
  • Edit the project with your favorite text editor or tool

Debugging

For your conveniente, this project comes with a pre-built configuration to debug the solution with Visual Studio Code. Just go to the "Debug" menu on the left, select "Yeoman generator" in the dropdown (beside "play button") and then click "play" to start debugging.

debug with VSCode