Skip to content

Commit 3b71bd0

Browse files
alexmtalexec
authored andcommitted
Issue #1411 - Document private repository configuration (#1515)
1 parent e75a7a5 commit 3b71bd0

File tree

6 files changed

+157
-0
lines changed

6 files changed

+157
-0
lines changed
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Private Repositories
2+
3+
## Credentials
4+
5+
If application manifests are located in private repository then repository credentials have to be configured. Argo CD supports both HTTP and SSH Git credentials.
6+
7+
### HTTP Username And Password Credential
8+
9+
Private repositories that require a username and password typically have a URL that start with "https://" rather than "git@" or "ssh://".
10+
11+
Credentials can be configured using Argo CD CLI:
12+
13+
```bash
14+
argocd repo add https://github.com/argoproj/argocd-example-apps --username <username> --password <password>
15+
```
16+
17+
or UI:
18+
19+
1. Navigate to `Settings/Repositories`
20+
1. Click `Connect Repo` button and enter HTTP credentials
21+
22+
![connect repo](../assets/connect_repo.png)
23+
24+
#### Access Token
25+
26+
Instead of using username and password you might use access token. Following instructions of your Git hosting service to generate the token:
27+
28+
* [Github](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
29+
* [Gitlab](https://docs.gitlab.com/ee/user/project/deploy_tokens/)
30+
* [Bitbucket](https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html)
31+
32+
Then, connect the repository using an empty string as a username and access token value as a password.
33+
34+
### SSH Private Key Credential
35+
36+
Private repositories that require an SSH private key have a URL that typically start with "git@" or "ssh://" rather than "https://".
37+
38+
The Argo CD UI don't support configuring SSH credentials. The SSH credentials can only be configured using the Argo CD CLI:
39+
40+
```
41+
argocd repo add [email protected]:argoproj/argocd-example-apps.git --ssh-private-key-path ~/.ssh/id_rsa
42+
```
43+
44+
## Self-Signed Certificates
45+
46+
If you are using self-hosted Git hosting service with the self-signed certificate then you need to disable certificate validation for that Git host.
47+
Following options are available:
48+
49+
Add repository using Argo CD CLI and `--insecure-ignore-host-key` flag:
50+
51+
52+
```bash
53+
argocd repo add [email protected]:argoproj/argocd-example-apps.git --ssh-private-key-path ~/.ssh/id_rsa
54+
```
55+
56+
The flag disables certificate validation only for specified repository.
57+
58+
!!! warning
59+
The `--insecure-ignore-host-key` flag does not work for HTTPS Git URLs. See [#1513](https://github.com/argoproj/argo-cd/issues/1513).
60+
61+
You can add Git service hostname to the `/etc/ssh/ssh_known_hosts` in each Argo CD deployment and disables cert validation for Git SSL URLs. For more information see
62+
[example](https://github.com/argoproj/argo-cd/tree/master/examples/known-hosts) which demonstrates how `/etc/ssh/ssh_known_hosts` can be customized.
63+
64+
!!! note
65+
The `/etc/ssh/ssh_known_hosts` should include Git host on each Argo CD deployment as well as on a computer where `argocd repo add` is executed. After resolving issue
66+
[#1514](https://github.com/argoproj/argo-cd/issues/1514) only `argocd-repo-server` deployment has to be customized.
67+
68+
## Declarative Configuration
69+
70+
See [declarative setup](../operator-manual/declarative-setup#Repositories)
71+

examples/known-hosts/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Argo CD ssh_known_hosts file customization
2+
3+
The directory contains sample kustomize application which customizes `/etc/ssh/ssh_known_hosts` file in Argo CD. This is useful if you want to disable SSL cert validation
4+
for Git repositories connected using SSL urls:
5+
6+
- `argocd-known-hosts-mounts.yaml` - define merge patches which inject `/etc/ssh/ssh_known_hosts` file mount into all Argo CD deployments.
7+
- `argocd-known-hosts.yaml` - defines `ConfigMap` which includes `/etc/ssh/ssh_known_hosts` file content.
8+
- `kustomization.yaml` - Kustomize application which bundles stable version of Argo CD and apply `argocd-known-hosts-mounts.yaml` patches on top.
9+
10+
!!! note
11+
The `/etc/ssh/ssh_known_hosts` should include Git host on each Argo CD deployment as well as on a computer where `argocd repo add` is executed. After resolving issue
12+
[#1514](https://github.com/argoproj/argo-cd/issues/1514) only `argocd-repo-server` deployment has to be customized.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: argocd-server
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: argocd-server
11+
volumeMounts:
12+
- name: known-hosts
13+
mountPath: /etc/ssh/ssh_known_hosts
14+
subPath: known_hosts
15+
volumes:
16+
- name: known-hosts
17+
configMap:
18+
name: argocd-known-hosts
19+
---
20+
apiVersion: apps/v1
21+
kind: Deployment
22+
metadata:
23+
name: argocd-repo-server
24+
spec:
25+
template:
26+
spec:
27+
containers:
28+
- name: argocd-repo-server
29+
volumeMounts:
30+
- name: known-hosts
31+
mountPath: /etc/ssh/ssh_known_hosts
32+
subPath: known_hosts
33+
volumes:
34+
- name: known-hosts
35+
configMap:
36+
name: argocd-known-hosts
37+
---
38+
apiVersion: apps/v1
39+
kind: Deployment
40+
metadata:
41+
name: argocd-application-controller
42+
spec:
43+
template:
44+
spec:
45+
containers:
46+
- name: argocd-application-controller
47+
volumeMounts:
48+
- name: known-hosts
49+
mountPath: /etc/ssh/ssh_known_hosts
50+
subPath: known_hosts
51+
volumes:
52+
- name: known-hosts
53+
configMap:
54+
name: argocd-known-hosts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: argocd-known-hosts
6+
data:
7+
known_hosts: |-
8+
<known_hosts file content>
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
bases:
5+
- github.com/argoproj/argo-cd//manifests/cluster-install?ref=stable
6+
7+
patchesStrategicMerge:
8+
- argocd-known-hosts-mounts.yaml
9+
10+
resources:
11+
- argocd-known-hosts.yaml

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ nav:
3737
- user-guide/index.md
3838
- user-guide/application_sources.md
3939
- user-guide/projects.md
40+
- user-guide/private-repositories.md
4041
- user-guide/tool_detection.md
4142
- user-guide/auto_sync.md
4243
- user-guide/diffing.md

0 commit comments

Comments
 (0)