Kubernetes
您可以在verdaccio/docker-例子资源库找到在Kubernetes群集中配置Verdaccio的指南。 然而,建议在Kubernetes集群上安装Verdaccio的方法是使用Helm。 Helm 是 Kubernetes 包管理者,它带来很多优点。
Helm
设置Helm
如果您以前没有使用过Helm,您需要设置叫做Tiller的Helm控制器:
helm init
安装
⚠️ If you are using this helm chart, please be aware of the migration of the repository.
配置Helm stable/verdaccio chart。
配置特定版本
helm install --name npm stable/verdaccio
请注意: 此命令删除所有源代码,包含您之前可能已经发布到registry里的包。
helm install --name npm --set image.tag=2.6.5 stable/verdaccio
Deploy a specific version
helm upgrade npm stable/verdaccio
升级Verdaccio
helm del --purge npm
卸载
wget https://raw.githubusercontent.com/verdaccio/verdaccio/master/conf/docker.yaml -O config.yaml
您可以用Kubernetes configMap自定义 Verdaccio 配置。
自定义Verdaccio 配置
Copy the existing configuration and adapt it for your use case:
准备
请注意: 请确保您使用的是持续存储的正确路径:
torage: /verdaccio/storage/data
auth:
htpasswd:
file: /verdaccio/storage/htpasswd
配置configMap
到集群
storage: /verdaccio/storage/data
auth:
htpasswd:
file: /verdaccio/storage/htpasswd
配置configMap
现在您可以配置Verdaccio Helm chart 并指定使用哪个配置:
kubectl create configmap verdaccio-config --from-file ./config.yaml
配置Verdaccio
Rancher 是一个完整的容器管理平台,它使得在生产中管理和使用容器非常容易。
helm install npm --set existingConfigMap=verdaccio-config verdaccio/verdaccio
Authenticate with private upstreams using Helm
As of version 4.8.0
of the helm chart, a new secretEnvVars
field has been added.
This allows you to inject sensitive values to the container via a Kubernetes Secret.
- Update your Verdaccio config according to the Uplinks documentation
- Pass the secret environment variable to your values file or via
--set secretEnvVars.FOO_TOKEN=superSecretBarToken
# values.yaml
secretEnvVars:
FOO_TOKEN: superSecretBarToken
NGINX proxy body-size limit
The standard k8s NGINX ingress proxy allows for 1MB for body-size which can be increased by modifying the default deployment options according to the documentation:
...
annotations:
...
kubernetes.io/proxy-body-size: 20m
....
...
Rancher 支持
Rancher is a complete container management platform that makes managing and using containers in production really easy.