-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
124 changed files
with
8,826 additions
and
1,088 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.md | ||
unit-tests/ | ||
old/ | ||
node_modules/ | ||
client/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# CRAIG in IBM Code Engine | ||
|
||
The default setup of CRAIG in Code Engine pulls the latest CRAIG source, builds a container image, and creates the serverless application. All of this activity is done in a Code Engine project. The default CRAIG Code Engine project looks like this: | ||
|
||
![craig-ce-project](images/craig-ce-project.png) | ||
|
||
## Updating CRAIG | ||
CRAIG is continually being enhanced with new features. To update your CRAIG deployment with the latest CRAIG code level, navigate to the `craig` project's image build. The navigation flow from the [Code Engine project page](https://cloud.ibm.com/codeengine/projects) is: | ||
1. Click on the `craig` project name | ||
2. Click `Image builds` on the left panel | ||
3. Click the `Image build` tab in the main panel | ||
4. Click the `imgbld-craig` build name | ||
|
||
The image build panel looks like this: | ||
![craig-ce-image-build](images/craig-ce-imgbld.png) | ||
|
||
To refresh the container image with the latest code, click the `Submit build` button and then the `Submit build` button on the right nav pop-over. | ||
|
||
This will build a new container image with the latest CRAIG source. The next time the CRAIG application starts after a period of inactivity, it will use the new image. | ||
|
||
### Redeploying the CRAIG instance | ||
The new instance can also be deployed immediately by navigating to the `craig` application panel and clicking the `Redeploy` button. | ||
|
||
The `craig` application panel can be reached from the `craig` project by clicking on the `Applications` left menu item and clicking the on the `craig` application name in the table. The application panel looks like this: | ||
|
||
![craig-application-panel](images/craig-application-panel.png) | ||
|
||
## Advanced source and container image management | ||
The Code Engine image build and application settings can be used to manage the CRAIG source level being built and run. | ||
|
||
* The `Branch name` field on the image build panel can be changed to build a specific CRAIG tag/release or a specific commit level. | ||
* The output tab of the image build panel can be used to change the output container image name and tag. The image name and tag can also be set during image build submission. The container image tags can be changed from `latest` to something else like the CRAIG source image tag or the date the latest `main` branch was pulled and built. | ||
* If different image container names or tags are used, the `Image reference` field on the `craig` application panel must be updated with the new image/tag name and the revision [redeployed](#redeploying-the-craig-instance) to run with the new image. | ||
|
||
## Bring your own Power VS workspace | ||
|
||
### Background | ||
You can bring your own existing Power VS workspace into CRAIG which allows you to choose custom images for Power VSIs. | ||
|
||
The IBM Code Engine deployment script will automatically create Power VS workspaces for CRAIG use when using the `-z` parameter. The script also allows specifying environment variables with the workspace IDs in a file with the `-e` parameter. In both cases the Power VS workspace zones and corresponding workspace IDs are placed in a Code Engine configmap. | ||
|
||
### Modifying the configmap | ||
If you want to bring your own workspace after CRAIG deployment in Code Engine you can update the configmap with the GUID of your workspace. | ||
|
||
To find the GUIDs and locations of your workspaces, the following IBM Cloud CLI command can be run in a terminal window or an IBM Cloud Shell: | ||
|
||
``` | ||
ibmcloud resource service-instances --service-name power-iaas --output json | jq -r '.[]? | "\(.guid), \(.name), \(.region_id)"' | ||
``` | ||
|
||
To modify the configmap to add your workspace GUID, click on `Secrets and configmaps` on left navigation pane of the Code Engine project. Click on the `craig-env` Configmap. Find the key that matches your workspace's zone and set your workspace's GUID as the value for the key. Click the `Save` button. The CRAIG instance can then be [redeployed](#redeploying-the-craig-instance) to pick up the configmap change. | ||
|
||
If CRAIG was deployed without specifying `-z` or `-e`, a configmap can be manually created and set with the correct key-value for the zone. See the [.example.env](../.example.env) for the possible keys and the [IBM Code Engine documentation](https://cloud.ibm.com/docs/codeengine?topic=codeengine-configmap) for how to create the configmap and add the reference to the `craig` application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Setting Up CRAIG Development Environment | ||
|
||
CRAIG is a flexible application that can be used directly from your local environment or containerized and deployed to your platform of choice. | ||
|
||
To run CRAIG in your development environment, follow these steps: | ||
|
||
## 1. Install Dependencies | ||
|
||
To install needed dependencies, use the command | ||
```shell | ||
npm run setup | ||
``` | ||
|
||
## 2. Creating .env file | ||
|
||
Make sure to set the `API_KEY` variable in a `.env` file to be used for IBM Cloud integration. To dynamically fetch Power VS images and storage pools within CRAIG, the IBM Power VS APIs require a workspace to be created and its GUID to be in an environment file. See [Power VS Workspace Deployment](.docs/power-vs-workspace-deployment.md) for more information. | ||
|
||
See `.env.example` found [here](./.env.example) | ||
|
||
## 3. Starting the Back-End Server | ||
|
||
In order to make sure the Back-End API calls are successful, the server needs to be started. To start the server run the following command from the root directory: | ||
|
||
```shell | ||
node server.js | ||
``` | ||
|
||
## 4. Starting the Front-End Application | ||
|
||
CRAIG uses [craco](https://www.npmjs.com/package/@craco/craco) to setup and run the development environment. To start the development build server, run the following command in parallel with [Step 3](#3-starting-the-back-end-server): | ||
|
||
```shell | ||
npm run dev-start | ||
``` | ||
|
||
## 5. Opening the Application | ||
|
||
Congratulations! CRAIG is now running at `localhost:3000` | ||
|
||
## 6. Testing the Development Environment | ||
|
||
CRAIG uses [mocha](https://mochajs.org/) and [chai](https://www.chaijs.com/) for unit testing. To run unit tests use the command: | ||
|
||
```shell | ||
npm run test | ||
``` | ||
|
||
Craig uses [nyc](https://www.npmjs.com/package/nyc) for unit test coverage. To get a report of unit test coverage run the command | ||
|
||
```shell | ||
npm run coverage | ||
``` | ||
|
||
## 7. Install Pre-commit Hook | ||
```shell | ||
git config --local core.hooksPath .githooks/ | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Power VS Workspace Deployment | ||
|
||
To dynamically fetch Power VS images and storage pools within CRAIG, the IBM Power VS APIs require a workspace to be created. CRAIG provides Terraform scripts to automatically provision these workspaces and an environment file that can be used for both IBM Code Engine deployments and local deployments. | ||
|
||
>* _**Note:** this only needs to be done once per IBM Cloud Account, not per user of CRAIG._ | ||
>* _The deploy.sh script used to deploy CRAIG in IBM Code Engine can also automatically deploy the workspaces using its `-z` parameter._ | ||
## Prerequisites | ||
- [Create an IBM Cloud API Key](https://cloud.ibm.com/docs/account?topic=account-userapikey&interface=ui#create_user_key) | ||
- [jq](https://jqlang.github.io/jq/) v1.7 or higher | ||
|
||
|
||
<br /> _Note: If you plan on [deploying CRAIG To IBM Code Engine](../README.md#deploying-to-ibm-code-engine), ensure you are using the same account you intend to use for CRAIG deployment in Code Engine when creating the API key and doing the PowerVS Workspace Deployment setup below._ | ||
|
||
|
||
## Automated Deployment | ||
|
||
The `terraform.sh` script found in the `/deploy` folder of the CRAIG root directory provisions a Power VS Workspace in each zone and sets the needed environment variables with the format of `POWER_WORKSPACE_<zone>=<workspace-guid>`. | ||
|
||
Use the following command to run the script: | ||
```shell | ||
sh deploy/terraform.sh -a "<Your IBM Cloud Platform API key>" | ||
``` | ||
|
||
This will produce a file named `.env` that can be passed to the `deploy.sh` script when deploying CRAIG in Code Engine. | ||
|
||
#### Bring Your Own Workspace | ||
|
||
To bring your own Power VS Workspace into CRAIG to fetch images, you will need to set a field in your `.env` with the following format. To see an example, see [.env.example](../.env.example) | ||
|
||
``` | ||
POWER_WORKSPACE_<zone-of-workspace>=<workspace-guid> | ||
``` | ||
|
||
To find the GUIDs and locations of your workspaces, the following IBM Cloud CLI command can be run in a terminal window or an IBM Cloud Shell: | ||
|
||
``` | ||
ibmcloud resource service-instances --service-name power-iaas --output json | jq -r '.[]? | "\(.guid), \(.name), \(.region_id)"' | ||
``` | ||
|
||
*For instructions on how to install the IBM Cloud CLI, click [here](https://cloud.ibm.com/docs/cli?topic=cli-getting-started)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Running the Terraform Files | ||
|
||
After creating a deployment using the GUI, users can download a file called `craig.zip`. Included in this file are all the Terraform files needed to create your environment. In addition, your environment configuration is saved as `craig.json` and can easily be imported into the GUI for further customization. | ||
|
||
## Prerequisites | ||
|
||
- Terraform v1.3 or higher | ||
- Terraform CLI | ||
- IBM Cloud Platform API Key | ||
|
||
### 1. Initializing the Directory | ||
|
||
After unzipping craig.zip, enter the containing folder from your terminal. In your directory, run the following command to install needed providers and to initialize the directory: | ||
``` | ||
terraform init | ||
``` | ||
|
||
### 2. Adding Environment Variables | ||
|
||
Once your environment has been initialized, add your IBM Cloud Platform API key to the environment. This can be done by exporting your API key as an environment variable. Once that's complete, run the following command to plan your terraform directory. | ||
|
||
``` | ||
terraform plan | ||
``` | ||
|
||
### 3. Creating Resources | ||
|
||
Resources can be created from the directory by running the Terraform Apply command after a successful plan | ||
|
||
``` | ||
terraform apply | ||
``` | ||
|
||
### 4. Destroying Resources | ||
|
||
To destroy your resources, use the following command. This will **delete all resources** provisioned by the template. | ||
|
||
``` | ||
terraform destroy | ||
``` |
Oops, something went wrong.