-
Notifications
You must be signed in to change notification settings - Fork 39
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
prgavali
wants to merge
4
commits into
develop
Choose a base branch
from
prgavali-guide
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Developer guide #106
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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" | ||
``` |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.