charts
charts copied to clipboard
How to install plugins is not documented? (scroll down👇)
Hi,
I was browsing both README and Values.yaml and can't find a way to install plugins to Verdaccio using the helm chart.
I really was hoping to get it to work some way without having to rebuild a container image with the plugins I require.
Asking this because I need a running Verdaccio with both ldap and gcloud storage plugins (or minio storage).
I can put in a PR for this after we figure out which directories to mount for the npm init container.
I am having a ton more issues than I thought I would when trying to do this with an initContainer
:
Output
robert ❱ ~ ❱ kubectl logs -n devops-sandbox -l app=<ENDPOINT> --all-containers --follow
+ npm install -g verdaccio-azure-ad-login
npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
+ [email protected]
added 12 packages from 13 contributors in 1.307s
+ cp -a /usr/local/lib/node_modules/npm /usr/local/lib/node_modules/verdaccio-azure-ad-login /tmp/node_modules/
+ ls -la /tmp/node_modules/
total 4
drwxrwsrwx 4 root 101 49 Dec 21 22:11 .
drwxrwxrwt 1 root root 26 Dec 21 22:11 ..
drwxr-sr-x 10 root root 4096 Nov 13 11:01 npm
drwxr-sr-x 4 root root 109 Dec 21 22:11 verdaccio-azure-ad-login
warn --- config file - /verdaccio/conf/config.yaml
error--- plugin not found. try npm install verdaccio-azure-ad-login
(node:10) UnhandledPromiseRejectionWarning: Error:
verdaccio-azure-ad-login plugin not found. try "npm install verdaccio-azure-ad-login"
at /opt/verdaccio/build/lib/plugin-loader.js:110:13
at Array.map (<anonymous>)
at loadPlugin (/opt/verdaccio/build/lib/plugin-loader.js:62:37)
at Auth._loadPlugin (/opt/verdaccio/build/lib/auth.js:56:38)
at new Auth (/opt/verdaccio/build/lib/auth.js:46:25)
at defineAPI (/opt/verdaccio/build/api/index.js:43:16)
at _default (/opt/verdaccio/build/api/index.js:124:10)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Applicable helmfile config:
repositories:
- name: verdaccio
url: https://charts.verdaccio.org
releases:
- name: {{ requiredEnv "DOMAIN" | replace "." "-" }}
namespace: {{ requiredEnv "ENVIRONMENT" }}
chart: verdaccio/verdaccio
version: 4.5.0 # https://github.com/verdaccio/charts/tree/verdaccio-4.5.0/charts/verdaccio
values:
- configMap: |
...
auth:
azure-ad-login:
tenant: "foo"
client_id: "bar"
client_secret: "baz"
organization_domain: "example.com"
...
extraInitContainers:
- name: install-plugins
image: node:14.18.1-alpine # FROM layer for Verdaccio 5.3.0
command:
- 'sh'
- '-c'
- |
set -ex
npm install -g verdaccio-azure-ad-login
# Ensure that npm is not lost during container mount
cp -a /usr/local/lib/node_modules/* /tmp/node_modules/
ls -la /tmp/node_modules/
volumeMounts:
- name: global-plugins
mountPath: /tmp/node_modules/
persistence:
volumes:
- name: global-plugins
emptyDir: {}
mounts:
- mountPath: /usr/local/lib/node_modules/
name: global-plugins
readOnly: false
wait: true
timeout: 120
I think I am super close to having a working prototype, but am by no means an npm
expert. I will circle back to this tonight, but in the meantime, if you see what I am doing wrong - pointing it out would be very much appreciated.
If you're using a Verdaccio 5.x image, yarn's pnp
loader will raise a stink if the application tries loading packages that it wasn't built with. I suspect that's what you are seeing. The 5.x Dockerfile includes node -r ./.pnp.js
: https://github.com/verdaccio/verdaccio/blob/e5d79ce8f00a18f0c0646b761f22dc608b5baf87/Dockerfile#L61
Maybe removing that one bit would be enough. Once I found the pnp thing though I personally made my own docker image to make sure yarn was totally happy :(
I also understand that Verdaccio 6 no longer uses yarn, so that issue is totally specific to 5.x
With these posts as inspiration, I was able to use the following with success after quite a few failed attempts:
##
# NOTE - The 'version' and init 'image' keys are from the latest values here:
# https://github.com/verdaccio/charts/blob/verdaccio-4.5.0/charts/verdaccio/Chart.yaml
# And the os image for lib edits is here:
# https://github.com/verdaccio/verdaccio/blob/v5.2.0/Dockerfile#L1
##
repo: https://charts.verdaccio.org
chart: verdaccio
version: 4.5.0
extraInitContainers:
- name: populate-workdir
image: verdaccio/verdaccio:5.2.0
command:
- 'sh'
- '-c'
- 'cp -a /opt/* /tmp/tmpopt/ > /dev/null 2>&1'
volumeMounts:
- name: verdoptio
mountPath: /tmp/tmpopt/
- name: install-plugins
image: node:14.18.1-alpine
command:
- 'sh'
- '-c'
- |
cd /opt/verdaccio/
yarn config set enableProgressBars false
yarn add verdaccio-aws-s3-storage
yarn cache clean
yarn workspaces focus --production > /dev/null 2>&1
chown -R root /opt/
chown 10001 /opt/verdaccio/
volumeMounts:
- name: verdoptio
mountPath: /opt/
persistence:
enabled: false
volumes:
- name: verdoptio
emptyDir: {}
mounts:
- mountPath: /opt/
name: verdoptio
readOnly: false
I'm sure a few of the permissions here probably don't need to be specified, but doesn't seem to hurt.
(Thanks for Verdaccio! Next step for me is trying to implement controlled cache updates, which I'm thinking using s3 and multiple instances will accomplish)
Maybe we should add either add this to the readme or website, somehow thanks @ejhatch great contribution
When I get time I would like to just update the helm chart. I think in the values.yaml we could do something like:
additionalPlugins: []
# - verdaccio-aws-s3-storage
# - verdaccio-azure-ad-login
This is pretty much what Jenkins does:
https://github.com/jenkinsci/helm-charts/blob/jenkins-3.9.3/charts/jenkins/values.yaml#L237-L241 https://github.com/jenkinsci/helm-charts/blob/jenkins-3.9.3/charts/jenkins/values.yaml#L250 https://github.com/jenkinsci/helm-charts/blob/jenkins-3.9.3/charts/jenkins/templates/config.yaml#L32-L44