Skip to content

Commit 2e1cd7b

Browse files
ankediaTom Barnes
andauthored
OWLS-90955 - Document expected file merge order for auxiliary images defined at various scopes (#2478)
* Document expected file merge order for auxiliary images at a particular scope and at different scopes. Co-authored-by: Tom Barnes <tom.barnes@oracle.com>
1 parent 846faa7 commit 2e1cd7b

File tree

2 files changed

+179
-28
lines changed

2 files changed

+179
-28
lines changed

documentation/staging/content/userguide/managing-domains/model-in-image/auxiliary-images.md

Lines changed: 171 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ description = "Auxiliary images are an alternative approach for supplying a doma
1111
- [Introduction](#introduction)
1212
- [References](#references)
1313
- [Configuration](#configuration)
14-
- [Auxiliary images](#auxiliary-images)
1514
- [Auxiliary volumes and paths](#auxiliary-volumes-and-paths)
15+
- [Auxiliary images](#auxiliary-images)
1616
- [Model in Image paths](#model-in-image-paths)
17+
- [Merge order](#merge-order)
18+
- [Expected merge order](#expected-merge-order)
19+
- [Performing replaces instead of merges](#performing-replaces-instead-of-merges)
20+
- [Merge ordering example](#merge-ordering-example)
1721
- [Sample](#sample)
18-
- [Step 1: Prerequisites](#step-1-prerequisites)
19-
- [Step 2: Create the auxiliary image](#step-2-create-the-auxiliary-image)
20-
- [Step 3: Prepare and apply the domain resource](#step-3-prepare-and-apply-the-domain-resource)
21-
- [Step 4: Invoke the web application](#step-4-invoke-the-web-application)
22+
- [Step 1: Prerequisites](#step-1-prerequisites)
23+
- [Step 2: Create the auxiliary image](#step-2-create-the-auxiliary-image)
24+
- [Step 3: Prepare and apply the domain resource](#step-3-prepare-and-apply-the-domain-resource)
25+
- [Step 4: Invoke the web application](#step-4-invoke-the-web-application)
2226

2327
### Introduction
2428

@@ -38,7 +42,7 @@ Instead:
3842
and `domain.spec.configuration.model.modelHome` fields are set to
3943
reference a directory that contains the files from the smaller images.
4044

41-
The advantages of auxiliary image for Model In Image domains are:
45+
The advantages of auxiliary images for Model In Image domains are:
4246

4347
- Use or patch a WebLogic installation image without needing to include a WDT installation,
4448
application archive, or model artifacts within the image.
@@ -67,12 +71,49 @@ from additional images.
6771
This section describes a typical auxiliary image configuration for the
6872
Model in Image use case.
6973

74+
#### Auxiliary volumes and paths
75+
76+
A domain resource `domain.spec.auxiliaryImageVolumes`
77+
auxiliary image volume defines a `mountPath`, `name`, plus
78+
[additional optional fields](https://github.com/oracle/weblogic-kubernetes-operator/blob/main/documentation/domains/Domain.md#auxiliary-image-volume).
79+
The `mountPath` field is the location of a directory in an auxiliary image, and
80+
is also the location in the main pod container (which will automatically contain
81+
a recursive copy of the auxiliary image directory). The `name` field is
82+
arbitrary, and is in turn referenced by one or more auxiliary images that
83+
are defined separately using
84+
[Auxiliary images](#auxiliary-images) configuration.
85+
86+
For example:
87+
88+
```
89+
spec:
90+
auxiliaryImageVolumes:
91+
- name: auxiliaryImageVolume1
92+
mountPath: /auxiliary
93+
```
94+
7095
#### Auxiliary images
7196

72-
One or more auxiliary images can be configured on a domain resource `serverPod`.
97+
One or more auxiliary images can be configured in a domain resource
98+
`serverPod.auxiliaryImage` array.
99+
Each array entry must define an `image` and `volume`
100+
where `image` is the name of an auxiliary image
101+
and the `volume` is the name of an [auxiliary image volume](#auxiliary-volumes-and-paths)
102+
as described previously.
103+
Optionally , you can also specify an `imagePullPolicy`,
104+
which defaults to `Always` if the `image` ends in `:latest` and to `IfNotPresent`,
105+
otherwise.
106+
Also, optionally, you can customize
107+
the command that is used to merge (copy) the auxiliary image's files
108+
into the auxiliary image volume during pod startup (this is rarely
109+
needed, see [Performing replaces instead of merges](#performing-replaces-instead-of-merges) for an example).
110+
For details
111+
about each field, see the [schema](https://github.com/oracle/weblogic-kubernetes-operator/blob/main/documentation/domains/Domain.md#auxiliary-image).
112+
73113
A `serverPod` can be defined at the domain scope, which applies to every pod in
74114
the domain, plus the introspector job's pod, at a specific WebLogic cluster's scope,
75-
or at a specific WebLogic Server pod's scope. Typically, the domain scope is
115+
or at a specific WebLogic Server pod's scope.
116+
Typically, the domain scope is
76117
the most applicable for the Model in Image use case; for example:
77118

78119
```
@@ -89,22 +130,6 @@ If image pull secrets are required for pulling auxiliary images,
89130
then the secrets must be referenced using `domain.spec.imagePullSecrets`.
90131
{{% /notice %}}
91132

92-
#### Auxiliary volumes and paths
93-
94-
The `serverPod.auxiliaryImages.volume` field refers to the name of an auxiliary
95-
image volume defined in the `domain.spec.auxiliaryImageVolumes` section, and
96-
an auxiliary image volume, in turn, defines a `mountPath`. The `mountPath`
97-
is the location of a directory in an auxiliary image, and
98-
is also the location in the main pod container (which will automatically contain
99-
a recursive copy of the auxiliary image directory). For example:
100-
101-
```
102-
spec:
103-
auxiliaryImageVolumes:
104-
- name: auxiliaryImageVolume1
105-
mountPath: /auxiliary
106-
```
107-
108133
#### Model in Image paths
109134

110135
For the Model In Image auxiliary image use case, you also need to
@@ -123,6 +148,126 @@ respectively, and must be changed to specify a directory in
123148
wdtInstallHome: "/auxiliary/weblogic-deploy"
124149
```
125150

151+
{{% notice warning %}}
152+
If multiple auxiliary images supply different versions of a WebLogic Deploy Tool installation
153+
to the same `wdtInstallHome` path, then it is recommended
154+
to ensure that the newer version completely replaces the older version
155+
instead of merges with it. See [Performing replaces instead of merges](#performing-replaces-instead-of-merges).
156+
{{% /notice %}}
157+
158+
### Merge order
159+
160+
Refer to this section if you need to control the merge order of files from
161+
multiple auxiliary images that all reference the same volume, or if
162+
you want to customize the command that is used to copy the
163+
files from an auxiliary image into its volume. You can
164+
use command customization to force "replace" behavior instead
165+
of merge behavior.
166+
167+
#### Expected merge order
168+
169+
By default, the files from multiple auxiliary images that share
170+
the same volume are merged. Specifically:
171+
172+
- Files from later images in the merge overwrite same named files from earlier images.
173+
174+
- The contents of overlapping directories from multiple images are combined.
175+
176+
The expected merge order for auxiliary images that share
177+
the same auxiliary image volume is:
178+
179+
- If you specify auxiliary images at different `serverPod` scopes,
180+
and they all share the same volume, then the files from the
181+
domain scope will be merged first, the cluster scope second,
182+
and the server scope last.
183+
184+
- If you specify multiple auxiliary images at the same scope,
185+
and they all share the same volume, then the files
186+
will be merged in the order in which images appear
187+
under `serverPod.auxiliaryImages`.
188+
189+
__Note:__ If the results of a merge yield two or more
190+
differently named `domain.spec.configuration.model.ModelHome` model files in
191+
an auxilliary image volume, then refer to
192+
[Model file naming and loading order]({{< relref "/userguide/managing-domains/model-in-image/model-files#model-file-naming-and-loading-order">}})
193+
for the model files loading order.
194+
195+
#### Performing replaces instead of merges
196+
197+
If multiple auxiliary images share the same volume
198+
and you prefer that a particular same named directory from a later
199+
image completely replaces a directory from a previous
200+
image instead of combining the two directories,
201+
then you can customize the command that the second image uses to populate
202+
the shared volume in order to force a replace.
203+
204+
For example, you can customize the
205+
the second image's `serverPod.auxiliaryImage.command` field
206+
to first delete the directory that was already copied from the
207+
earlier image and then have it perform a normal copy:
208+
209+
```shell
210+
...
211+
spec:
212+
...
213+
auxiliaryImageVolumes:
214+
- name: aivolume
215+
mountPath: /auxiliary
216+
...
217+
serverPod:
218+
auxiliaryImages:
219+
- image: domain-image-A:v1
220+
volume: aivolume
221+
- image: domain-image-B:v1
222+
volume: aivolume
223+
# the following command replaces 'mydir' instead of merging it:
224+
command: 'rm -fr $TARGET_MOUNT_PATH/mydir; cp -R $COMMON_MOUNT_PATH/* $TARGET_MOUNT_PATH'
225+
```
226+
227+
#### Merge ordering example
228+
229+
Assuming you have auxiliary images are defined at the domain, the WebLogic cluster,
230+
and the server scope (myserver is part of the mycluster):
231+
232+
```
233+
...
234+
spec:
235+
auxiliaryImageVolumes:
236+
- name: aivolume
237+
mountPath: /auxiliary
238+
serverPod:
239+
auxiliaryImages:
240+
- image: domain-image-A:v1
241+
volume: aivolume
242+
- image: domain-image-B:v1
243+
volume: aivolume
244+
cluster:
245+
- name: mycluster
246+
serverPod:
247+
auxiliaryImages:
248+
- image: cl-image-A:v1
249+
volume: aivolume
250+
- image: cl-image-B:v1
251+
volume: aivolume
252+
managedServers:
253+
- serverName: "myserver"
254+
serverPod:
255+
auxiliaryImages:
256+
- image: ms-image-A:v1
257+
volume: aivolume
258+
259+
```
260+
261+
Then the files from the images will be merged into their shared `aivolume` volume `/auxiliary` mount path in the following order:
262+
263+
```
264+
domain-image-A:v1 (first)
265+
domain-image-B:v1
266+
cl-image-A:v1
267+
cl-image-B:v1
268+
ms-image-A:v1 (last)
269+
```
270+
126271
### Sample
127272

128273
This sample demonstrates deploying a Model in Image domain that uses
@@ -152,7 +297,7 @@ container image.
152297

153298
#### Step 2: Create the auxiliary image
154299

155-
Follow these steps to create a auxiliary image containing
300+
Follow these steps to create an auxiliary image containing
156301
Model In Image model files, application archives, and the WDT installation files:
157302

158303
1. Create a model ZIP application archive and place it in the same directory
@@ -477,7 +622,7 @@ $ kubectl apply -f /tmp/mii-sample/domain-resources/WLS-AI/mii-initial-d1-WLS-AI
477622

478623
**Note**: If you are choosing _not_ to use the predefined Domain YAML file
479624
and instead created your own Domain YAML file earlier, then substitute your
480-
custom file name in the above command. Previously, we suggested naming it `/tmp/mii-sample/mii-initial.yaml`.
625+
custom file name in the previous command. Previously, we suggested naming it `/tmp/mii-sample/mii-initial.yaml`.
481626

482627
Now, if you run `kubectl get pods -n sample-domain1-ns --watch`, then you will see
483628
the introspector job run and your WebLogic Server pods start. The output will look something like this:

documentation/staging/content/userguide/managing-domains/model-in-image/model-files.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ For a description of model file macro references to secrets and environment vari
9090

9191
Refer to this section if you need to control the order in which your model files are loaded. The order is important when two or more model files refer to the same configuration, because the last model that's loaded has the highest precedence.
9292

93-
During domain home creation, model, and property files are first loaded from the `configuration.models.modelHome` directory within the image, which defaults to `/u01/wdt/models`, and are then loaded from the optional WDT ConfigMap, described in [Optional WDT model ConfigMap]({{< relref "/userguide/managing-domains/model-in-image/usage/_index.md#optional-wdt-model-configmap" >}}).
93+
During domain home creation, model and property files are first loaded from the `configuration.models.modelHome` directory within the image, which defaults to `/u01/wdt/models`. After the `modelHome` files are all loaded, the domain home creation then loads files from the optional WDT ConfigMap, described in [Optional WDT model ConfigMap]({{< relref "/userguide/managing-domains/model-in-image/usage/_index.md#optional-wdt-model-configmap" >}}). If a `modelHome` file and ConfigMap file both have the same name, then both files are loaded.
9494

9595
The loading order within each of these locations is first determined using the convention `filename.##.yaml` and `filename.##.properties`, where `##` are digits that specify the desired order when sorted numerically. Additional details:
9696

@@ -101,7 +101,11 @@ The loading order within each of these locations is first determined using the c
101101
* File names that don't include `.##.` sort _before_ other files as if they implicitly have the lowest possible `.##.`
102102
* If two files share the same number, the loading order is determined alphabetically as a tie-breaker.
103103

104-
If an image file and ConfigMap file both have the same name, then both files are loaded.
104+
> Note: If `configuration.models.modelHome` files are supplied by combining multiple
105+
[Auxiliary images]({{< relref "/userguide/managing-domains/model-in-image/auxiliary-images.md" >}}),
106+
then the files in this directory are populated according to their
107+
[Auxiliary image merge order]({{< relref "/userguide/managing-domains/model-in-image/auxiliary-images#file-merge-order" >}})
108+
before the loading order is determined.
105109

106110
For example, if you have these files in the model home directory `/u01/wdt/models`:
107111

@@ -129,6 +133,8 @@ Property files (ending in `.properties`) use the same sorting algorithm, but the
129133

130134
### Model file macros
131135

136+
WDT models can have macros that reference secrets or environment variables.
137+
132138
#### Using secrets in model files
133139

134140
You can use WDT model `@@SECRET` macros to reference the WebLogic administrator `username` and `password` keys that are stored in a Kubernetes Secret and to optionally reference additional secrets. Here is the macro pattern for accessing these secrets:

0 commit comments

Comments
 (0)