Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

argocd kustomize github ssh key #9631

Open
vvatlin opened this issue Jun 10, 2022 · 23 comments
Open

argocd kustomize github ssh key #9631

vvatlin opened this issue Jun 10, 2022 · 23 comments
Labels
bug Something isn't working

Comments

@vvatlin
Copy link

vvatlin commented Jun 10, 2022

Hello.

I don't know how to use GitHub public repo with argocd and kustomize.

Here is an example:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: mongodb

resources:
# mongodb community operator
- github.com/mongodb/mongodb-kubernetes-operator/config/crd?ref=v0.7.3
- github.com/mongodb/mongodb-kubernetes-operator/config/rbac?ref=v0.7.3
- github.com/mongodb/mongodb-kubernetes-operator/config/manager?ref=v0.7.3

When I use just kustomize on my laptop - everything is ok, because I have ssh private key.

But argocd failed with the error:

rpc error: code = Unknown desc = Manifest generation error (cached): `kustomize build .mongodb/overlays/test` failed exit status 1: Error: accumulating resources: accumulation err='accumulating resources from 'github.com/mongodb/mongodb-kubernetes-operator/config/crd?ref=v0.7.3': evalsymlink failure on '.mongodb/overlays/test/github.com/mongodb/mongodb-kubernetes-operator/config/crd?ref=v0.7.3' : lstat .mongodb/overlays/test/github.com: no such file or directory': git cmd = '/usr/bin/git submodule update --init --recursive': exit status 1

I've tried to create Secrets for repo with url

  url: github.com/mongodb/mongodb-kubernetes-operator
  url: https://github.com/mongodb/mongodb-kubernetes-operator
  url: git@github.com:mongodb/mongodb-kubernetes-operator

and my private key

Like this:

apiVersion: v1
kind: Secret
metadata:
  name: mongodb-kubernetes-operator1
  namespace: argocd
  labels:
    argocd.argoproj.io/secret-type: repository
stringData:
  url: https://github.com/mongodb/mongodb-kubernetes-operator
  sshPrivateKey: |
    -----BEGIN OPENSSH PRIVATE KEY-----
    -----END OPENSSH PRIVATE KEY-----

But It didn't help.

How can I fix this ?

@vvatlin vvatlin added the bug Something isn't working label Jun 10, 2022
@vrajendra
Copy link

i am facing this error too

ComparisonError: rpc error: code = Unknown desc = sh -c helm template --release-name release-name . > all.yaml && kustomize build failed exit status 1: Error: accumulating resources: accumulation err='accumulating resources from 'git@github.com:url//base/library': evalsymlink failure on '.gatekeeper/git@github.com:url/base/library' : lstat .gatekeeper/git@github.com:vrajendra: no such file or directory': git cmd = '/usr/bin/git fetch --depth=1 origin HEAD': exit status 128

my kustomization.yaml is below

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- git@github.com:url//base/library
- ./all.yaml

@vvatlin
Copy link
Author

vvatlin commented Jun 12, 2022

I was able to fix this with this approach:
#827

But it looks awful to patch argocd-repo-server to add private key to .ssh folder..

@vrajendra
Copy link

I was able to fix this with this approach: #827

But it looks awful to patch argocd-repo-server to add private key to .ssh folder..

Hi @vvatlin I was able to fix the issue by following the above approach by modifying the repo-server deployment also made the readonlyfilesystem to false but i have to manually run the command inside the reposerver pod to get it synced successfuly

argocd repo add git@github.com:vrajendra/terraformcode_sample --ssh-private-key-path ~/.ssh/id_rsa

@prasobhen
Copy link

Hello .

I was able to run the kustomize build locally with base as azure repo, but when I am trying to run the pipeline from azure devops I am getting this error

lstat /__w/1/s/deployment/kustomize/overlays/dev/git@ssh.dev.azure.com:v3: no such file or directory': git cmd = '/usr/bin/git fetch --depth=1 origin HEAD': exit status 128

@prasobhen
Copy link

