Skip to content

Commit c7ba8f2

Browse files
authored
Document the ability to override the introspector job pod resource settings and name restriction on the converted 3.x aux image init-containers. (#3939)
* Documentation update for the changes to independently configure introspector pod resources and aux image upgrade restriction. * Changes to allow 'wls-shared-' prefix in the names of the init containers generated during '3.x/v8' aux image config conversion. * Fix for the environment variables in generated init containers starting with 'compat-' or 'wls-shared'.
1 parent 0a0c719 commit c7ba8f2

File tree

8 files changed

+90
-10
lines changed

8 files changed

+90
-10
lines changed

common/src/main/java/oracle/kubernetes/common/CommonConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ private CommonConstants() {
1010
}
1111

1212
public static final String COMPATIBILITY_MODE = "compat-";
13+
public static final String WLS_SHARED = "wls-shared-";
1314
public static final String API_VERSION_V9 = "weblogic.oracle/v9";
1415
public static final String API_VERSION_V8 = "weblogic.oracle/v8";
1516

documentation/4.0/content/faq/resource-settings.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ You can tune container memory and CPU usage
4040
by configuring Kubernetes resource requests and limits,
4141
and you can tune a WebLogic JVM heap usage
4242
using the `USER_MEM_ARGS` environment variable in your Domain YAML file.
43-
The introspector job pod uses the same CPU and memory settings as the
43+
By default, the introspector job pod uses the same CPU and memory settings as the
4444
domain's WebLogic Administration Server pod. Similarly, the operator created init containers in the
4545
introspector job pod for the [Auxiliary Images]({{< relref "/managing-domains/model-in-image/auxiliary-images" >}})
4646
based domains use the same CPU and memory settings as the domain's WebLogic Administration Server pod.
47+
Beginning with operator version 4.0.5, you can override the settings of the introspector job pod using
48+
the `domain.spec.introspector.serverPod` element.
4749
A resource request sets the minimum amount of a resource that a container requires.
4850
A resource limit is the maximum amount of a resource a container is given
4951
and prevents a container from using more than its share of a resource.
@@ -61,6 +63,8 @@ and you can override the setting for individual WebLogic Server instances using
6163
setting for member servers of a cluster using the `cluster.spec.serverPod` element.
6264
Note that the introspector job pod uses the same settings
6365
as the WebLogic Administration Server pod.
66+
Beginning with operator version 4.0.5, you can override the settings of the introspector job pod
67+
using the `domain.spec.introspector.serverPod` element.
6468

6569
Values set in the `.serverPod` stanzas for a more specific type of pod, override
6670
the same values if they are also set for a more general type of pod, and inherit

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,13 @@ to use Docker to build its auxiliary image:
284284
### Automated upgrade of the `weblogic.oracle/v8` schema auxiliary images configuration
285285

286286
{{% notice note %}}
287-
The automated upgrade described in this section converts `weblogic.oracle/v8` schema auxiliary image configuration into low-level Kubernetes schema, for example, init-containers and volumes.
287+
The automated upgrade described in this section converts `weblogic.oracle/v8` schema auxiliary image configuration into low-level Kubernetes schema, for example, init containers and volumes.
288288
Instead of relying on the generated low-level schema, Oracle recommends using a simplified `weblogic.oracle/v9` schema configuration for auxiliary images, as documented in the [Configuration](#configuration) section.
289289
{{% /notice %}}
290290

291291
In operator version 4.0, we have enhanced auxiliary images to improve ease of use; also, its configuration has changed from operator 3.x releases.
292292

293-
Operator 4.0 provides a seamless upgrade of Domains with `weblogic.oracle/v8` schema auxiliary images configuration. When you create a Domain with auxiliary images using `weblogic.oracle/v8` schema in a namespace managed by the 4.0 operator, the [WebLogic Domain resource conversion webhook]({{< relref "/managing-operators/conversion-webhook.md" >}}) performs an automated upgrade of the domain resource to the `weblogic.oracle/v9` schema. The conversion webhook runtime converts the `weblogic.oracle/v8` auxiliary image configuration to the equivalent configuration using init-containers, volume and volume mounts under the `serverPod` spec in `weblogic.oracle/v9`. Similarly, when [upgrading the operator]({{< relref "/managing-operators/installation#upgrade-the-operator" >}}), Domains with `weblogic.oracle/v8` schema auxiliary images are seamlessly upgraded.
293+
Operator 4.0 provides a seamless upgrade of Domains with `weblogic.oracle/v8` schema auxiliary images configuration. When you create a Domain with auxiliary images using `weblogic.oracle/v8` schema in a namespace managed by the 4.0 operator, the [WebLogic Domain resource conversion webhook]({{< relref "/managing-operators/conversion-webhook.md" >}}) performs an automated upgrade of the domain resource to the `weblogic.oracle/v9` schema. The conversion webhook runtime converts the `weblogic.oracle/v8` auxiliary image configuration to the equivalent configuration using init containers, volume and volume mounts under the `serverPod` spec in `weblogic.oracle/v9`. Similarly, when [upgrading the operator]({{< relref "/managing-operators/installation#upgrade-the-operator" >}}), Domains with `weblogic.oracle/v8` schema auxiliary images are seamlessly upgraded.
294294

295295
The following is a sample `weblogic.oracle/v8` schema auxiliary image configuration in operator 3.x and
296296
the equivalent `weblogic.oracle/v9` schema configuration generated by the conversion webhook in operator 4.0.
@@ -344,6 +344,10 @@ spec:
344344
name: compat-ai-vol-auxiliaryimagevolume1
345345
```
346346

347+
{{% notice note %}}
348+
The conversion webhook runtime creates init containers with names prefixed with `compat-` when converting the auxiliary image configuration of the `weblogic.oracle/v8` schema. The operator generates only init containers with names starting with either `compat-` or `wls-shared-` in the introspector job pod. To alter the generated init container's name, the new name must start with either `compat-` or `wls-shared-`.
349+
{{% /notice %}}
350+
347351
### Domain upgrade tool to manually upgrade the `weblogic.oracle/v8` schema domain resource
348352

349353
To manually upgrade the domain resource from the `weblogic.oracle/v8` schema to the `weblogic.oracle/v9` schema, see [Upgrade the `weblogic.oracle/v8` schema domain resource manually]({{< relref "/managing-domains/upgrade-domain-resource#upgrade-the-weblogicoraclev8-schema-domain-resource-manually" >}}).

documentation/4.0/content/managing-domains/upgrade-domain-resource/_index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The Domain CustomResourceDefinition in operator version 4.0 has changed signific
1414
### Automated upgrade of `weblogic.oracle/v8` schema domain resource
1515

1616
{{% notice note %}}
17-
The automated upgrade described in this section converts `weblogic.oracle/v8` schema auxiliary image configuration into low-level Kubernetes schema, for example, init-containers and volumes.
17+
The automated upgrade described in this section converts `weblogic.oracle/v8` schema auxiliary image configuration into low-level Kubernetes schema, for example, init containers and volumes.
1818
Instead of relying on the generated low-level schema, Oracle recommends using a simplified `weblogic.oracle/v9` schema configuration for auxiliary images, as documented in the
1919
Auxiliary Images [Configuration]({{<relref "/managing-domains/model-in-image/auxiliary-images#configuration" >}}) section.
2020
{{% /notice %}}
@@ -24,7 +24,7 @@ The 4.0 operator provides a seamless upgrade of the Domain resources with the `w
2424
### Upgrade the `weblogic.oracle/v8` schema domain resource manually
2525

2626
{{% notice note %}}
27-
The manual upgrade tooling described in this section converts `weblogic.oracle/v8` schema auxiliary image configuration into low-level Kubernetes schema, for example, init-containers and volumes.
27+
The manual upgrade tooling described in this section converts `weblogic.oracle/v8` schema auxiliary image configuration into low-level Kubernetes schema, for example, init containers and volumes.
2828
Instead of relying on the generated low-level schema, Oracle recommends using a simplified `weblogic.oracle/v9` schema configuration for auxiliary images, as documented in the
2929
Auxiliary Images [Configuration]({{<relref "/managing-domains/model-in-image/auxiliary-images#configuration" >}}) section.
3030
{{% /notice %}}
@@ -69,3 +69,7 @@ In the previous example, the tool writes the upgraded file to the `/tmp` directo
6969
$ ls -ltr /tmp/domain-v9.yaml
7070
-rw-r----- 1 user dba 2818 Apr 18 23:11 /tmp/domain-v9.yaml
7171
```
72+
73+
{{% notice note %}}
74+
The manual upgrade tooling creates init containers with names prefixed with `compat-` when converting the auxiliary image configuration of the `weblogic.oracle/v8` schema. The operator generates only init containers with names starting with either `compat-` or `wls-shared-` in the introspector job pod. To alter the generated init container's name, the new name must start with either `compat-` or `wls-shared-`.
75+
{{% /notice %}}

operator/src/main/java/oracle/kubernetes/operator/helpers/BasePodStepContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static oracle.kubernetes.common.CommonConstants.COMPATIBILITY_MODE;
4040
import static oracle.kubernetes.common.CommonConstants.SCRIPTS_MOUNTS_PATH;
4141
import static oracle.kubernetes.common.CommonConstants.SCRIPTS_VOLUME;
42+
import static oracle.kubernetes.common.CommonConstants.WLS_SHARED;
4243
import static oracle.kubernetes.common.helpers.AuxiliaryImageEnvVars.AUXILIARY_IMAGE_PATHS;
4344
import static oracle.kubernetes.weblogic.domain.model.AuxiliaryImage.AUXILIARY_IMAGE_INTERNAL_VOLUME_NAME;
4445

@@ -171,7 +172,7 @@ protected List<V1EnvVar> createEnv(AuxiliaryImage auxiliaryImage, String name) {
171172
protected List<V1EnvVar> createEnv(V1Container c) {
172173
List<V1EnvVar> initContainerEnvVars = new ArrayList<>();
173174
Optional.ofNullable(c.getEnv()).ifPresent(initContainerEnvVars::addAll);
174-
if (!c.getName().startsWith(COMPATIBILITY_MODE)) {
175+
if (!(c.getName().startsWith(COMPATIBILITY_MODE) || c.getName().startsWith(WLS_SHARED))) {
175176
getEnvironmentVariables()
176177
.forEach(envVar -> addIfMissing(initContainerEnvVars,
177178
envVar.getName(), envVar.getValue(), envVar.getValueFrom()));

operator/src/main/java/oracle/kubernetes/operator/helpers/JobStepContext.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static oracle.kubernetes.common.CommonConstants.COMPATIBILITY_MODE;
5858
import static oracle.kubernetes.common.CommonConstants.SCRIPTS_MOUNTS_PATH;
5959
import static oracle.kubernetes.common.CommonConstants.SCRIPTS_VOLUME;
60+
import static oracle.kubernetes.common.CommonConstants.WLS_SHARED;
6061
import static oracle.kubernetes.common.utils.CommonUtils.MAX_ALLOWED_VOLUME_NAME_LENGTH;
6162
import static oracle.kubernetes.common.utils.CommonUtils.VOLUME_NAME_SUFFIX;
6263
import static oracle.kubernetes.operator.DomainStatusUpdater.createKubernetesFailureSteps;
@@ -213,19 +214,23 @@ List<V1Volume> getAdditionalVolumes() {
213214
}
214215

215216
private void addVolumeIfMissing(V1Volume volume, List<V1Volume> volumes) {
216-
if (!volumes.contains(volume) && volume.getName().startsWith(COMPATIBILITY_MODE)) {
217+
if (!volumes.contains(volume) && isAllowedInIntrospector(volume.getName())) {
217218
volumes.add(volume);
218219
}
219220
}
220221

222+
private boolean isAllowedInIntrospector(String name) {
223+
return name.startsWith(COMPATIBILITY_MODE) || name.startsWith(WLS_SHARED);
224+
}
225+
221226
List<V1VolumeMount> getAdditionalVolumeMounts() {
222227
List<V1VolumeMount> volumeMounts = getDomain().getSpec().getAdditionalVolumeMounts();
223228
getServerSpec().getAdditionalVolumeMounts().forEach(mount -> addVolumeMountIfMissing(mount, volumeMounts));
224229
return volumeMounts;
225230
}
226231

227232
private void addVolumeMountIfMissing(V1VolumeMount mount, List<V1VolumeMount> volumeMounts) {
228-
if (!volumeMounts.contains(mount) && mount.getName().startsWith(COMPATIBILITY_MODE)) {
233+
if (!volumeMounts.contains(mount) && isAllowedInIntrospector(mount.getName())) {
229234
volumeMounts.add(mount);
230235
}
231236
}
@@ -402,7 +407,7 @@ protected void addInitContainers(V1PodSpec podSpec) {
402407
List<V1Container> initContainers = new ArrayList<>();
403408
Optional.ofNullable(getAuxiliaryImages()).ifPresent(auxImages -> addInitContainers(initContainers, auxImages));
404409
initContainers.addAll(getAdditionalInitContainers().stream()
405-
.filter(container -> container.getName().startsWith(COMPATIBILITY_MODE))
410+
.filter(container -> isAllowedInIntrospector(container.getName()))
406411
.map(c -> c.env(createEnv(c)).resources(createResources()))
407412
.collect(Collectors.toList()));
408413
podSpec.initContainers(initContainers);

operator/src/main/resources/scripts/auxImage.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ if [[ "$AUXILIARY_IMAGE_CONTAINER_NAME" == "operator-aux-container"* ]]; then
4848
else
4949
trace FINE "Auxiliary Image: Skipping initialization due to a previous successful initialization."
5050
fi
51-
elif [[ "$AUXILIARY_IMAGE_CONTAINER_NAME" == "compat-operator-aux-container"* ]]; then
51+
elif [[ "$AUXILIARY_IMAGE_CONTAINER_NAME" == "compat-"* ]] \
52+
|| [[ "$AUXILIARY_IMAGE_CONTAINER_NAME" == "wls-shared-"* ]]; then
5253
sucFile="${AUXILIARY_IMAGE_TARGET_PATH}/${AUXILIARY_IMAGE_COMMAND_LOGS_DIR}/${AUXILIARY_IMAGE_CONTAINER_NAME}.suc"
5354
if [ ! -f $sucFile ]; then
5455
initCompatibilityModeInitContainersWithLegacyAuxImages > /tmp/compatibilityModeInitContainers.out 2>&1

operator/src/test/java/oracle/kubernetes/operator/helpers/JobHelperTest.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575
import static com.meterware.simplestub.Stub.createNiceStub;
7676
import static oracle.kubernetes.common.CommonConstants.COMPATIBILITY_MODE;
77+
import static oracle.kubernetes.common.CommonConstants.WLS_SHARED;
7778
import static oracle.kubernetes.common.logging.MessageKeys.FLUENTD_CONFIGMAP_CREATED;
7879
import static oracle.kubernetes.common.logging.MessageKeys.FLUENTD_CONFIGMAP_REPLACED;
7980
import static oracle.kubernetes.common.utils.CommonUtils.getMD5Hash;
@@ -1028,6 +1029,19 @@ void introspectorPodSpec_createdWithConfiguredAuxImageInitContainers() {
10281029
assertThat(getNumPodSpecInitContainers(jobSpec), equalTo(1));
10291030
}
10301031

1032+
@Test
1033+
void introspectorPodSpec_createdWithConfiguredWlsSharedInitContainers() {
1034+
configureDomain()
1035+
.withInitContainer(
1036+
createContainer(
1037+
WLS_SHARED + "aux-image-container", "busybox", "sh", "-c",
1038+
"echo managed server && sleep 120"));
1039+
1040+
V1JobSpec jobSpec = createJobSpec();
1041+
1042+
assertThat(getNumPodSpecInitContainers(jobSpec), equalTo(1));
1043+
}
1044+
10311045
@Test
10321046
void introspectorPodSpec_createdWithConfiguredAuxImageInitContainersHavingIntrospectorResources() {
10331047
configureDomain()
@@ -1053,6 +1067,27 @@ private V1ResourceRequirements getInitContainerResources(V1PodSpec podSpec) {
10531067
return podSpec.getInitContainers().stream().findFirst().get().getResources();
10541068
}
10551069

1070+
@Test
1071+
void introspectorPodSpec_createdWithConfiguredWlsSharedInitContainersHavingIntrospectorResources() {
1072+
configureDomain()
1073+
.withInitContainer(
1074+
createContainer(
1075+
WLS_SHARED + "aux-image-container", "busybox", "sh", "-c",
1076+
"echo managed server && sleep 120"))
1077+
.configureIntrospector()
1078+
.withRequestRequirement("cpu", "512m")
1079+
.withLimitRequirement("memory", "1Gi"); ;
1080+
1081+
V1JobSpec jobSpec = createJobSpec();
1082+
1083+
assertThat(getNumPodSpecInitContainers(jobSpec), equalTo(1));
1084+
V1PodSpec podSpec = getPodSpec(jobSpec);
1085+
assertThat(
1086+
getInitContainerResources(podSpec),
1087+
is(new V1ResourceRequirements().requests(Collections.singletonMap("cpu", new Quantity("512m")))
1088+
.limits(Collections.singletonMap("memory", new Quantity("1Gi")))));
1089+
}
1090+
10561091
@Test
10571092
void introspectorPodSpec_createdWithoutConfiguredContainers() {
10581093
configureDomain()
@@ -1081,6 +1116,19 @@ void whenAdminServerHasLegacyAuxImageInitContainers_introspectorPodStartupWithTh
10811116
assertThat(getNumPodSpecInitContainers(jobSpec), equalTo(1));
10821117
}
10831118

1119+
@Test
1120+
void whenAdminServerHasWlsSharedInitContainers_introspectorPodStartupWithThem() {
1121+
configureDomain()
1122+
.configureAdminServer()
1123+
.withInitContainer(
1124+
createContainer(
1125+
WLS_SHARED + "aux-image-container", "busybox", "sh", "-c",
1126+
"echo managed server && sleep 120"));
1127+
V1JobSpec jobSpec = createJobSpec();
1128+
1129+
assertThat(getNumPodSpecInitContainers(jobSpec), equalTo(1));
1130+
}
1131+
10841132
@Test
10851133
void whenAdminServerHasNormalInitContainers_introspectorPodStartupWithoutThem() {
10861134
configureDomain()
@@ -1144,6 +1192,18 @@ void whenAdminServerHasLegacyAuxImageVolumeMount_introspectorPodStartupWithoutTh
11441192
.orElse(Collections.emptyList()).size(), equalTo(4));
11451193
}
11461194

1195+
@Test
1196+
void whenAdminServerHasWlsSharedVolumeMount_introspectorPodStartupWithoutThem() {
1197+
configureDomain()
1198+
.configureAdminServer()
1199+
.withAdditionalVolumeMount(WLS_SHARED + "aux-image-container_volume", "/test");
1200+
1201+
V1JobSpec jobSpec = createJobSpec();
1202+
1203+
assertThat(getMatchingContainer(domainPresenceInfo, jobSpec).map(V1Container::getVolumeMounts)
1204+
.orElse(Collections.emptyList()).size(), equalTo(4));
1205+
}
1206+
11471207
@Test
11481208
void introspectorPodContainerSpec_hasJobNameAsContainerName() {
11491209
V1JobSpec jobSpec = createJobSpec();

0 commit comments

Comments
 (0)