Skip to content

Commit abc3e02

Browse files
authored
Merge pull request #679 from dminnear-rh/update-private-repo-docs
add gitlab https private repo section
2 parents f370a83 + 3f519e4 commit abc3e02

2 files changed

Lines changed: 107 additions & 60 deletions

File tree

content/blog/2023-12-20-private-repos.md

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,64 +16,6 @@
1616
- repository access
1717
---
1818

19-
We're excited to announce that support for private repositories is now
20-
available. This feature is accessible when using VP operator version 0.0.36 or
21-
higher, in conjunction with the latest common/ clustergroup 0.8.2 chart. With
22-
this update, you can deploy patterns from git repositories that are either
23-
password-protected or secured with an SSH key.
19+
We're excited to announce that support for private repositories is now available. You can deploy patterns from git repositories that are either password-protected or secured with an SSH key.
2420

25-
To enable this feature, follow these steps:
26-
27-
1. Create a Secret for Repository Access: Generate a secret that holds the
28-
credentials for accessing your repository. This secret should be formatted
29-
according to ArgoCD's guidelines, which you can find [here](https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#repositories).
30-
For instance, your secret might look like this:
31-
```yaml
32-
apiVersion: v1
33-
kind: Secret
34-
metadata:
35-
name: private-repo
36-
namespace: openshift-operators
37-
labels:
38-
argocd.argoproj.io/secret-type: repository
39-
stringData:
40-
type: git
41-
url: git@github.com:mbaldessari/mcg-private.git
42-
sshPrivateKey: |
43-
-----BEGIN OPENSSH PRIVATE KEY-----
44-
a3...
45-
...
46-
...
47-
-----END OPENSSH PRIVATE KEY-----
48-
```
49-
2. Deploy the Pattern with the Secret: Point your pattern's Custom Resource to
50-
the secret you created in the first step. Ensure that both tokenSecret and
51-
tokenSecretNamespace fields are correctly set to reference your new secret.
52-
Here's an example of how this might be configured:
53-
```yaml
54-
apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1
55-
kind: Pattern
56-
metadata:
57-
name: pattern-sample
58-
namespace: openshift-operators
59-
spec:
60-
clusterGroupName: hub
61-
gitSpec:
62-
targetRepo: git@github.com:mbaldessari/mcg-private.git
63-
targetRevision: private-repo
64-
tokenSecret: private-repo
65-
tokenSecretNamespace: openshift-operators
66-
```
67-
68-
Following these steps ensures that the pattern's framework efficiently manages
69-
the necessary configurations, allowing all Argo instances to access the private
70-
repository.
71-
72-
To do this entirely via CLI you can simply run the following:
73-
```bash
74-
./pattern.sh make TOKEN_SECRET=private-repo TOKEN_NAMESPACE=openshift-operators install
75-
```
76-
77-
The above command assumes that the `private-repo` secret exists and that the
78-
`origin` remote of the repository points to
79-
`git@github.com:mbaldessari/mcg-private.git` as specified in the secret above.
21+
For setup instructions, see [Installing Patterns in Private Repos](/learn/private-repos/).

content/learn/private-repos.adoc

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
menu:
3+
learn:
4+
parent: Patterns quick start
5+
title: Installing Patterns in Private Repos
6+
weight: 51
7+
aliases: /learn/private-repos/
8+
---
9+
10+
:toc:
11+
:_content-type: ASSEMBLY
12+
include::modules/comm-attributes.adoc[]
13+
14+
[id="private-repos"]
15+
== Deploying patterns from private repositories
16+
17+
You can deploy patterns from git repositories that are either password-protected or secured with an SSH key.
18+
19+
== Using an SSH key
20+
21+
To deploy a pattern from an SSH-secured private repository, create a secret for repository access and then reference it in your pattern's Custom Resource.
22+
23+
=== Create a secret for repository access
24+
25+
Generate a secret containing the credentials for accessing your repository. This secret should be formatted according to link:https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#repositories[ArgoCD's declarative setup guidelines].
26+
27+
[source,yaml]
28+
----
29+
apiVersion: v1
30+
kind: Secret
31+
metadata:
32+
name: private-repo
33+
namespace: openshift-operators
34+
labels:
35+
argocd.argoproj.io/secret-type: repository
36+
stringData:
37+
type: git
38+
url: git@github.com:mbaldessari/mcg-private.git
39+
sshPrivateKey: |
40+
-----BEGIN OPENSSH PRIVATE KEY-----
41+
a3...
42+
...
43+
...
44+
-----END OPENSSH PRIVATE KEY-----
45+
----
46+
47+
=== Deploy the pattern with the secret
48+
49+
Reference the secret you created by passing `TOKEN_SECRET` and `TOKEN_NAMESPACE` to the install command:
50+
51+
[source,terminal]
52+
----
53+
./pattern.sh make TOKEN_SECRET=private-repo TOKEN_NAMESPACE=openshift-operators install
54+
----
55+
56+
This command assumes that the `private-repo` secret exists and that the `origin` remote of the repository points to `git@github.com:mbaldessari/mcg-private.git` as specified in the secret. The install sets the `tokenSecret` and `tokenSecretNamespace` fields on the pattern's Custom Resource, which ensures that all Argo instances can access the private repository.
57+
58+
If you need to create the pattern CR manually instead, set those fields directly:
59+
60+
[source,yaml]
61+
----
62+
apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1
63+
kind: Pattern
64+
metadata:
65+
name: pattern-sample
66+
namespace: patterns-operator
67+
spec:
68+
clusterGroupName: hub
69+
gitSpec:
70+
targetRepo: git@github.com:mbaldessari/mcg-private.git
71+
targetRevision: private-repo
72+
tokenSecret: private-repo
73+
tokenSecretNamespace: openshift-operators
74+
----
75+
76+
== Using a GitLab private repository with a PAT
77+
78+
First, make sure your PAT has at least Read and Download permissions for your private repository.
79+
80+
As with the SSH example above, create a secret before running the install:
81+
82+
[source,yaml]
83+
----
84+
apiVersion: v1
85+
kind: Secret
86+
metadata:
87+
name: private-repo
88+
namespace: openshift-operators
89+
labels:
90+
argocd.argoproj.io/secret-type: repository
91+
stringData:
92+
type: git
93+
url: https://gitlab.com/dminnear-rh/mcg-private.git
94+
username: oauth2
95+
password: glpat-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
96+
----
97+
98+
NOTE: The username must be `oauth2`, not your GitLab handle.
99+
100+
Then reference the secret in the install:
101+
102+
[source,terminal]
103+
----
104+
./pattern.sh make TOKEN_SECRET=private-repo TOKEN_NAMESPACE=openshift-operators install
105+
----

0 commit comments

Comments
 (0)