Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer guide #106

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions DEPLOYMENT_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# Development of deployment template
The deployment template is created in `deployment.yaml` file as per the directory structure mentioned [here](README.md#filedirectory-reference)
This file defines the template that contain the configuration of storage solution in YAML format. It is Kubernetes `List` that includes the resources like Deployment, StatefulSet, DaemonSet, Configmap, secrets. When user creates the configuration from this template , this file will be embedded inside [`MustacheTemplate`](https://mustache.github.io/mustache.5.html). The `MustacheTemplate` is the template evaluation engine that is used to translate the template into final configuration file using the custom parameters and secret parameters passed by the user. So, it is advised to follow the `MustacheTemplate` syntax [`here`](https://mustache.github.io/mustache.5.html). The existing example of `deployment.yaml` is found [here](config-templates/redhat/ocs-local/4.6/deployment.yaml)


## Configuration of Single Valued variable
This is simple variable with single value of type `text` , `boolean` or `number`. In the following example , `num-of-osd` , `ocs-upgrade` and `billing-type` are the single valued variables.

__Template YAML__
```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: {{ ocs-cluster-name }}
namespace: default
spec:
monStorageClassName: localfile
monSize: "1"
osdStorageClassName: localblock
osdSize: "1"
numOfOsd: {{ num-of-osd }}
billingType: "{{ billing-type }}"

```

__User Parameteter__

ocs-cluster-name=mycluster
num-of-osd=2
billing-type=hurly


__Translated YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: mycluster
namespace: default
spec:
monStorageClassName: localfile
monSize: "1"
osdStorageClassName: localblock
osdSize: "1"
numOfOsd: 2
billingType: "hourly"

```

## Configuration of Multi Valued/List/Array/Csv variable

If the type of the customer parameter is `csv` (Comma Separated Values), its considered as multi-valued variable. In the below example, `mon-device-path` is the multi-valued variable. e.g `mon-device-path=/dev/sdc1,/dev/sdc1`

__Template YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: {{ ocs-cluster-name }}
namespace: default
spec:
monStorageClassName: localfile
monSize: "1"
osdStorageClassName: localblock
osdSize: "1"
monDevicePaths:
{{#mon-device-path }}
- "{{{ item }}}"
{{/mon-device-path }}
```
__Custom Parameters__

mon-device-path=/dev/sdc1,/dev/sdc1
ocs-cluster-name=mycluster

__Translated YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: mycluster
namespace: default
spec:
monStorageClassName: localfile
monSize: "1"
osdStorageClassName: localblock
osdSize: "1"
monDevicePaths:
- /dev/sdc1
- /dev/sdc2
```

## Configuration for optional/empty/false variable
The optional user parameter may not be given by the user while creating the configuration. These variables will result into undefined or empty valued variables. If the variable is not defined or empty, its evaluated to empty string , that could break the YAML syntax. Hence it is advised to added `emptyness/undfined` check in the template as below.

### Single value empty parameter
If the parameter type is `text` , `number` or `boolean` i.e not CSV (multi-valued), we use the `parameter name` in the condition as below
__syntax__
```
{{#paramater-name}}
yaml-tag
{{/paramater-name}}
```

The `yaml-tag` will be rendered only when parameter is not `empty` or `false`

In this example, `monSize` is optional variable of `number` type. Hence, the tag `monSize:` is enclosed inside `{{#monSize}}`.

__Template YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: {{ ocs-cluster-name }}
namespace: default
spec:
monStorageClassName: localfile
{{#monSize}}
monSize: {{monSize}}
{{/monSize}}`
osdStorageClassName: localblock
osdSize: "1"
```
__Custom Parameters__

ocs-cluster-name=mycluster

__Translated YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: mycluster
namespace: default
spec:
monStorageClassName: localfile
osdStorageClassName: localblock
osdSize: "1"
```

### CSV type empty value parameter
If the parameter tye is CSV (multi-valued), we use the `parameter name` followed by `?` in the condition as below
__syntax__
```
{{#paramater-name?}}
yaml-tag
{{/paramater-name?}}
```

The `yaml-tag` will be rendered only when parameter is not empty

In this example, `mon-device-path` is optional variable of `csv` type. Hence, the list tag `monDevicePaths:` is enclosed inside `{{#mon-device-path?}}`.

__Template YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: {{ ocs-cluster-name }}
namespace: default
spec:
monStorageClassName: localfile
monSize: "1"
osdStorageClassName: localblock
osdSize: "1"
{{#mon-device-path?}}
monDevicePaths:
{{#mon-device-path?}}
{{#mon-device-path }}
- "{{{ item }}}"
{{/mon-device-path }}
```
__Custom Parameters__

ocs-cluster-name=mycluster

__Translated YAML__

```
- apiVersion: ocs.ibm.io/v1
kind: OcsCluster
metadata:
name: mycluster
namespace: default
spec:
monStorageClassName: localfile
monSize: "1"
osdStorageClassName: localblock
osdSize: "1"
```
124 changes: 74 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,56 +109,80 @@ With IBM Cloud Satellite, you can bring your own compute infrastructure that is
---README.md
```

### File reference

| File name | Description |
| --- | --- |
| `storage-provider-name` | The name of storage provider. Example: `ibm`, `aws`, `azure`, `netapp`, `dell`. |
| `storage-offering-name` | The storage offering name. A provider can have multiple storage offerings for IBM satallite. |
| `template-version` | The template version. There can be multiple tempalte version for a storage offering |
| `deployment.yaml` | A custom Kubernetes `List` that includes the resources like Deployment, StatefulSet, DaemonSet, Configmap, secrets, and storage classes. Example [`deployment.yaml`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/deployment.yaml). |
| `custom-parameters.json` | This file contains the list of parameters that your deployment accepts. Include any required and optional paramters and their default values. Example [`customer-paramerters.json`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/custom-parameters.json). |
| `storage-class-template.yaml` | The storage class template. This template can be used to create storage classes on a Satellite cluster. Example [`storage-class-template.yaml`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/storage-class-template.yaml). |
| `storage-class-parameters.json` | The list of storage class parameters. User / admin can override the values from GUI. The parameter values are injected in storage class template to generate the storage class specifications to deploy on the target clusters. [`storage-class-parameters.json`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/storage-class-parameters.json) |
| `README.md` | Contains prerequisites, deployment steps, and additional information about your template. Copy and fill out the [README_TEMPLATE.md](/.github/README_TEMPLATE.md). |
| `metadata.json` | This file contains the metadata for GUI display. Example [`metadata.json`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/metadata.json). |


### Setting dynamic parameters in your deployment

In this example, the `devicepath` parameter is set dynamically. In a local storage configuration, the device path of the local disks might vary from one cluster to another. To account for this in your configuration template, you can create a dynamic parameter.

1. Parameterize the device path in the template `deployment.yaml` file in the following format. The parameter name `devicepath` is passed in the format: `"{{ <parameter-name> }}"`
```yaml
storageClassDevices:
- storageClassName: "localblock-sc"
volumeMode: Block
devicePaths:
- "{{ devicepath }}"
```

2. Add the parameter to your `custom-parameters.json` file in the following format. You can also include a default value for the parameter.
```json
{
"description": "A description of the parameter.",
"displayname": "The display name for the Satellite UI",
"name": "devicepath",
"default": "/dev/sdc",
"required": true,
"type": "text"
}
```

#### Custom parameter reference
| Parameter name | Description |
| --- | --- |
| `description` | A description of the parameter. |
| `displayname` | The display name of the parameter that is used in the Satellite UI. |
| `name` | The name of the parameter in string format. |
| `default` | Optional. The default value for the parameter. If the does not specify the parameter in their configuration, this value entered as `default` is used. |
| `required` | Specify `true` or `false`. |
| `type` | Specify the parameter type. Valid parameter types are: `text`, `secret`, `boolean`, `option`, or `dropdown`. |

### File/Directory reference

| File name | Description | Type(Dir/File) | Required(Yes/No)
| --- | --- | --- | --- |
| `storage-provider-name` | The name of storage provider. Example: `ibm`, `aws`, `azure`, `netapp`, `dell`. | Dir | Yes |
| `storage-offering-name` | The storage offering name. A provider can have multiple storage offerings for IBM satellite. |Dir | Yes |
| `template-version` | The template version. There can be multiple template version for a storage offering |Dir | Yes |
| `deployment.yaml` | A custom Kubernetes `List` that includes the resources like Deployment, StatefulSet, DaemonSet, Configmap, secrets, and storage classes. Example [`deployment.yaml`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/deployment.yaml). |File | Yes |
| `custom-parameters.json` | This file contains the list of parameters that your deployment accepts. Include any required and optional paramters and their default values. Example [`customer-paramerters.json`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/custom-parameters.json). This file is optional and if not provided then no customer parameter or secret parameter are accepted while creating the configuration from this template.|File | No |
| `storage-class.yaml` | The list of vendor provided storage classes. Example [`storage-class.yaml`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-ontap-san/20.07/storage-class.yaml). |File | No |
| `storage-class-template.yaml` | The storage class template. This template allows user create additioal storage classes on a Satellite cluster. The additional storage classes are created from the parameters mentioned in `storage-class-parameters.json` Example [`storage-class-template.yaml`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/storage-class-template.yaml). |File | No |
| `storage-class-parameters.json` | The list of storage class parameters. User / admin can override the values from GUI. The parameter values are injected in storage class template to generate the storage class specifications to deploy on the target clusters. [`storage-class-parameters.json`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/storage-class-parameters.json) |File | No |
| `README.md` | Contains prerequisites, deployment steps, and additional information about your template. Copy and fill out the [README_TEMPLATE.md](/.github/README_TEMPLATE.md). |File | No |
| `metadata.json` | This file contains the metadata for GUI display. Example [`metadata.json`](https://github.com/IBM/ibm-satellite-storage/blob/master/config-templates/netapp/netapp-trident/20.07/metadata.json). |File | No |


### Defining Custom parameter reference
The customer parameter has following attributes
| Attribute name | Description | Required | Default|
| --- | --- | ---| --- |
| `description` | A description of the parameter. | Yes| |
| `displayname` | The display name of the parameter that is used in the Satellite UI. |Yes |
| `name` | The name of the parameter in string format. | Yes |
| `default` | Optional. The default value for the parameter. If the does not specify the parameter in their configuration, this value entered as `default` is used. | No | Empty String|
| `type` | Specify the parameter type. Valid parameter types are: `text`, `csv`, `number`, `boolean` | No | `text`|
| `catagory` | Specify the parameter category `config` or `secret`. On UI , the `config` parameters will display in `User Config Parameter` section and `secret` parameters will dislay in `User secrete paramater` section | No | `config`|
| `required` | Specify `true` or `false`. | No | `false`|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be better to mention that when the default value for parameter is set, then set required to false.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with this. In the UI, if they have a default value they can still delete it. If they delete it and its "supposed" to be required but follows this pattern, they could have an issue without realizing.

| `regex` | Specify the regular expression to validate the user input. For example `"^[0-9]+Gi$"` will validate a string like `50Gi`| No | No RegEx Validation|
| `place-holder` | The example text that will be shown to user as a place-holder in text box . For example `50Gi` indicates the format of allowed text | No | empty string|
| `min-length` | Minimum allowed a length of input value | No | 1 if `required` is `true`|
| `max-length` | Maximum allowed a length of input value | No | no limit|

The customer parameters are defined in `custom-parameters.json` file in the following format.

```
[
{
"description": "Maximum requestable volume size and qtree parent volume size",
"displayname": "Limit Volume Size",
"name": "limitVolumeSize",
"default": "50Gi",
"place-holder":"50Gi",
"regex": "^[0-9]+Gi$",
"required": "false",
"category": "config"
}, {
"description": "Fail provisioning if usage is above this percentage.",
"displayname": "Limit AggregateUsage",
"name": "limitAggregateUsage",
"default": "80%",
"place-holder":"80%",
"regex": "^[0-9]+%$",
"required": "false",
"category": "config"
}, {
"description": "The NFS mount options.",
"displayname": "NFS Mount Options",
"name": "nfsMountOptions",
"default": "nfsvers=4",
"place-holder":"nfsvers=4",
"regex": "^(nfsvers=){1}[0-9.]+$",
"required": "false",
"category": "config"
}
]
```

The complete example can be found [here](config-templates/netapp/netapp-ontap-nas/20.07/custom-parameters.json)

### Developing `deployment.yaml` file
The complete guide to develop `deployment.yaml` is found [here](DEPLOYMENT_README.md)

### Developing storage class template
The complete guide to storage class template is found [here](STORAGE_CLASS_README.md)

## Testing and support

Expand Down
Loading