Skip to content

Commit 375b7ec

Browse files
authored
Updated Argo lab (#272)
Signed-off-by: Noé Samaille <[email protected]> Signed-off-by: Noé Samaille <[email protected]>
1 parent c040d80 commit 375b7ec

File tree

1 file changed

+27
-137
lines changed
  • docs/developer-advanced-1/inventory-cd

1 file changed

+27
-137
lines changed

docs/developer-advanced-1/inventory-cd/index.md

Lines changed: 27 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@ This Micro App guidance continues to build upon the micro-services that were bui
1818

1919
## Using CD to deploy to Test
2020

21-
ArgoCD is a tool that provides continuous delivery for projects and applications. If you haven't already, be sure to read
22-
through the [Continuous Delivery with ArgoCD guide](/continuous-delivery).
23-
24-
For this exercise, we are going to use ArgoCD to push the Inventory app from `dev` to `test` (and possibly `staging` as well). If you have already completed the Inventory Micro App , then it can be used for the ArgoCD process (although perhaps with some minor pipeline updates). If you haven't completed the exercise, you can start from the [solution repositories](/developer-intermediate/inventory-app#deploy-the-inventory-app-solution) to perform the ArgoCD steps.
21+
ArgoCD is a tool that provides continuous delivery for projects and applications. For this exercise, we are going to use ArgoCD to push the Inventory app from `dev` to `test`. If you have already completed the Inventory Micro App, then it can be used for the ArgoCD process. If you haven't completed the exercise, you can start from the [solution repositories](/developer-intermediate/inventory-prebuilt-solution/) to perform the ArgoCD steps.
2522

2623

2724
### Set up the GitOps repo
2825

2926
Let's get started with using Argo CD.
3027

31-
- Create a new repo from the [ArgoCD Code Pattern](https://github.com/IBM/template-argocd-gitops/generate)
28+
- Create a new repo from the [ArgoCD Code Pattern](https://github.com/IBM/template-argocd-gitops/generate), name it something like `inv-app-gitops-{your initials}`.
3229

33-
- Clone the project to your machine
30+
- On the Web Terminal, clone the repository you have just created:
31+
```bash
32+
git clone https://github.com/{organization}/inv-app-gitops-{your initials}
33+
cd inv-app-gitops-{your initials}
34+
```
3435

35-
- Create a branch named `test`
36+
- Create a branch named `test`:
3637
```bash
3738
git checkout -b test
3839
```
@@ -42,6 +43,20 @@ Let's get started with using Argo CD.
4243
git push -u origin test
4344
```
4445

46+
- Hook the CI pipeline to the CD pipeline, using the `test` branch of the current gitops repository:
47+
```bash
48+
igc gitops
49+
```
50+
51+
!!! note
52+
**What just happened?**: The `igc gitops` command creates a secret `git-credentials` and a configmap named `gitops-repo` in the OpenShift project. These contain the url, username, password, and branch information for the GitOps repository. You can verify the secret was created by running:
53+
```bash
54+
oc get configmap/gitops-repo -n dev-{initials} -o yaml
55+
oc get secret/git-credentials -n dev-{initials} -o yaml
56+
```
57+
58+
- Manually trigger the pipeline for the Inventory Management service by going to the last pipeline run and click **Action**, then **Rerun**. When the pipeline has finished you will see a new folder on the `test` branch of the GitOps repo.
59+
4560
- Create the test namespace with the CLI by running `oc sync test-{initials}`
4661

4762
### Grant required access to the service account of the test namespace
@@ -56,12 +71,7 @@ oc policy add-role-to-group system:image-puller system:serviceaccounts:${TEST_NA
5671

5772
Now that the repository has been created, we need to tell ArgoCD where it is.
5873

59-
- Get the ArgoCD login information from the `oc credentials` cli command
60-
61-
!!! note
62-
You need to be logged into the cluster on the command-line for the CLI to access the cluster information.
63-
64-
- Log into ArgoCD (use `oc credentials` to obtain your credentials and login to argo)
74+
- Log into ArgoCD using the `Cluster Argo CD` console link on the top menu of the OpenShift console.
6575

6676
- Click on the gear icon on the left menu to access the Settings options
6777

@@ -80,7 +90,7 @@ on what can be done for applications that make up a project.
8090

8191
To create a project, do the following:
8292

83-
- Log into ArgoCD
93+
- Log into ArgoCD using the `Cluster Argo CD` console link on the top menu of the OpenShift console.
8494

8595
- Click on the gear icon on the left menu to access the Settings options
8696

@@ -97,61 +107,10 @@ To create a project, do the following:
97107
- `sources` - click `add source` and pick the Git repository from the list that was added previously
98108
- `destinations`
99109
- Add `https://kubernetes.default.svc` for the cluster url and `test-{initials}` for the namespace
100-
- Add `https://kubernetes.default.svc` for the cluster url and `staging-{initials}` for the namespace
101110
102111
**Note:** Initially, the only cluster that is available is the one in which ArgoCD is -
103112
`https://kubernetes.default.svc`. By adding the two destinations we have allowed the project to be deployed
104-
to both the `test-{initials}` and `staging-{initials}` namespaces within the current cluster.
105-
106-
### Configure the GitOps repo for Inventory Management service
107-
108-
- Clone the GitOps repository you created earlier, copy the folder `templates/app-helm` to the root of the repository and give it a name that matches the Inventory Management service component
109-
(e.g. `inv-svc-{initials}`)
110-
111-
- Update `inv-svc-{initials}/Chart.yaml` and update the name to match the directory name
112-
113-
- Update `inv-svc-{initials}/requirements.yaml` with the following values:
114-
115-
- `name` - the name of helm chart/image. This should match the folder name
116-
- `version` - the version number of the helm chart
117-
- `repository` - the url to the helm repository including the folder where helm charts are being stored.
118-
119-
- here is an example
120-
```yaml
121-
dependencies:
122-
- name: inv-svc-mjp
123-
version: 1.0.0-1
124-
repository: http://artifactory.mooc-one-rhos-cluster.us-east.containers.appdomain.cloud/artifactory/generic-local/mooc-team-one/
125-
```
126-
- The url of the Artifactory helm repository can be taken from the below step.
127-
128-
129-
- In the Artifactory Setup screen, in Set Me Up Section, select the tool as "Generic" and repository as "generic-local". Copy the deploy URL from the Set Me Up dialog box. That is the Artifactory helm repository URL.
130-
![ArtifactoryURLSetup config](images/artifactoryurlsetup.png)
131-
132-
- Run `kubectl get configmap/ibmcloud-config -n tools -o yaml` to print the configuration information
133-
for the cluster
134-
135-
- In `inv-svc-{initials}/values.yaml` replace `<app-chart-name>` with the directory name. Replace `ingressSubdomain` with the value from the previous step. Update `tlsSecretName` with the value from the previous step. The result should look something like the following
136-
```yaml title="inv-svc-{initials}/values.yaml"
137-
global:
138-
ingressSubdomain: sms-test.us-south.containers.appdomain.cloud
139-
tlsSecretName: sms-test-cluster
140-
141-
inv-svc-{initials}:
142-
replicaCount: 1
143-
144-
ingress:
145-
enabled: true
146-
tlsSecretName: sms-test-cluster
147-
```
148-
149-
- Commit and push the changes
150-
```bash
151-
git add .
152-
git commit -m "Adds inv-svc config"
153-
git push
154-
```
113+
to both the `test-{initials}` namespaces within the current cluster.
155114
156115
### Add an application in ArgoCD for the Inventory Management service
157116
@@ -174,77 +133,8 @@ connecting the config within the Git repo to the cluster and namespace.
174133
175134
- Click `Create`
176135
177-
- Click on the newly created application. A graph of kubernetes resources should be shown
178-
if everything is configured correctly.
179-
180-
### Make a change in the GitOps repo
181-
182-
In order to trigger a (re-)deployment we can make an update to a value in the GitOps repo and
183-
watch ArgoCD apply the change.
184-
185-
- Open a terminal and navigate to your GitOps repo directory
186-
187-
- Be sure that you are in the `test` branch
188-
```bash
189-
git checkout test
190-
```
191-
192-
- Update `inv-svc-{initials}/values.yaml` to increase the replica count
193-
```yaml title="inv-svc-{initials}/values.yaml"
194-
global:
195-
ingressSubdomain: sms-test.us-south.containers.appdomain.cloud
196-
tlsSecretName: sms-test-cluster
197-
198-
inv-svc-{initials}:
199-
replicaCount: 3
200-
201-
ingress:
202-
enabled: true
203-
tlsSecretName: sms-test-cluster
204-
```
205-
206-
- Commit and push the change
207-
```bash
208-
git add .
209-
git commit -m "Increases replica count"
210-
```
211-
212-
- Log into the ArgoCD UI and look at the state of the application. It should say `Synchronizing`.
213-
If you don't want to wait you can manually by pressing the `Synchronize` button.
214-
215-
### Hook the CI pipeline to the CD pipeline
216-
217-
The last stage in the CI pipeline updates the version number in the `requirements.yaml` to the version of the helm chart
218-
that was just built. Through a couple naming conventions the only thing the pipeline needs in order to interact
219-
with the CD process is a kubernetes secret named `gitops-cd-secret` that provides the details needed
220-
to connect to the git repo to push updates.
221-
222-
The [IGC CLI](/getting-started/cli) has a command that provides a helper to make the creating of a kubernetes secret
223-
with git credentials very easy.
224-
225-
- Log into the cluster on the command-line and select your dev project.
226-
227-
- Run `igc gitops <GITOPS_REPO_URL>`. This command will prompt for the username,
228-
personal access token, and the branch to use.
229-
230-
### What just happened?
231-
232-
- The `igc gitops` command creates a secret `git-credentials` and a configmap named `gitops-repo` in the OpenShift project. These contain the url, username, password, and branch information for the GitOps repository. You can verify the secret was created by running:
233-
234-
```bash
235-
oc get configmap/gitops-repo -n dev-{initials} -o yaml
236-
oc get secret/git-credentials -n dev-{initials} -o yaml
237-
```
238-
239-
!!! note
240-
- For the secret to be available to the CI pipeline, the secret needs to be created in the same namespace
241-
where the pipeline is running (e.g. `dev-{initials}`).
242-
- The value provided for `branch` is the one the pipeline will use to when committing changes to trigger
243-
the CD pipeline. `test` is the recommended value for the branch field.
244-
245-
- Trigger the pipeline for the Inventory Management service to build by making a change to the Inventory Management Service code and push the changes to Git.
136+
- Click on the newly created application. The app should be synchronizing and a graph of kubernetes resources should be shown if everything is configured correctly.
246137
247138
### Repeat for BFF and UI components
248139
249-
Starting from [Configure the GitOps repo for Inventory Management service](#configure-the-gitops-repo-for-inventory-management-service),
250-
the steps need to be repeated for each application within the project.
140+
Manually trigger rerun of BFF and UI pipelines and when it's finished repeat this last step to create applications for BFF and UI.

0 commit comments

Comments
 (0)