crumbhole / argocd-lovely-plugin

A plugin to make Argo CD behave like we'd like.
BSD 3-Clause "New" or "Revised" License
390 stars 24 forks source link

exit status 1: Error: no cached repository for helm-manager #85

Closed gabrielfsousa closed 1 year ago

gabrielfsousa commented 1 year ago

how i fix this error ?

rpc error: code = Unknown desc = Manifest generation error (cached): `argocd-lovely-plugin` failed exit status 1: 2022/11/25 12:36:32 exit status 1: Error: no cached repository for helm-manager-daf1ee1308783e5bff6495f156b188a0ededf4f6125cc2a5c95c7274583672ee found. (try 'helm repo update'): open /tmp/.helm/cache/repository/helm-manager-daf1ee1308783e5bff6495f156b188a0ededf4f6125cc2a5c95c7274583672ee-index.yaml: no such file or directory
Joibel commented 1 year ago

Hard to tell, you have not given much information. Does helm dependency build work locally on your PC in the directory with the Chart.yaml. Is the chart stored in a private repository. Show us your Chart.yaml for this error if you can.

gabrielfsousa commented 1 year ago

yes, works in my local pc ALSO, work in ARGOCD if i dont use the plugin

ArgoCD v2.5.2 Harbor v2.6.0

apiVersion: v2
name: weave-scope
version: 1.10.1
dependencies:
- name: weave-scope
  version: 1.0.1
  repository: https://registry.harbor/chartrepo/artifacthub.io
PS C:\WORK\helm> helm dependency build
Getting updates for unmanaged Helm repositories...
...Successfully got an update from the "https://registry.harbor/chartrepo/artifacthub.io" chart repository
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "dasmeta" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading weave-scope from repo https://registry.harbor/chartrepo/artifacthub.io
Deleting outdated charts
Joibel commented 1 year ago

https://registry.harbor/ is a private repo.

Does it require authentication? Is it reachable from the argocd-repo-server pod?

Joibel commented 1 year ago

Does this work if you remove lovely plugin?

gabrielfsousa commented 1 year ago

like i said, works if i dont use the plugin.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: weave-scope
  namespace: argocd
spec:
  generators:
  - list:
      elements:
      - cluster: dev
        url: https://rancher/k8s/clusters/c-m-bsdxhrnf
      - cluster: prod-me
        url: https://rancher/k8s/clusters/c-m-r2sxk659
      - cluster: prod-nl
        url: https://rancher/k8s/clusters/c-m-j45pbv8s
      - cluster: local
        url: https://kubernetes.default.svc
  template:
    metadata:
      name: '{{cluster}}-weave-scope'
    spec:
      project: default
      source:
        repoURL: https://dev.azure.com/ssot/_git/ssot
        targetRevision: HEAD
        path: "weave-scope/{{cluster}}"
        plugin:
          name: argocd-lovely-plugin
      destination:
        server: '{{url}}'
        namespace: 'observability'

      syncPolicy:
        syncOptions:
        - CreateNamespace=true

        automated:
          selfHeal: true
          prune: true
gabrielfsousa commented 1 year ago

is my private repo, but is public no authentication need it image

Joibel commented 1 year ago

Are you attempting to install a helm version 2 chart here (as in the upstream Chart.yaml has apiVersion: v1 in it)? If so, this is old and deprecated. I'm not sure why it doesn't work any more.

Joibel commented 1 year ago

like i said, works if i dont use the plugin.

So if you remove the plugin: section it works?

gabrielfsousa commented 1 year ago

i have more information. i run the helm dependency build inside the repo-server pod i have the "x509: certificate signed by unknown authority"

argocd@argocd-repo-server-6896b56566-bvvmn:/tmp/111$ helm dependency build
Getting updates for unmanaged Helm repositories...
...Unable to get an update from the "https://registry.harbor/chartrepo/artifacthub.io" chart repository:
        Get "https://registry.harbor/chartrepo/artifacthub.io/index.yaml": x509: certificate signed by unknown authority
Error: no cached repository for helm-manager-daf1ee1308783e5bff6495f156b188a0ededf4f6125cc2a5c95c7274583672ee found. (try 'helm repo update'): open /helm-working-dir/repository/helm-manager-daf1ee1308783e5bff6495f156b188a0ededf4f6125cc2a5c95c7274583672ee-index.yaml: no such file or directory
argocd@argocd-repo-server-6896b56566-bvvmn:/tmp/111$ helm dependency build --insecure-skip-tls-verify
Error: unknown flag: --insecure-skip-tls-verify
gabrielfsousa commented 1 year ago

like i said, works if i dont use the plugin.

So if you remove the plugin: section it works?

yes

gabrielfsousa commented 1 year ago

upstream Chart.yaml v1 worked in my private k8s, with the plugin

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: weave-scope
  namespace: argocd
spec:
  generators:
  - list:
      elements:
      - cluster: dev
        url: https://kubernetes.default.svc
      - cluster: prod
        url: https://kubernetes.default.svc
  template:
    metadata:
      name: '{{cluster}}-weave-scope'
    spec:
      project: default
      source:
        repoURL: https://github.com/gabrielfsousa/infra001.git
        targetRevision: HEAD
        path: weave-scope/{{cluster}}
        plugin:
          name: argocd-lovely-plugin
      destination:
        server: '{{url}}'
        namespace: '{{cluster}}'
      syncPolicy:
        syncOptions:
        - CreateNamespace=true

        automated:
          selfHeal: true
          prune: true
apiVersion: v2
name: weave-scope
version: 0.1.0
dependencies:
- name: weave-scope
  version: 1.0.0
  repository: https://dasmeta.github.io/helm/
Joibel commented 1 year ago

Get "https://registry.harbor/chartrepo/artifacthub.io/index.yaml": x509: certificate signed by unknown authority

