|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * argocd_instance/argo-cd-cr-component-properties.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="configuring-annotation-based-tracking-in-multiple-argo-cd-instances_{context}"] |
| 7 | += Configuring annotation-based tracking in multiple Argo CD instances |
| 8 | + |
| 9 | +You can configure annotation-based tracking in multiple Argo CD instances. |
| 10 | + |
| 11 | +[NOTE] |
| 12 | +==== |
| 13 | +This procedure uses the following example values: |
| 14 | +
|
| 15 | +* `repoURL`: `\https://github.com/redhat-developer/gitops-operator` |
| 16 | +* `server`: `\https://kubernetes.default.svc` |
| 17 | +
|
| 18 | +When you follow these steps, replace the example values with the actual values. |
| 19 | +==== |
| 20 | + |
| 21 | +.Pre-requisites |
| 22 | + |
| 23 | +* You have logged in to the {OCP} cluster as an administrator. |
| 24 | +* You have installed the {gitops-title} Operator on your {OCP} cluster. |
| 25 | +
|
| 26 | +.Procedure |
| 27 | + |
| 28 | +. Log in to the {OCP} web console. |
| 29 | + |
| 30 | +. In the *Administrator* perspective of the web console, click *Operators* -> *Installed Operators*. |
| 31 | + |
| 32 | +* In the *Project* list, create or select the project where you want to install the user-defined Argo CD instance. |
| 33 | +
|
| 34 | +. Select *{gitops-title}* from the installed Operators list and click the *Argo CD* tab. |
| 35 | + |
| 36 | +. To create two Argo CD instances, click *Create ArgoCD* and create two YAML files similar to the following examples: |
| 37 | ++ |
| 38 | +.Example first Argo CD instance with an annotation label |
| 39 | +[source,yaml] |
| 40 | +---- |
| 41 | +apiVersion: argoproj.io/v1beta1 |
| 42 | +kind: ArgoCD |
| 43 | +metadata: |
| 44 | + name: argocd-instance-demo-1 # <1> |
| 45 | + namespace: argocd-test-demo-1 # <2> |
| 46 | +spec: |
| 47 | + installationID: "instance-demo-1" # <3> |
| 48 | + resourceTrackingMethod: "annotation+label" |
| 49 | +---- |
| 50 | +<1> Specifies the name of the first Argo CD instance. |
| 51 | +<2> Specifies the namespace used for the first Argo CD instance. |
| 52 | +<3> Specifies the name of the `installationID` object for the first Argo CD instance. |
| 53 | ++ |
| 54 | +.Example second Argo CD instance with an annotation label |
| 55 | +[source,yaml] |
| 56 | +---- |
| 57 | +apiVersion: argoproj.io/v1beta1 |
| 58 | +kind: ArgoCD |
| 59 | +metadata: |
| 60 | + name: argocd-instance-demo-2 # <1> |
| 61 | + namespace: argocd-test-demo-2 # <2> |
| 62 | +spec: |
| 63 | + installationID: "instance-demo-2" # <3> |
| 64 | + resourceTrackingMethod: "annotation+label" |
| 65 | +---- |
| 66 | ++ |
| 67 | +<1> Specifies the name of the second Argo CD instance. |
| 68 | +<2> Specifies the namespace used for the second Argo CD instance. |
| 69 | +<3> Specifies the name of the `installationID` object for the second Argo CD instance. |
| 70 | + |
| 71 | +. Configure and label target namespaces to associate namespaces with their Argo CD instances. |
| 72 | +.. Navigate to *Administration* -> *Namespaces*. |
| 73 | +.. Create namespaces for application deployments, `app-ns-1` and `app-ns-2`. |
| 74 | +.. Associate each namespace with their respective Argo CD instance: |
| 75 | +... Associate the `app-ns-1` namespace with the `argocd-test-demo-1` Argo CD instance by running the following command: |
| 76 | ++ |
| 77 | +.Example command |
| 78 | +[source,terminal] |
| 79 | +---- |
| 80 | +$ oc label namespace app-ns-1 argocd.argoproj.io/managed-by=argocd-test-demo-1 |
| 81 | +---- |
| 82 | +... Associate the `app-ns-2` namespace with the `argocd-test-demo-2` Argo CD instance by running the following command: |
| 83 | ++ |
| 84 | +.Example command |
| 85 | +[source,terminal] |
| 86 | +---- |
| 87 | +$ oc label namespace app-ns-2 argocd.argoproj.io/managed-by=argocd-test-demo-2 |
| 88 | +---- |
| 89 | ++ |
| 90 | +. Create two applications in Argo CD. |
| 91 | +.. In the {OCP} web console, go to *Operators* -> *Installed Operators* -> *OpenShift GitOps Operator*. |
| 92 | +.. Select *Argo CD* and navigate to the *Applications* tab. |
| 93 | +.. Click *Create Application*. |
| 94 | +.. Enter the following YAML snippet to create two applications in Argo CD. |
| 95 | ++ |
| 96 | +.Example first application using Argo CD |
| 97 | +[source,yaml] |
| 98 | +---- |
| 99 | +apiVersion: argoproj.io/v1alpha1 |
| 100 | +kind: Application |
| 101 | +metadata: |
| 102 | + name: sprint-petclinic # <1> |
| 103 | + namespace: argocd-test-demo-1 # <2> |
| 104 | +spec: |
| 105 | + project: default |
| 106 | + source: |
| 107 | + repoURL: https://github.com/redhat-developer/gitops-operator |
| 108 | + path: test/examples/nginx |
| 109 | + targetRevision: HEAD |
| 110 | + destination: |
| 111 | + server: https://kubernetes.default.svc |
| 112 | + namespace: app-ns-1 |
| 113 | + syncPolicy: |
| 114 | + automated: {} |
| 115 | +---- |
| 116 | +<1> Specifies the name of the first application. |
| 117 | +<2> Specifies the namespace used for the first application. |
| 118 | ++ |
| 119 | +.Example second application using Argo CD |
| 120 | +[source,yaml] |
| 121 | +---- |
| 122 | +apiVersion: argoproj.io/v1alpha1 |
| 123 | +kind: Application |
| 124 | +metadata: |
| 125 | + name: sprint-petclinic # <1> |
| 126 | + namespace: argocd-test-demo-2 # <2> |
| 127 | +spec: |
| 128 | + project: default |
| 129 | + source: |
| 130 | + repoURL: https://github.com/redhat-developer/gitops-operator |
| 131 | + path: test/examples/nginx |
| 132 | + targetRevision: HEAD |
| 133 | + destination: |
| 134 | + server: https://kubernetes.default.svc |
| 135 | + namespace: app-ns-2 |
| 136 | + syncPolicy: |
| 137 | + automated: {} |
| 138 | +---- |
| 139 | +<1> Specifies the name of the second application that is created with the same name as the first application. |
| 140 | +<2> Specifies the namespace used for the second application. |
| 141 | + |
| 142 | +.Verification |
| 143 | +. Navigate to *Workloads* -> *Pods* in the {OCP} web console. |
| 144 | +. Ensure that the pods for Argo CD instances `argocd-instance-demo-1` and `argocd-instance-demo-2` are running. |
| 145 | +. Check the application synchronization status in the *Argo CD Applications* YAML tab. |
| 146 | +. Navigate to the `argocd-cm` config map in `argocd-test-demo-1` and `argocd-test-demo-2` namespaces and verify that the `installationID` object is configured successfully. |
0 commit comments