From 63c338bb9cf5cda964e458e5535277ac2a945642 Mon Sep 17 00:00:00 2001 From: Etienne Date: Wed, 29 Nov 2017 21:14:14 +0100 Subject: [PATCH] Add Verdaccio chart (#2727) * Add Verdaccio chart * Add appVersion to charts, update deployment apiVersion to apps/v1beta1 --- stable/verdaccio/.helmignore | 21 ++++ stable/verdaccio/Chart.yaml | 10 ++ stable/verdaccio/README.md | 125 +++++++++++++++++++++ stable/verdaccio/templates/NOTES.txt | 15 +++ stable/verdaccio/templates/_helpers.tpl | 16 +++ stable/verdaccio/templates/configmap.yaml | 66 +++++++++++ stable/verdaccio/templates/deployment.yaml | 68 +++++++++++ stable/verdaccio/templates/pvc.yaml | 24 ++++ stable/verdaccio/templates/service.yaml | 35 ++++++ stable/verdaccio/values.yaml | 62 ++++++++++ 10 files changed, 442 insertions(+) create mode 100644 stable/verdaccio/.helmignore create mode 100644 stable/verdaccio/Chart.yaml create mode 100644 stable/verdaccio/README.md create mode 100644 stable/verdaccio/templates/NOTES.txt create mode 100644 stable/verdaccio/templates/_helpers.tpl create mode 100644 stable/verdaccio/templates/configmap.yaml create mode 100644 stable/verdaccio/templates/deployment.yaml create mode 100644 stable/verdaccio/templates/pvc.yaml create mode 100644 stable/verdaccio/templates/service.yaml create mode 100644 stable/verdaccio/values.yaml diff --git a/stable/verdaccio/.helmignore b/stable/verdaccio/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/verdaccio/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/stable/verdaccio/Chart.yaml b/stable/verdaccio/Chart.yaml new file mode 100644 index 0000000000..a78c2b63b1 --- /dev/null +++ b/stable/verdaccio/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +description: A lightweight private npm proxy registry (sinopia fork) +name: verdaccio +version: 0.1.0 +appVersion: 2.6.5 +sources: +- http://www.verdaccio.org +maintainers: +- name: etiennetremel + email: etienne.tremel@container-solutions.com diff --git a/stable/verdaccio/README.md b/stable/verdaccio/README.md new file mode 100644 index 0000000000..bd8293e17c --- /dev/null +++ b/stable/verdaccio/README.md @@ -0,0 +1,125 @@ +# Verdaccio + +[Verdaccio](http://www.verdaccio.org) is a lightweight private +[NPM](https://www.npmjs.com) proxy registry. + +## TL;DR; + +``` +$ helm install stable/verdaccio +``` + +## Introduction + +This chart bootstraps a [Verdaccio](https://github.com/verdaccio/verdaccio) +deployment on a [Kubernetes](http://kubernetes.io) cluster using the +[Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.7+ with Beta APIs enabled +- PV provisioner support in the underlying infrastructure + +## Installing the Chart + +To install the chart with the release name `my-release`: + +``` +$ helm install --name my-release stable/verdaccio +``` + +The command deploys Verdaccio on the Kubernetes cluster in the default +configuration. The [configuration](#configuration) section lists the parameters +that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +``` +$ helm delete my-release +``` + +The command removes all the Kubernetes components associated with the chart and +deletes the release. + +## Configuration + +The following tables lists the configurable parameters of the Verdaccio chart +and their default values. + +| Parameter | Description | Default | +| ---------------------------------- | --------------------------------------------------------------- | -------------------------------------------------------- | +| `customConfigMap` | Use a custom ConfigMap | `false` | +| `image.pullPolicy` | Image pull policy | `Always` if `image` tag is `latest`, else `IfNotPresent` | +| `image.repository` | Verdaccio image | `verdaccio/verdaccio:{VERSION}` | +| `nodeSelector` | Node labels for pod assignment | `{}` | +| `persistence.accessMode` | PVC Access Mode for Verdaccio volume | `ReadWriteOnce` | +| `persistence.enabled` | Enable persistence using PVC | `true` | +| `persistence.mounts` | Additional mounts | `nil` | +| `persistence.size` | PVC Storage Request for Verdaccio volume | `8Gi` | +| `persistence.storageClass` | PVC Storage Class for Verdaccio volume | `nil` | +| `persistence.volumes` | Additional volumes | `nil` | +| `podAnnotations` | Annotations to add to each pod | `{}` | +| `replicaCount` | Desired number of pods | `1` | +| `resources` | CPU/Memory resource requests/limits | `{}` | +| `resources` | pod resource requests & limits | `{}` | +| `service.annotations` | Annotations to add to service | none | +| `service.clusterIP` | IP address to assign to service | `""` | +| `service.externalIPs` | Service external IP addresses | `[]` | +| `service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` | +| `service.loadBalancerSourceRanges` | List of IP CIDRs allowed access to load balancer (if supported) | `[]` | +| `service.port` | Service port to expose | `4873` | +| `service.type` | Type of service to create | `ClusterIP` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +``` +$ helm install --name my-release \ + --set service.type=LoadBalancer \ + stable/verdaccio +``` + +The above command sets the a service type LoadBalancer. + +Alternatively, a YAML file that specifies the values for the above parameters +can be provided while installing the chart. For example, + +``` +$ helm install --name my-release -f values.yaml stable/verdaccio +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + +### Custom ConfigMap + +When creating a new chart with this chart as a dependency, CustomConfigMap can +be used to override the default config.yaml provided. It also allows for +providing additional configuration files that will be copied into +`/verdaccio/conf`. In the parent chart's values.yaml, set the value to true and +provide the file `templates/config.yaml` for your use case. + +### Persistence + +The Verdaccio image stores persistence under `/verdaccio/storage` path of the +container. A dynamically managed Persistent Volume Claim is used to keep the +data across deployments, by default. This is known to work in GCE, AWS, and +minikube. +Alternatively, a previously configured Persistent Volume Claim can be used. + +It is possible to mount several volumes using `Persistence.volumes` and +`Persistence.mounts` parameters. + +#### Existing PersistentVolumeClaim + +1. Create the PersistentVolume +1. Create the PersistentVolumeClaim +1. Install the chart + +```bash +$ helm install --name my-release \ + --set persistence.existingClaim=PVC_NAME \ + stable/verdaccio +``` diff --git a/stable/verdaccio/templates/NOTES.txt b/stable/verdaccio/templates/NOTES.txt new file mode 100644 index 0000000000..04928414a4 --- /dev/null +++ b/stable/verdaccio/templates/NOTES.txt @@ -0,0 +1,15 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "verdaccio.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "verdaccio.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "verdaccio.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "verdaccio.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + kubectl port-forward $POD_NAME 8080:{{ .Values.service.port }} + echo "Visit http://127.0.0.1:8080 to use your application" +{{- end }} diff --git a/stable/verdaccio/templates/_helpers.tpl b/stable/verdaccio/templates/_helpers.tpl new file mode 100644 index 0000000000..9a7d7ba11e --- /dev/null +++ b/stable/verdaccio/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "verdaccio.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "verdaccio.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/verdaccio/templates/configmap.yaml b/stable/verdaccio/templates/configmap.yaml new file mode 100644 index 0000000000..70035506e0 --- /dev/null +++ b/stable/verdaccio/templates/configmap.yaml @@ -0,0 +1,66 @@ +{{- if not .Values.customConfigMap }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "verdaccio.fullname" . }} + labels: + app: {{ template "verdaccio.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + config.yaml: | + # + # This is the config file used for the docker images. + # It allows all users to do anything, so don't use it on production systems. + # + # Do not configure host and port under `listen` in this file + # as it will be ignored when using docker. + # see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration + # + # Look here for more config file examples: + # https://github.com/verdaccio/verdaccio/tree/master/conf + # + + # path to a directory with all packages + storage: /verdaccio/storage/data + + auth: + htpasswd: + file: /verdaccio/storage/htpasswd + # Maximum amount of users allowed to register, defaults to "+infinity". + # You can set this to -1 to disable registration. + #max_users: 1000 + + # a list of other known repositories we can talk to + uplinks: + npmjs: + url: https://registry.npmjs.org/ + + packages: + '@*/*': + # scoped packages + access: $all + publish: $authenticated + proxy: npmjs + + '**': + # allow all users (including non-authenticated users) to read and + # publish all packages + # + # you can specify usernames/groupnames (depending on your auth plugin) + # and three keywords: "$all", "$anonymous", "$authenticated" + access: $all + + # allow all known users to publish packages + # (anyone can register by default, remember?) + publish: $authenticated + + # if package is not available locally, proxy requests to 'npmjs' registry + proxy: npmjs + + # log settings + logs: + - {type: stdout, format: pretty, level: http} + #- {type: file, path: verdaccio.log, level: info} +{{- end }} diff --git a/stable/verdaccio/templates/deployment.yaml b/stable/verdaccio/templates/deployment.yaml new file mode 100644 index 0000000000..11cc0a35e1 --- /dev/null +++ b/stable/verdaccio/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + labels: + app: {{ template "verdaccio.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} + name: {{ template "verdaccio.fullname" . }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + {{- if .Values.podAnnotations }} + annotations: +{{ toYaml .Values.podAnnotations | indent 8 }} + {{- end }} + labels: + app: {{ template "verdaccio.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ template "verdaccio.name" . }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 4873 + livenessProbe: + httpGet: + path: / + port: 4873 + readinessProbe: + httpGet: + path: / + port: 4873 + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: +{{- if .Values.persistence.mounts }} +{{ toYaml .Values.persistence.mounts | indent 12 }} +{{- end }} + - mountPath: /verdaccio/storage + name: storage + readOnly: false + - mountPath: /verdaccio/conf + name: config + readOnly: true + # Allow non-root user to access PersistentVolume + securityContext: + fsGroup: 1000 + volumes: + - name: config + configMap: + name: {{ template "verdaccio.fullname" . }} +{{- if .Values.persistence.volumes }} +{{ toYaml .Values.persistence.volumes | indent 6 }} +{{- end }} + - name: storage + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ .Values.persistence.existingClaim | default (include "verdaccio.fullname" .) }} + {{- else }} + emptyDir: {} + {{- end -}} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/stable/verdaccio/templates/pvc.yaml b/stable/verdaccio/templates/pvc.yaml new file mode 100644 index 0000000000..8fc0cc799b --- /dev/null +++ b/stable/verdaccio/templates/pvc.yaml @@ -0,0 +1,24 @@ +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + labels: + app: {{ template "verdaccio.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + name: {{ template "verdaccio.fullname" . }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end }} diff --git a/stable/verdaccio/templates/service.yaml b/stable/verdaccio/templates/service.yaml new file mode 100644 index 0000000000..acdbce556a --- /dev/null +++ b/stable/verdaccio/templates/service.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: Service +metadata: +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end }} + name: {{ template "verdaccio.fullname" . }} + labels: + app: {{ template "verdaccio.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + clusterIP: "{{ .Values.service.clusterIP }}" +{{- if .Values.service.externalIPs }} + externalIPs: +{{ toYaml .Values.service.externalIPs | indent 4 }} +{{- end }} +{{- if .Values.service.loadBalancerIP }} + loadBalancerIP: "{{ .Values.service.loadBalancerIP }}" +{{- end }} +{{- if .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: +{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }} +{{- end }} + ports: + - port: {{ .Values.service.port }} + targetPort: 4873 + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "verdaccio.name" . }} + release: {{ .Release.Name }} + type: {{ .Values.service.type }} diff --git a/stable/verdaccio/values.yaml b/stable/verdaccio/values.yaml new file mode 100644 index 0000000000..41f2ab5af9 --- /dev/null +++ b/stable/verdaccio/values.yaml @@ -0,0 +1,62 @@ +image: + repository: verdaccio/verdaccio + tag: 2.6.5 + pullPolicy: IfNotPresent + +service: + annotations: {} + clusterIP: "" + + ## List of IP addresses at which the service is available + ## Ref: https://kubernetes.io/docs/user-guide/services/#external-ips + ## + externalIPs: [] + + loadBalancerIP: "" + loadBalancerSourceRanges: [] + port: 4873 + type: ClusterIP + +## Node labels for pod assignment +## Ref: https://kubernetes.io/docs/user-guide/node-selection/ +## +nodeSelector: {} + +podAnnotations: {} +replicaCount: 1 + +resources: {} + # limits: + # cpu: 100m + # memory: 512Mi + # requests: + # cpu: 100m + # memory: 512Mi + +customConfigMap: false + +persistence: + enabled: true + ## A manually managed Persistent Volume and Claim + ## Requires Persistence.Enabled: true + ## If defined, PVC must be created manually before volume will be bound + # existingClaim: + + ## Verdaccio data Persistent Volume Storage Class + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + + accessMode: ReadWriteOnce + size: 8Gi + volumes: +# - name: nothing +# emptyDir: {} + mounts: +# - mountPath: /var/nothing +# name: nothing +# readOnly: true