|
| 1 | +## Configuring Oracle WebLogic Server Kubernetes Operator |
| 2 | + |
| 3 | +The Extract Domain Resource Tool can be used to create a domain resource file for use with the Oracle WebLogic Server Kubernetes Operator. This allows the domain configuration and the Kubernetes container configuration to be specified in a single model file. |
| 4 | + |
| 5 | +This is especially useful when making configuration changes to the domain that also need to be reflected in the domain resource file. For example, adding a cluster to the domain only requires that it be added to the `topology` section of the WDT model, then a new domain resource file can be generated to apply to Kubernetes. |
| 6 | + |
| 7 | +More information about the Oracle WebLogic Server Kubernetes Operator can be found [here](https://oracle.github.io/weblogic-kubernetes-operator). |
| 8 | + |
| 9 | +NOTE: The Extract Domain Resource Tool is available with WDT releases 1.7.0 and later. |
| 10 | + |
| 11 | +Here is an example command line for the Extract Domain Resource Tool: |
| 12 | +``` |
| 13 | +<wls-deploy-home>/bin/extractDomainResource.sh -oracle_home /tmp/oracle -domain_home /u01/mydomain -model_file /tmp/mymodel.yaml -variable_file /tmp/my.properties -domain_resource_file /tmp/operator/domain-resource.yaml |
| 14 | +``` |
| 15 | + |
| 16 | +For the simplest case, the Extract Domain Resource Tool will create a sparse domain file. This is what is generated when there is not a `kubernetes` section in the model, or that section is empty. |
| 17 | +```yaml |
| 18 | +apiVersion: weblogic.oracle/v6 |
| 19 | +kind: Domain |
| 20 | +metadata: |
| 21 | + name: DemoDomain |
| 22 | +spec: |
| 23 | + domainHome: /u01/mydomain |
| 24 | + image: '--FIX ME--' |
| 25 | + imagePullSecrets: |
| 26 | + - name: '--FIX ME--' |
| 27 | + webLogicCredentialsSecret: '--FIX ME--' |
| 28 | + clusters: |
| 29 | + - clusterName: mycluster |
| 30 | + replicas: 2 |
| 31 | + - clusterName: mycluster3 |
| 32 | + replicas: 4 |
| 33 | +``` |
| 34 | +
|
| 35 | +In this example, the value for `domainHome` was set as an input parameter to the extractDomainResource script from the command line. The `kind` and `name` were set to the domain name derived from the topology section of the model, or the default `base_domain`. The cluster entries are pulled from the topology section of the model, and their replica counts were derived from the number of servers for each cluster. |
| 36 | + |
| 37 | +The user is expected to fill in the image and secrets information identified by `--FIX ME--` in the domain resource output. |
| 38 | + |
| 39 | +For more advanced configurations, including pre-populating the `--FIX ME--` values, the user can populate the `kubernetes` section of the WDT model, and those values will appear in the resulting domain resources file. This model section overrides and adds some values to the result. |
| 40 | +```yaml |
| 41 | +kubernetes: |
| 42 | + metadata: |
| 43 | + name: myName |
| 44 | + namespace: myNamespace |
| 45 | + spec: |
| 46 | + image: 'my.repo/my-image:2.0' |
| 47 | + imagePullSecrets: |
| 48 | + WEBLOGIC_IMAGE_PULL_SECRET_NAME: |
| 49 | + webLogicCredentialsSecret: |
| 50 | + name: '@@PROP:mySecret@@' |
| 51 | + serverPod: |
| 52 | + env: |
| 53 | + USER_MEM_ARGS: |
| 54 | + value: '-XX:+UseContainerSupport -Djava.security.egd=file:/dev/./urandom' |
| 55 | + JAVA_OPTIONS: |
| 56 | + value: '-Dmydir=/home/me' |
| 57 | +``` |
| 58 | +This example uses `@@PROP:mySecret@@` to pull the value for `webLogicCredentialsSecret` from the variables file specified on the command line. This can be done with any of the values in the `kubernetes` section of the model. More details about using model variables can be found [here](../README.md/#simple-example). |
| 59 | + |
| 60 | +For this example, the resulting domain resource file would contain: |
| 61 | +```yaml |
| 62 | +metadata: |
| 63 | + name: myName |
| 64 | + namespace: myNamespace |
| 65 | +spec: |
| 66 | + image: 'my.repo/my-image:2.0' |
| 67 | + imagePullSecrets: |
| 68 | + - name: WEBLOGIC_IMAGE_PULL_SECRET_NAME |
| 69 | + webLogicCredentialsSecret: |
| 70 | + name: WEBLOGIC_CREDENTIALS_SECRET_NAME |
| 71 | + serverPod: |
| 72 | + env: |
| 73 | + - name: USER_MEM_ARGS |
| 74 | + value: '-XX:+UseContainerSupport -Djava.security.egd=file:/dev/./urandom' |
| 75 | + - name: JAVA_OPTIONS |
| 76 | + value: '-Dmydir=/home/me' |
| 77 | + domainHome: /u01/mine/domain |
| 78 | + clusters: |
| 79 | + - clusterName: mycluster |
| 80 | + replicas: 2 |
| 81 | + - clusterName: mycluster3 |
| 82 | + replicas: 4 |
| 83 | +apiVersion: weblogic.oracle/v6 |
| 84 | +kind: Domain |
| 85 | +``` |
| 86 | + |
| 87 | +The syntax of the `spec/serverPod/env` and other list sections in the WDT model are different from the syntax in the target file. The WDT tools do not recognize the hyphenated list syntax, so these elements are specified in a similar manner to other model lists. |
| 88 | + |
| 89 | +If clusters are specified in the `kubernetes/spec` section of the model, those clusters will be configured in the domain resource file, and clusters from the `topology` section will be disregarded. |
| 90 | + |
| 91 | +If the WDT model has a value of `Never` for `spec/imagePullPolicy`, the `imagePullSecrets` default value will not be added. |
| 92 | + |
| 93 | +A full list of sections and variables supported by the Oracle WebLogic Server Kubernetes Operator is available [here](https://github.com/oracle/weblogic-kubernetes-operator/blob/master/docs/domains/Domain.md). |
| 94 | + |
| 95 | +The Extract Domain Resource Tool supports a subset of these sections, including `metadata`, `serverPod`, and `spec`. |
| 96 | + |
| 97 | +The content in the `kubernetes` section is not generated when a model is discovered by the Discover Domain Tool. |
0 commit comments