Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 585
jolla Avatar asked Feb 19 '19 16:02

jolla


4 Answers

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

like image 109
Shivang Gupta Avatar answered Nov 18 '22 00:11

Shivang Gupta


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:

!! In 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-2.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

Don't 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
like image 22
Raposo Avatar answered Nov 18 '22 00:11

Raposo


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

like image 15
abinet Avatar answered Nov 18 '22 00:11

abinet


... 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.

like image 2
David Maze Avatar answered Nov 17 '22 23:11

David Maze