That's the problem. I assume you have added this repository to ArgoCD? lovely can't see the certificate you've trusted in ArgoCD if so, so won't trust it. I don't have a workaround for that.

gabrielfsousa commented 1 year ago

yes, its in ArgoCD, in argo i added insecure-skip-tls-verify.

apiVersion: v1
kind: Secret
metadata:
  name: repo-harbor
  namespace: argocd
  labels:
    argocd.argoproj.io/secret-type: repository
stringData:
  enableOCI: "false"
  insecure: "true"
  name: "harbor"
  type: helm
  url: "https://registry.harbor/chartrepo/artifacthub.io"
  project: "default"
gabrielfsousa commented 1 year ago

can you add in the plugin insecure-skip-tls-verify

Joibel commented 1 year ago

can you add in the plugin insecure-skip-tls-verify

Not at the moment. It's an easy thing to add though. I'll do that for you now.

gabrielfsousa commented 1 year ago

how i use ARGOCD_ENV_LOVELY_HELM_REPO_ADD_PARAMS ? create a env.txt in repo and the pluging will read it ?

or with :

        plugin:
          env:
            - name: ARGOCD_ENV_LOVELY_HELM_REPO_ADD_PARAMS
              value: "--insecure-skip-tls-verify"
          name: argocd-lovely-plugin
Joibel commented 1 year ago

The second option, the env: section to the plugin. Github is having issues so the new version of the plugin hasn't built yet.

gabrielfsousa commented 1 year ago

is not the 0.10.0 ?

Joibel commented 1 year ago

It is, but the docker images for that haven't built correctly yet. Not sure if you can see this: https://github.com/crumbhole/argocd-lovely-plugin/actions/runs/3548614879

gabrielfsousa commented 1 year ago

im installing downloading the tar.gz and unpack to the right path

FROM argoproj/argocd:v2.5.2

LABEL author="Gabriel Sousa" \
      description="ArgoCD with plugins"

USER root

RUN apt-get update && \
    apt-get install -y \
            curl \
            wget && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /vartmp/*

ARG ALP_VERSION="0.10.0"
RUN wget https://github.com/crumbhole/argocd-lovely-plugin/releases/download/${ALP_VERSION}/argocd-lovely-plugin-${ALP_VERSION}-linux-amd64.tar.gz -P /tmp
RUN echo $(ls -1 /tmp)
RUN tar xvzf /tmp/argocd-lovely-plugin-${ALP_VERSION}-linux-amd64.tar.gz -C /tmp
RUN echo $(ls -1 /tmp)
RUN cp /tmp/argocd-lovely-plugin /usr/local/bin
RUN echo $(ls -1 /usr/local/bin)
RUN chown argocd:root /usr/local/bin/argocd-lovely-plugin
RUN echo $(ls -al /usr/local/bin/argocd-lovely-plugin)
ENV ARGOCD_USER_ID=999
ENV DEBIAN_FRONTEND=noninteractive
ENV USER=argocd
USER 999
gabrielfsousa commented 1 year ago

i manage to run helm dependency build successfully

but the plugin gives me the same error

argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/1$ helm repo add artifacthub.io https://registry.harbor/chartrepo/artifacthub.io  --insecure-skip-tls-verify
"artifacthub.io" has been added to your repositories
argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/1$ cat Chart.yaml
apiVersion: v2
name: weave-scope
version: 1.10.1
dependencies:
- name: weave-scope
  version: 1.0.1
  repository: https://registry.harbor/chartrepo/artifacthub.io
argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/1$ helm dependency build
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "harbor" chart repository
...Successfully got an update from the "weave-scope" chart repository
...Successfully got an update from the "artifacthub.io" chart repository
...Successfully got an update from the "harbor-bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading weave-scope from repo https://registry.harbor/chartrepo/artifacthub.io
Deleting outdated charts
argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/lovely-plugin-1761433463$ pwd
/tmp/lovely-plugin-1761433463
argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/lovely-plugin-1761433463$ ls -al
total 12
drwxr-xr-x 2 argocd argocd  63 Nov 25 16:01 .
drwxrwxrwx 8 root   root   194 Nov 25 16:14 ..
-rw-r--r-- 1 argocd argocd 181 Nov 25 16:01 Chart.yaml
-rw-r--r-- 1 argocd argocd 297 Nov 25 16:01 cluster.yaml
-rw-r--r-- 1 argocd argocd 629 Nov 25 16:01 values.yaml
argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/lovely-plugin-1761433463$ helm dependency build
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "artifacthub.io" chart repository
...Successfully got an update from the "harbor" chart repository
...Successfully got an update from the "weave-scope" chart repository
...Successfully got an update from the "harbor-bitnami" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading weave-scope from repo https://registry.harbor/chartrepo/artifacthub.io
Deleting outdated charts
argocd@argocd-repo-server-f96bf5d7b-mznx7:/tmp/lovely-plugin-1761433463$
gabrielfsousa commented 1 year ago

found other issue, if i add ARGOCD_ENV_LOVELY_HELM_REPO_ADD_PARAMS in env: plugin wont create the dir /tmp/lovely-plugin-xxxxxxxxxx

Joibel commented 1 year ago

The variable in env should be called LOVELY_HELM_REPO_ADD_PARAMS without ARGOCDENV in the front.

gabrielfsousa commented 1 year ago

yeah, found out 2 days ago.. after my post, will test again, and will report. thanks

Before reaching the init.command, generate.command, and discover.command commands, Argo CD prefixes all user-supplied environment variables (#3 above) with ARGOCD_ENV_. This prevents users from directly setting potentially-sensitive environment variables.
Joibel commented 1 year ago

I'll assume this is sorted now, please reopen if not.