Error: accumulating resources: accumulation err='accumulating resources from 'https://dev.azure.com/xxxx/xxx/_git/repo?path=/k8s/backend/bases': yaml: line 27: mapping values are not allowed in this context': git cmd = '/usr/bin/git fetch --depth=1 origin HEAD': exit status 128

Could some one help me on this error

@fantasticnaveen
Copy link

fantasticnaveen commented Jul 21, 2022

@prasobhen

use the following format
https://dev.azure.com/org/project/_git/<base_repo>/base?ref=0.1.0

you can remove the ref if you dont have a tag or branch and the kustomization file is in master branch

@prasobhen
Copy link

@fantasticnaveen

https://dev.azure.com/org/project/_git/<base_repo>/k8s/backend/bases?

I am going to use above one

@fantasticnaveen
Copy link

fantasticnaveen commented Jul 21, 2022

@prasobhen

https://dev.azure.com/org/project/_git/<base_repo>/k8s/backend/bases?

I am going to use above one

remove the ? and get your actual git url before base repo

@prasobhen
Copy link

@fantasticnaveen

Still getting same error from azure pipeline

Error: accumulating resources: accumulation err='accumulating resources from 'https://dev.azure.com/myorg/myproject/_git/my_repo/k8s/backend/bases': yaml: line 6: mapping values are not allowed in this context': git cmd = '/usr/bin/git fetch --depth=1 origin HEAD': exit status 128

@fantasticnaveen
Copy link

fantasticnaveen commented Jul 21, 2022

@prasobhen I think you want to use kustomize . also your repo is a private azure repo with restrictions. please have look at here https://github.com/argoproj/argocd-example-apps/tree/master/plugins/kustomized-helm to setup the plugin to use it with argocd. make sure you are able test the kustomize build and the base repo URL in a standalone machine , if that works and if you setup the CMP plugin , you should resolve the issue. for private repository setup check this https://argo-cd.readthedocs.io/en/release-1.8/user-guide/private-repositories/ . make sure you have kustomization.yaml directly under the bases directory

@fantasticnaveen
Copy link

@prasobhen this thread is for argocd . and you mentioning azure pipeline, which i could not understand. may be this is not the thread

@prasobhen
Copy link

@fantasticnaveen This is for argocd and when I run the kustomize build I am getting this error. is there anything I need to add additionally?

@fantasticnaveen
Copy link

fantasticnaveen commented Jul 22, 2022

@prasobhen from your machine test kustomize build base url and paste the output . Also tell me how you integrated kustomize in argocd

@prasobhen
Copy link

resources:

transformers:
- labels-transformer.yaml

This how my kustomization.yaml in the overlays

@fantasticnaveen
Copy link

@prasobhen from your machine test kustomize build and paste the output

@prasobhen
Copy link

Error: accumulating resources: accumulation err='accumulating resources from 'https://dev.azure.com/myorg/myproject/_git/my_repo/k8s/backend/bases': yaml: line 6: mapping values are not allowed in this context': git cmd = '/usr/bin/git fetch
--depth=1 origin HEAD': exit status 128

@fantasticnaveen
Copy link

fantasticnaveen commented Jul 22, 2022

what is line 6 in your kustomization.yaml . probably a syntax error . go to http://www.yamllint.com/ and find the error

@prasobhen
Copy link

yaml file looks fine and also tried using ssh locally and build was working. But when I am using https I get above error. I will double check the authentication part and update

@fantasticnaveen
Copy link

you have use PAT. look here #6289

@prasobhen
Copy link

Yes I was checking internally by generation the PFA..I tried using PAT in in the Kustomization and it worked.. I will have to check option to pass the value in the pipeline. Thanks @fantasticnaveen for the suggestion

@kxs-sindrakumar
Copy link

I get this error with github. When using https. My format is:

https://github.com/myorg/ce-cluster-addons/cert-manager/overlays/tenant/myenv?ref=v0.3.5

@melnikovn
Copy link

hitting the same issue...

@melnikovn
Copy link

any plans to get this fixed, team?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants