|
| 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