|
16 | 16 | - repository access |
17 | 17 | --- |
18 | 18 |
|
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. |
24 | | - |
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: |
| 19 | +We're excited to announce that support for private repositories is now available. This feature requires VP operator version 0.0.36 or higher with the latest common/ clustergroup 0.8.2 chart. With this update, you can deploy patterns from git repositories that are either password-protected or secured with an SSH key. |
| 20 | + |
| 21 | +## Setting up a private repository with SSH |
| 22 | + |
| 23 | +To deploy a pattern from a private repository, follow these steps: |
| 24 | + |
| 25 | +### Create a secret for repository access |
| 26 | + |
| 27 | +Generate a secret containing the credentials for accessing your repository. This secret should be formatted according to [ArgoCD's declarative setup guidelines](https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#repositories). For example: |
| 28 | + |
| 29 | +```yaml |
| 30 | +apiVersion: v1 |
| 31 | +kind: Secret |
| 32 | +metadata: |
| 33 | + name: private-repo |
| 34 | + namespace: openshift-operators |
| 35 | + labels: |
| 36 | + argocd.argoproj.io/secret-type: repository |
| 37 | +stringData: |
| 38 | + type: git |
| 39 | + url: git@github.com:mbaldessari/mcg-private.git |
| 40 | + sshPrivateKey: | |
| 41 | + -----BEGIN OPENSSH PRIVATE KEY----- |
| 42 | + a3... |
| 43 | + ... |
| 44 | + ... |
| 45 | + -----END OPENSSH PRIVATE KEY----- |
| 46 | +``` |
| 47 | +
|
| 48 | +### Deploy the pattern with the secret |
| 49 | +
|
| 50 | +Point your pattern's Custom Resource to the secret you created. Ensure that the `tokenSecret` and `tokenSecretNamespace` fields reference your new secret: |
| 51 | + |
| 52 | +```yaml |
| 53 | +apiVersion: gitops.hybrid-cloud-patterns.io/v1alpha1 |
| 54 | +kind: Pattern |
| 55 | +metadata: |
| 56 | + name: pattern-sample |
| 57 | + namespace: patterns-operator |
| 58 | +spec: |
| 59 | + clusterGroupName: hub |
| 60 | + gitSpec: |
| 61 | + targetRepo: git@github.com:mbaldessari/mcg-private.git |
| 62 | + targetRevision: private-repo |
| 63 | + tokenSecret: private-repo |
| 64 | + tokenSecretNamespace: openshift-operators |
| 65 | +``` |
| 66 | + |
| 67 | +This ensures that the pattern framework manages the necessary configurations, allowing all Argo instances to access the private repository. |
| 68 | + |
| 69 | +Alternatively, you can do this entirely via the CLI: |
| 70 | + |
73 | 71 | ```bash |
74 | 72 | ./pattern.sh make TOKEN_SECRET=private-repo TOKEN_NAMESPACE=openshift-operators install |
75 | 73 | ``` |
76 | 74 |
|
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. |
| 75 | +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. |
| 76 | + |
| 77 | +## Using a GitLab private repository with a PAT |
| 78 | + |
| 79 | +First, make sure your PAT has at least Read and Download permissions for your private repository. |
| 80 | + |
| 81 | +As with the SSH example above, create a secret before running the install: |
| 82 | + |
| 83 | +```yaml |
| 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 that the username must be `oauth2`, not your GitLab handle. |
| 99 | + |
| 100 | +Then reference the secret in the install: |
| 101 | + |
| 102 | +```bash |
| 103 | +./pattern.sh make TOKEN_SECRET=private-repo TOKEN_NAMESPACE=openshift-operators install |
| 104 | +``` |
0 commit comments