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

k8s-scripts

v3.2.2

Published

Bash scripts for deploying and managing applications in Kubernetes

Downloads

25

Readme

Kubernetes Scripts

Opinionated scripts for managing application development and deployment lifecycle using Kubernetes.

How to Install

npm install -g k8s-scripts

Then in your top-level project directory:

k8s-example-config

Config file

k8s-scripts all function based on a simple bash config file in the root of your project directory named 'k8s-scripts.config'.

# Dockerfile to build
DOCKERFILE='Dockerfile'

# Docker tag that will be created
DOCKERTAG='quay.io/exampleorg/example-app'

# Cluster Namespace to work in
NAMESPACE='default'

# List of files ending in '.configmap.yml' in the kube directory
CONFIGMAPS=()

# List of files ending in '.secret.yml' in the kube directory
SECRETS=('example-app')

# List of files ending in '.service.yml' in the kube directory
SERVICES=('example-app')

# List of files ending in '.deployment.yml' in the kube directory
DEPLOYMENTS=('example-app')

# List of files ending in '.job.yml' in the kube directory (Not supported yet)
JOBS=()

Generating a config

There is a k8s-example-config script that will output an example config for you.

k8s-example-config Outputs an example config to k8s-scripts.config

k8s-example-config -o k8s-scripts.prod.config Outputs an example config to the filename specified by -o flag.

Supporting multiple environments

All scripts take an -f configfile option that allows you to specify which configuration file to use.

We recommend having the default, k8s-scripts.config, setup for your minikube environment, then specify <env>.conf for each of your environments.

deploy directory

Your kubernetes API object files should all be stored in the /deploy top level directory using consistent naming:

  • Deployments end in deployment.yml
  • Secrets end in secret.yml
  • ConfigMaps end in configmap.yml
  • Services end in service.yml
  • Jobs end in job.yml

Commands

docker-build

Does a build of the current directory `docker build --rm=false -t $DOCKERTAG -f ${BASEDIR}/$DOCKERFILE ${BASEDIR}``

docker-pull

Pulls from the registry the most recent build of the image. Useful for CI/CD layer caching

docker-push

Pushes the recently build image to the registry

k8s-deploy

Generates $CI_SHA1 suffixs for each of the files defined in your k8s-scripts config and uses kubectl create if the objects don't exist, kubectl apply if they do.

Leverages kubernetes annotations with --record when creating objects.

Verifies your deployment was successful within a specified timeout.

k8s-delete

Nukes everything defined in your k8s-scripts config file.

minikube-build

Switches to the minikube kubectl context, builds a Docker image form your current directory within the minikube Docker environment.

minikube-deploy

Switches the minikube kubectl context, then runs k8s-deploy

minikube-delete

Switches to the minikube kubectl context and deletes all of the objects associated with the k8s-scripts.config

minikube-services

Switches to the minikube kubectl context and prints out the accessible ip:port of any services defined in the config file that are accessible from your local machine

minikube-services-all

Switches to the minikube kubectl context and prints all the accessible ip:port of all services that are accessible from your local machine

ensure-kubectl

Makes sure kubectl is installed and available for use. Customize the version by specifying the KUBECTL_VERSION envrionmental variable. Default: v1.3.6.

Assumptions

  • In your Deployment file, specify imagePullPolicy: IfNotPresent