helm chart with requirements.yaml, did not find local charts

霸气de小男生 提交于 2021-02-07 02:49:39

问题


my charts has elasticsearch and mongdb dependencies, and in my charts, the structure like this:

├── [-rw-rw-r--]  Chart.yaml
├── [drwxrwxr-x]  dependency_charts
│   ├── [drwxrwxr-x]  elasticsearch
│   └── [drwxrwxr-x]  mongodb
├── [-rw-rw-r--]  deploy.sh
├── [-rw-rw-r--]  requirements.yaml
├── [-rw-rw-r--]  values.yaml
├── [drwxrwxr-x]  templates
│   ├── [-rw-rw-r--]  proj-deploy.yaml
│   └── [-rw-rw-r--]  proj-svc.yaml

but when I try to install my chart, it will say:

Error: found in requirements.yaml, but missing in charts/ directory: elasticsearch, mongodb

and when I execute helm dep ls, it show status missing

$ helm dep list
NAME            VERSION REPOSITORY                              STATUS
elasticsearch   6.5.1   file://dependency_charts/elasticsearch  missing
mongodb         4.0.3   file://dependency_charts/mongodb        missing

the version is appVersion, and I have also change the version to chart version, it doesn't work.

this is the official document: https://github.com/helm/helm/blob/master/docs/helm/helm_dependency.md https://docs.helm.sh/chart_best_practices/#repository-urls

this is helm version

$ helm version
Client: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}

And I can put those chart to a charts folder, but if I do that, helm will install mongodb and elasticsearch in the same charts, that's not expected, what I'm expecting is under the same namespace has three charts: myproj, elasticsearch, mongodb.

Anyone got a clue about what I do wrong? Thanks.


回答1:


You have to run helm dep update. This will put subcharts into the ./charts folder and create ./requirements.lock file. Then you can install.




回答2:


helm dep update

only works when the repo list is empty. Check helm repo list , if this return something then local dependencies will not resolve. Try removing the repos using command helm repo remove REPO_NAME




回答3:


... what I'm expecting is under the same namespace has three charts: myproj, elasticsearch, mongodb.

You need to run helm install three separate times to get that effect.


The requirements.yaml mechanism causes Helm to install multiple sub-charts in a single Helm release. helm list would just show myproj, but internally it would also have the Kubernetes resources for the other components. If you kubectl get service then you'd see Service objects like unusual-animal-myproj and unusual-animal-mongodb, managed by the same Helm release. If you helm del unusual-animal, it would delete all three components together.

If that's the behavior you want, then the error message you got means what it says: the local charts must be in a subdirectory named exactly charts. Running helm dep up or helm dep build will copy them there.




回答4:


helm dep update <name_of_folder_where_chart.yaml_is>

Once you run above below will be the output:-

Saving 1 charts
Deleting outdated charts

Now, you can run your charts locally using

helm template <path_to_chart.yaml> 



回答5:


Using Helm version v3.4.1.

I was having this error.

My solution was to:

  • Rename charts/ (directory) to subcharts/
  • And chmod 755 subcharts/*

Heml 3 didn't like it when I placed my local dependencies in charts/
Also Helm dep up needs permissions to move the local dependencies from your subcharts directory to tmpcharts/ and so on.

**

This is not my find.

**

I read this from @sgandon and @Narayana :

Post about conditionally deploying helm charts

Bug documented #3742.
comment.

the reason why the os.Stat() fails to find the folder. This is because the calling function downloadAll is renaming the charts folder to tmpcharts during the update thus making our unpacked chart not foundable for that duration.

Note:

!! On Helm 3 requirements.yaml is deprecated. !!

You add the dependencies in the Parent/Main Charts.yaml.

dependencies:
  - name: chart-you-want-to-deploy-1
    repository: file://subcharts/chart-you-want-to-deploy-1
    version: 0.0.1
    condition: chart-you-want-to-deploy-1.enabled

  - name: chart-you-want-to-deploy-2
    repository: file://subcharts/chart-you-want-to-deploy-2
    version: 0.0.1
    condition: chart-you-want-to-deploy-2e.enabled

Added my variables to my globals in the Parent/Main Values.yaml

globals:
  chart-you-want-to-deploy-1:
    enabled: true
  chart-you-want-to-deploy-2:
    enabled: false

Dont forget to add the flags to your command.
In my case I was using a CI/CD tool (Gitlab)

script:
    - >
      helm dep up Main-Chart-Name && \
       helm upgrade --install \
       --set chart-you-want-to-deploy-1.enabled=false \
       --set chart-you-want-to-deploy-2.enabled=true \
       RELEASE_NAME Main-Chart-Name

my tree

Main-Chart-Name
├── Chart.yaml
├── subcharts
│   ├── chart-you-want-to-deploy-1
│   │   ├── Chart.yaml
│   │   ├── charts
│   │   ├── templates
│   │   │   └── chart-you-want-to-deploy-1.yaml
│   │   └── values.yaml
│   └── chart-you-want-to-deploy-2
│       ├── Chart.yaml
│       ├── charts
│       ├── templates
│       │   └── chart-you-want-to-deploy-2.yaml
│       └── values.yaml
├── templates
│   ├── helpers.tpl
│   ├── my.yaml
│   ├── main.yaml
│   └── templates.yaml
└── values.yaml


来源:https://stackoverflow.com/questions/54770636/helm-chart-with-requirements-yaml-did-not-find-local-charts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!