Kubernetes private NPM registry

Tomáš Papež
2 min readSep 21, 2018

I was using Sinopia NPM registry for a long time and everything worked just fine but with a move to Kubernetes I was looking for a better solution and I found project https://verdaccio.org/ what’s a lightweight NPM proxy registry basically it’s Sinopia fork.

They have few examples based on docker and cool HELM chart but I’m not using HELM in my clusters but this example is inspired by it. My Source code is here: https://github.com/papezt/verdaccio-example

Because I’m running most of the workloads on GCE I wanted to use only Google services and GCS storage plugin is still experimental and I didn’t want to use GKE mixed with S3 storage then I decided to develop a temporary solution based on GKE and persistent volumes. As soon as GCS plugin will be GA I will migrate.

First of all I wanted to store data on SSD, then I needed to create a new storage class:

After that it’s super easy to get it running just review Kubernetes manifests and add your values and then run:

Some comments for every file:

  • pd-ssd — create storage class ssd
  • pvc — persistent volume claim using SSD. Define a size of the disk and don’t forget it’s pretty hard to resize then use bigger disk than later suffer from migration.
  • configmap — includes config for Verdaccio itself and htpasswd file for auth. Check out Verdaccio config documentation.
  • deployment — simple deployment based on Verdaccio HELM example
  • service — service manifest for Ingress
  • Ingress — using GLB and it has two prerequisites — secret wildcard-company-comwith a certificate and reserved global IP cluster-1-ingress.

You can use own ingress provider or just use load-balancing depends on use case.

For simple expose of deployment use this command:

kubectl expose deployment verdaccio --type=LoadBalancer --name=verdaccio-lb

For local testing, I used Mac Docker Kubernetess and I needed to create a different volume: https://github.com/papezt/verdaccio-examples/blob/master/global-manifests/pv.yaml.

If you want to go further it’s good to check out Verdaccio plugins. If you will want to use them, then you will have two options:

  • create another volume for plugins in /verdaccio/plugin and put your plugins there https://verdaccio.org/docs/en/docker
  • create own Dockerfile based on Verdacccio an install them directly

If you have better solutions let me know!

In the end, I would like to thank all developers behind Verdaccio good job guys!

--

--