|
| 1 | +## Target Environments |
| 2 | + |
| 3 | +The [Discover Domain](../discover.md) and [Prepare Model](../prepare.md) Tools allow you to customize the model and other files produced to be compatible with a specific target environment. Options for a target environment may include: |
| 4 | +- Using model tokens for some attributes in the model (see [Model Tokens](../../README.md#model-tokens)) |
| 5 | +- Using Kubernetes secrets for credentials in the model |
| 6 | +- Applying filters to the model (see [Model Filters](../tool_filters.md)) |
| 7 | +- Creating additional configuration files for the target system |
| 8 | + |
| 9 | +### Specifying a Target Environment |
| 10 | + |
| 11 | +Each tool specifies a target environment using the command-line argument `-target <target-name>`, where `<target-name>` refers to a pre-configured target environment, or a user-defined environment. In addition, the `-output_dir <output-directory>` argument specifies where the files for the target environment will be stored. |
| 12 | + |
| 13 | +This command line shows how these arguments can be used with the Discover Domain Tool: |
| 14 | +```yaml |
| 15 | + $WLSDEPLOY_HOME/bin/discoverDomain.sh ... -target k8s -output_dir /etc/files |
| 16 | +``` |
| 17 | +This example would apply the `k8s` target type to the discovery result, and place those files in `/etc/files`. |
| 18 | + |
| 19 | +If a variable file is specified on the tool's command line using the `-variable_file` argument, any injected variables will be added to that file. If no variable file is specified, injected variables will be written to the file `<output-directory>/<target_name>_variable.properties`. |
| 20 | + |
| 21 | +### The Target Configuration File |
| 22 | + |
| 23 | +A target environment is configured in a JSON file at this location: |
| 24 | +``` |
| 25 | +$WLSDEPLOY_HOME/lib/target/<target-name>/target.json |
| 26 | +``` |
| 27 | +The `<target-name>` value corresponds to the value of the `-target` argument on the tool's command line. The WLS installation includes two pre-defined targets: |
| 28 | + - [Oracle Weblogic Server Kubernetes Operator](#the-oracle-weblogic-server-kubernetes-operator-target) (named `k8s`) |
| 29 | + - [Verrazzano](#the-verrazzano-target) (named `vz`). |
| 30 | + |
| 31 | +You can define a new or extended target environment with a new `target-name` in the above location, or using a [Custom Configuration](custom_configuration.md) directory, such as `$WDT_CUSTOM_CONFIG/target/<my-target-name>/target.json`. |
| 32 | + |
| 33 | +Here is an example of a target environment file: |
| 34 | +``` |
| 35 | +{ |
| 36 | + "model_filters" : { |
| 37 | + "discover": [ |
| 38 | + { "name": "k8s_prep", "path": "@@TARGET_CONFIG_DIR@@/k8s_operator_filter.py" } |
| 39 | + ] |
| 40 | + }, |
| 41 | + "variable_injectors" : {"PORT": {},"HOST": {},"URL": {}}, |
| 42 | + "validation_method" : "lax", |
| 43 | + "credentials_method" : "secrets", |
| 44 | + "additional_output" : "vz" |
| 45 | +} |
| 46 | +``` |
| 47 | +Each of the fields in this example is optional, and can be customized. |
| 48 | + |
| 49 | +#### `model_filters` |
| 50 | + |
| 51 | +This field specifies the filters to be applied to the resulting model. This follows the same format and rules as the [Model Filters](../tool_filters.md) configuration. The `discover` type should always be used here. |
| 52 | + |
| 53 | +The `@@TARGET_CONFIG_DIR@@` token can be used to indicate that the specified filter is in the same directory as the target configuration file. |
| 54 | + |
| 55 | +#### `variable_injectors` |
| 56 | + |
| 57 | +This field specifies the variable injectors to be applied to the resulting model. This follows the same format and rules as the [Variable Injectors](../variable_injection.md) configuration. |
| 58 | + |
| 59 | +#### `validation_method` |
| 60 | + |
| 61 | +This field can be used to set the validation level for the resulting model. Only the value `lax`is currently supported. With `lax` validation, variables and Kubernetes secrets referenced in the resulting model do not need to be available when the model is created. |
| 62 | + |
| 63 | +#### `credentials_method` |
| 64 | + |
| 65 | +This field specifies how credentials in the model should be handled. There are two values available: |
| 66 | +- `secrets` - the credentials in the model are replaced with references to Kubernetes secrets, and a UNIX script to create those secrets is produced. |
| 67 | +- `config_override_secrets` - the credentials in the model are replaced with placeholder values, such as `password1`, and a UNIX script to create corresponding Kubernetes secrets is produced. |
| 68 | + |
| 69 | +In both these cases, the script to create the Kubernetes secrets is written to `<output-directory>/create_k8s_secrets.sh`. You will need to update this script with credential values before executing |
| 70 | + |
| 71 | +#### `additional_output` |
| 72 | + |
| 73 | +This field can be used to create additional output for use in the target environment. The key `vz` is currently the only valid value for this field. It indicates that the tool should create additional Kubernetes resource files for use with the Verrazzano product. |
| 74 | + |
| 75 | +### Pre-configured Target Environments |
| 76 | + |
| 77 | +These target environment configurations are included in the WebLogic Deploy Tooling installation. |
| 78 | + |
| 79 | +#### The Oracle Weblogic Server Kubernetes Operator Target |
| 80 | + |
| 81 | +This target environment can be applied by providing the command-line argument `-target k8s`. It will provide this additional processing: |
| 82 | + |
| 83 | +- The `k8s_operator_filter.py` filter will be applied to remove model elements that are not compatible with the Kubernetes environment |
| 84 | +- Variables will be injected into the model for port, host, and URL attributes |
| 85 | +- `lax` validation will be applied for the resulting model |
| 86 | +- Credentials in the model will be replaced with references to Kubernetes secrets, and a script to create those secrets will be produced |
| 87 | + |
| 88 | +#### The Verrazzano Target |
| 89 | +This target environment can be applied by providing the command-line argument `-target vz`. It will provide this additional processing: |
| 90 | + |
| 91 | +- The `vz_filter.py` filter will be applied to remove model elements that are not compatible with the Kubernetes environment |
| 92 | +- Variables will be injected into the model for port, host, and URL attributes |
| 93 | +- `lax` validation will be applied for the resulting model |
| 94 | +- Credentials in the model will be replaced with placeholder values, and a script to create corresponding secrets will be produced |
| 95 | +- Two additional Kubernetes resource files, `model.yaml` and `binding.yaml`, will be produced, with cluster and data source information derived from the model |
0 commit comments