npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kustron

v1.2.3

Published

kustomize based kubernetes manifest generator for your services with GKE friendly pipeline commands

Downloads

37

Readme

downloads downloads version

Table of Contents

Introduction

If you have started moving your services to kubernetes cluster and was looking for a way to know how to write manifest files in a manageable and idiomatic way- kustron is for you. kustron is a simple cli tool that helps you generate manifest files for your service. kustron uses kustomization for dynamic templating, to keep things simple and understandable.

Few of the manifest files are relevant(e.g. cert.yml) only if you are using GKE, but with some basic tweaking you can make the manifests work for any provider like AWS or Azure. Eventually kustron will be extended to support all the major providers out of the box.

Features

A few of the things kustron can do for you:

  • Generate k8s manifests with different env specific overrides

  • Generate a Makefile with helper commands that you can utilise in your CI/CD pipelines

  • Generate a gitlab pipeline with GCP integration format(more cloud providers and other pipeline runners will be available soon)

Prerequisite

  • Install via npm- npm i -g kustron

  • Your application must have been dockerized already, meaning a Dockerfile exists at application root dir

Usage

  • In your application root dir, you can run this- kustron -g e.g. cd projects/checkout-service && kustron -g

  • It will ask you a few questions regarding your application; the questions are pretty straight-forward and self-explanatory

  • Once you have provided all the answers, a k8s folder will be generated with all the necessary files

  • If you have chosen the option to generate pipeline, it will also generate a Makefile and gitlab pipeline for you

  • You can also do- kustron -g -p /absolute/path/of/your/application/folder to generate all the mentioned files and folders in the path you specified. e.g. kustron -g /users/lbm/projects/gaan-recorder/

  • You can always do kustron -h if you need

Next Steps

  • The generated k8s folder will have following structure
- k8s
  - base
    - config
      - configmap.yml
      - hpa.yml (only if you have told kustron that your application needs autoscaling)
    - deployment.yml
    - ... (other files like service.yml, ingress.yml etc.)
    - kustomization.yml
  - overrides (all the env specific overrides to base manifests reside here in proper folders)
    - dev
      - ...
    - stg
      - ...
    - prd
      - ...
  • base folder contains base configurations

  • overrides folder has specific overrides, it considers you will deploy your service at least into 3 envs(e.g. dev, stg, prd)

  • All the files have necessary comments to help you out with any modifications you want

  • Adding another env override should be as simple as creating a dir under overrides and copying the files from any of the existing env and doing necessary amendments

  • If you have asked kustron to generate pipeline as well, it will generate a Makefile as well as a .gitlab-ci.yml file(right now only gitlab pipeline with GCP integration is supported, more options with different providers will come in future)

Apart from these, you should know about few particular files to make things work for your application the right way-

configmap.yml

  • This is the place where you should put all the env vars that your application need at runtime. For example, in case of a nodejs application, you should put proper NODE_ENV in this file

  • Check the given comments in the file to understand what you can do with it or check official documentation

deployment.yml

  • Apart from the env variables that get loaded from configmap(and which is hard coded), there are some sensitive env variables(like api key for a third party service) that you can load via kubernetes secrets

  • These sensitive env variables can be loaded in deployment.yml during runtime, an example is given as comments in the file itself

cert.yml

  • Only relevant if you have defined your application to be https only

  • The certificate created by this yml is a GCP managed certificate resource

  • This is already tied to the ingress given in env specific overrides(as every env will have different url like dev.myapp.com, stg.myapp.com etc. and hence difference certificates)

  • If you are not using GCP, you might check how to add other certificates to your ingress. Here's one with let's encrypt

ingress.yml

  • It's a good practice to have ingress if you want to expose your service, this necessarily works as a load balancer and creates a public ip

  • If your answer to Is Public was No while creating manifests by kustron, this file won't be generated and your service will only be privately accessible by your other services in the cluster

Makefile & .gitlab-ci.yml

  • If your answer to Generate Pipeline was Yes, kustron will generate these files for you

  • These files give you the building blocks for your automated build and deployment pipeline

  • Check both the files, as they have lots of comments to make things self-explanatory

  • None of these files will require much changes when you use a different provider like Azure or AWS- but you should check the comments and understand what has to be changed

Release Flow

The default generated gitlab pipeline respects the following release flow-

Feedback

Feel free to file an issue.

Would love to extend this for other cloud providers. Please create a pull request with one, if you want to add.