Skip to content

Commit

Permalink
Updated inv-app docs (#262)
Browse files Browse the repository at this point in the history
* Updated inv-app docs

Signed-off-by: Noé Samaille <noe.samaille@ibm.com>

* Fix spellchecks

Signed-off-by: Noé Samaille <noe.samaille@ibm.com>

Signed-off-by: Noé Samaille <noe.samaille@ibm.com>
  • Loading branch information
NoeSamaille authored Aug 23, 2022
1 parent c80286d commit 9c4b839
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 213 deletions.
26 changes: 13 additions & 13 deletions docs/developer-advanced-1/inventory-cd/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ To create a project, do the following:
### Configure the GitOps repo for Inventory Management service
- 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
(e.g. `inventory-management-svc-{initials}`)
(e.g. `inv-svc-{initials}`)
- Update `inventory-management-svc-{initials}/Chart.yaml` and update the name to match the directory name
- Update `inv-svc-{initials}/Chart.yaml` and update the name to match the directory name
- Update `inventory-management-svc-{initials}/requirements.yaml` with the following values:
- Update `inv-svc-{initials}/requirements.yaml` with the following values:
- `name` - the name of helm chart/image. This should match the folder name
- `version` - the version number of the helm chart
Expand All @@ -119,7 +119,7 @@ To create a project, do the following:
- here is an example
```yaml
dependencies:
- name: inventory-management-svc-mjp
- name: inv-svc-mjp
version: 1.0.0-1
repository: http://artifactory.mooc-one-rhos-cluster.us-east.containers.appdomain.cloud/artifactory/generic-local/mooc-team-one/
```
Expand All @@ -132,13 +132,13 @@ To create a project, do the following:
- Run `kubectl get configmap/ibmcloud-config -n tools -o yaml` to print the configuration information
for the cluster
- In `inventory-management-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
```yaml title="inventory-management-svc-{initials}/values.yaml"
- 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
```yaml title="inv-svc-{initials}/values.yaml"
global:
ingressSubdomain: sms-test.us-south.containers.appdomain.cloud
tlsSecretName: sms-test-cluster
inventory-management-svc-{initials}:
inv-svc-{initials}:
replicaCount: 1
ingress:
Expand All @@ -149,7 +149,7 @@ for the cluster
- Commit and push the changes
```bash
git add .
git commit -m "Adds inventory-management-svc config"
git commit -m "Adds inv-svc config"
git push
```
Expand All @@ -162,12 +162,12 @@ connecting the config within the Git repo to the cluster and namespace.
- Click `New Application` and provide the following values:
- `application name` - `test-inventory-management-svc`
- `application name` - `test-inv-svc`
- `project` - `inventory-management`
- `sync-policy` - `Automatic`
- `repository url` - The url of the GitOps repository you created earlier
- `revision` - `test`
- `path` - `inventory-management-svc-{initials}`
- `path` - `inv-svc-{initials}`
- `destination cluster` - The cluster url for the deployment
- `destination namespace` - `test-{initials}`
- `values file` - `values.yaml`
Expand All @@ -189,13 +189,13 @@ watch ArgoCD apply the change.
git checkout test
```
- Update `inventory-management-svc-{initials}/values.yaml` to increase the replica count
```yaml title="inventory-management-svc-{initials}/values.yaml"
- Update `inv-svc-{initials}/values.yaml` to increase the replica count
```yaml title="inv-svc-{initials}/values.yaml"
global:
ingressSubdomain: sms-test.us-south.containers.appdomain.cloud
tlsSecretName: sms-test-cluster
inventory-management-svc-{initials}:
inv-svc-{initials}:
replicaCount: 3
ingress:
Expand Down
149 changes: 63 additions & 86 deletions docs/developer-intermediate/inventory-bff/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--- cSpell:ignore templatized ICPA openshiftconsole Theia userid toolset crwexposeservice gradlew bluemix ocinstall Mico crwopenlink crwopenapp swaggerui gitpat gituser buildconfig yourproject wireframe devenvsetup viewapp crwopenlink atemplatized rtifactoryurlsetup Kata Koda configmap Katacoda checksetup cndp katacoda checksetup Linespace igccli regcred REPLACEME Tavis pipelinerun openshiftcluster invokecloudshell cloudnative sampleapp bwoolf hotspots multicloud pipelinerun Sricharan taskrun Vadapalli Rossel REPLACEME cloudnativesampleapp artifactoryuntar untar Hotspot devtoolsservices Piyum Zonooz Farr Kamal Arora Laszewski Roadmap roadmap Istio Packt buildpacks automatable ksonnet jsonnet targetport podsiks SIGTERM SIGKILL minikube apiserver multitenant kubelet multizone Burstable checksetup handson stockbffnode codepatterns devenvsetup newwindow preconfigured cloudantcredentials apikey Indexyaml classname errorcondition tektonpipeline gradlew gitsecret viewapp cloudantgitpodscreen crwopenlink cdply crwopenapp -->
<!--- cSpell:ignore templatized ICPA openshiftconsole Theia userid toolset crwexposeservice gradlew bluemix ocinstall Mico crwopenlink crwopenapp swaggerui gitpat gituser buildconfig yourproject wireframe devenvsetup viewapp crwopenlink atemplatized rtifactoryurlsetup Kata Koda configmap Katacoda checksetup cndp katacoda checksetup Linespace igccli regcred REPLACEME Tavis pipelinerun openshiftcluster invokecloudshell cloudnative sampleapp bwoolf hotspots multicloud pipelinerun Sricharan taskrun Vadapalli Rossel REPLACEME cloudnativesampleapp artifactoryuntar untar Hotspot devtoolsservices Piyum Zonooz Farr Kamal Arora Laszewski Roadmap roadmap Istio Packt buildpacks automatable ksonnet jsonnet targetport podsiks SIGTERM SIGKILL minikube apiserver multitenant kubelet multizone Burstable checksetup handson stockbffnode codepatterns devenvsetup newwindow preconfigured cloudantcredentials apikey Indexyaml classname errorcondition tektonpipeline gradlew gitsecret viewapp cloudantgitpodscreen crwopenlink cdply crwopenapp desktoplaptop -->
**Develop and deploy the BFF component of the inventory application**

The Inventory BFF's role in the architecture is to act as an orchestrator between the core business services and the specific digital channel it is focused on supporting. This class article will give you more detail about the [Backend For Frontend architectural pattern](https://samnewman.io/patterns/architectural/bff/) and the benefits.
Expand All @@ -11,116 +11,93 @@ The Inventory solution will use [GraphQL](https://graphql.org/) for its BFF laye

## Setup

### [Optional]: Access cloud shell
### Create your OpenShift project and register the pipeline

If you don't plan to use your workstation to run this lab, you can use IBM Cloud Shell:
- Create a new repository from the [Typescript GraphQL template](https://github.com/IBM/template-graphql-typescript/generate).

- Open the IBM Cloud console (cloud.ibm.com) in your browser and log in if needed.
!!! warning
If you are developing on a shared education cluster, place the repository in the **Git Organization** listed in your notification email and remember to add your initials as a suffix to the app name.
- In order to prevent naming collisions, name the repository `inv-bff-{your initials}` replacing `{your initials}` with your actual initials.

- Invoke Cloud Shell by clicking on the button at the top, right-hand corner of the browser window.
- Deploy this application with Tekton pipelines :

![Invoke Cloud Shell](../../images/common/invokecloudshell.png)
=== "Using OpenShift web terminal"
- In the OpenShift web console, head up to **Topology** menu on the left on the **Developer** perspective and click **Create a new project**.

### Setup your shell environment
- Give a name to your project, call it `dev-{your initials}`, the other fields are optional.

We have provided a simplified installer that will install tools and configure the shell environment. The
installer will first check if the required tool is available in the path. If not, the missing tool(s) will be
installed into the `bin/` folder of the current user's home directory and the `PATH` variable will be updated in the
`.bashrc` or `.zshrc` file to include that directory.
- Initialize a web terminal using the `>_` button on the top bar next to your name on the cluster. You should have a terminal with all the necessary development tools.

The following tools are included in the shell installer:
=== "Using your local terminal"
!!! note
You should have the `oc` and `igc` command line tools installed. If not, refer to the [developers tools setup page](/getting-started/devenvsetup/#tools-installation-on-desktoplaptop).

- In the OpenShift web console, click on email address top right, click on **Copy login command** and get the OpenShift login command, which includes a token.

- Click on **Display Token**, copy the Login with the token. oc login command will log you in. Run the login command in the cloud shell terminal:

```bash
$ oc login --token=qvARHflZDlOYfjJZRJUEs53Yfy4F8aa6_L3ezoagQFM --server=https://c103-e.us-south.containers.cloud.ibm.com:30979
Logged into "https://c103-e.us-south.containers.cloud.ibm.com:30979" as "IAM#email@company" using the token provided.

You have access to 71 projects, the list has been suppressed. You can list all projects with 'oc projects'
```

- IBM Cloud cli (ibmcloud)
- ArgoCD cli (argocd)
- Tekton cli (tkn)
- IBM Cloud fast switching (icc)
- kube-ps1 prompt
- OpenShift cli (oc)
- Kubernetes cli (kubectl)
- JSON cli (jq)
- IBM Garage Cloud CLI (igc)
- Clone the repository you created earlier

1. Set up the shell environment by running:
```shell
curl -sL shell.cloudnativetoolkit.dev | sh -
```
- **Note**: If successful, you should see something like the following:
```shell
Downloading scripts: https://github.com/cloud-native-toolkit/cloud-shell-commands/releases/download/0.6.1/assets.tar.gz
** Installing argocd cli
** Installing tkn cli
** Installing kube-ps1
** Installing icc
** Installing Cloud-Native Toolkit cli
```
2. The installer updates PATH in the `.zshrc` or `.bashrc` file. You will need to source the file to apply the update to the current shell environment:
```shell
if [[ "${SHELL}" =~ zsh ]]; then
source ~/.zshrc
else
source ~/.bashrc
fi
git clone https://github.com/cnw-team-{team}/inv-bff-{your initials}.git
```
3. You can check the shell was installed correctly by checking the `oc` version:
```shell
oc sync --version
```

### Log in to OpenShift Cluster
- Run the command

- Log in to OpenShift Cluster from the cloud console. Go to Resource listStockItems and click on the cluster:

![OpenShift](../../images/common/openshiftcluster.png)

- Access the OpenShift console from within that console by clicking on the button.

![OpenShift Console](../../images/common/openshiftconsole.png)

- In OpenShift Console, click on email address top right, Click on Copy Login Command and get the OpenShift login command, which includes a token.

![OpenShift Login](../../images/common/LoginCommand.png)
```
oc sync dev-{your initials}
```

- click on **_Display Token_**, copy the Login with the token. `oc login` command will log you in. Run the login command in the cloud shell terminal:
```bash
$ oc login --token=qvARHflZDlOYfjJZRJUEs53Yfy4F8aa6_L3ezoagQFM --server=https://c103-e.us-south.containers.cloud.ibm.com:30979
Logged into "https://c103-e.us-south.containers.cloud.ibm.com:30979" as "IAM#email@company" using the token provided.
- Go to the directory of the repository your cloned and [Register the pipeline](/developer-intermediate/deploy-app#5-register-the-application-in-a-openshift-pipeline)

You have access to 71 projects, the list has been suppressed. You can list all projects with 'oc projects'
```
oc pipeline --tekton
```

Using project "dev-ab".
```
- Give git credentials if prompted, and master as the git branch to use. When prompted for the pipeline, select `ibm-nodejs`

### Setup code base
```bash
$ oc pipeline --tekton
...

To get the initial BFF project created and registered with a pipeline for automated builds follow these steps.
Pipeline run started: inv-bff-ns-181f77c24a4
```

- Create a new repository from the [Typescript GraphQL template](https://github.com/IBM/template-graphql-typescript/generate).
- [Open the pipeline](/developer-intermediate/deploy-app/#5-register-the-application-in-a-openshift-pipeline) to see it running

!!! warning
If you are developing on a shared education cluster, place the repository in the **Git Organization** listed in your notification email and remember to add your initials as a suffix to the app name.
- In order to prevent naming collisions, name the repository `inventory-management-bff-{your initials}` replacing `{your initials}` with your actual initials.
- When the pipeline is completed, run `oc endpoints -n dev-{your initials}`. You should see an entry for the app we just pushed. Select the entry and hit `Enter` to launch the browser.

- Clone the new repository to your machine.
### Choose your development environment

- Run `npm install` to install all the package dependencies.
=== "Gitpod"
- Head over to [gitpod.io](https://gitpod.io), login with your github account by clicking **Continue with GitHub**.

- Grant access to gitpod to your GitHub organization by going to account settings on the top right corner, navigate to **Integrations**, go to GitHub and click **Manage on GitHub**.

- On GitHub, search the organization you have used to create the repository and click **grant** to allow gitpod to access repositories in that organization.

- Back to [gitpod.io](https://gitpod.io/workspaces), navigate to workspaces and click **New Workspace** to create a new workspace, give it your newly create repository URL.

- If it is your first gitpod workspace, it will ask you for your preferred editor, pick the in browser Visual Studio Code, and the workspace will be created automatically for your.

You are now ready to modify the application!

- Go into the repository directory cloned and execute the following:
=== "Locally"
Clone the project and open it using your favorite text editor or IDE (Visual Studio Code, Atom...).

```
oc sync dev-{your initials}
```
```sh

- Register the pipeline:
```
oc pipeline --tekton
git clone https://github.com/cnw-team-{team}/inv-bff-{your initials}.git
cd inv-bff-{your initials}
code .
```
- replacing `{your initials}` with your actual initials
- Give git credentials if prompted, and master as the git branch to use. When prompted for the pipeline, select `igc-nodejs-<VERSION>`.

- Open the pipeline to see it running, using the link provided in the command output.

- When the pipeline is completed, run `oc endpoints -n dev-{your initials}`. You should see an entry for the app we just pushed. Select the entry and hit `Enter` to launch the browser, if you are working on your desktop/laptop. Otherwise copy the url and paste it in a new browser tab.

## Create the REST interface

The controller provides the REST interface for our BFF. The template uses the `typescript-rest`
Expand Down Expand Up @@ -655,7 +632,7 @@ The config class separates how the config is loaded from how it is used. In this
```yaml title="chart/base/values.yaml"
...
connectsTo: inventory-management-svc-{your initials}
connectsTo: inv-svc-{your initials}
...
```
Expand Down
14 changes: 7 additions & 7 deletions docs/developer-intermediate/inventory-prebuilt-solution/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ In some cases with self pace hands on labs you may not get everything working. C
### Inventory Service

- Create a new project from the [Inventory Management Service solution template](https://github.com/ibm-ecosystem-lab/inventory-management-svc-intermediate/generate)
named `inv-man-svc-sol-{initials}`
- Replacing `{initials}` with your actual initials
named `inv-svc-solution-{initials}`
- replacing `{initials}` with your actual initials

- Clone the repository to your local machine

Expand All @@ -37,8 +37,8 @@ named `inv-man-svc-sol-{initials}`
### Inventory BFF
- Create a new project from the [Inventory Management BFF solution template](https://github.com/ibm-ecosystem-lab/inventory-bff-prebuild/generate)
named `inventory-management-bff-solution-{initials}`
- Replacing `{initials}` with your actual initials
named `inv-bff-solution-{initials}`
- replacing `{initials}` with your actual initials
- Go into the cloned repository directory and execute the following, if you have not executed it previously:
Expand All @@ -56,7 +56,7 @@ named `inventory-management-bff-solution-{initials}`
- Open the [pipeline to see it running](/developer-intermediate/deploy-app/#6-view-your-application-pipeline)
- Get the backend service name this value by executing the command `oc get svc -n dev-{initials}.
- Get the backend service name this value by executing the command `oc get svc -n dev-{initials}`.
```
$ oc get svc -n dev-ar
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
Expand All @@ -78,8 +78,8 @@ service of the microservice: `connectsTo: inventory-svc-ar`
### Inventory UI
- Create a new project from the [Inventory Management UI solution template](https://github.com/ibm-ecosystem-lab/inventory-ui-prebuild/generate)
named `inventory-management-ui-solution-{initials}`
- Replacing `{initials}` with your actual initials
named `inv-ui-solution-{initials}`
- replacing `{initials}` with your actual initials
- Clone the repository to your local machine
Expand Down
Loading

0 comments on commit 9c4b839

Please sign in to comment.