Skip to content

Commit f48866f

Browse files
jshum2479rjeberhard
authored andcommitted
support model encryption in domain on pv
1 parent d147e5f commit f48866f

File tree

10 files changed

+112
-10
lines changed

10 files changed

+112
-10
lines changed

documentation/domains/Domain.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@
735735
"description": "An optional field that describes the configuration to create a PersistentVolume for `Domain on PV` domain. Omit this section if you have manually created a persistent volume. The operator will perform this one-time create operation only if the persistent volume does not already exist. The operator will not recreate or update the PersistentVolume when it exists. More info: https://oracle.github.io/weblogic-kubernetes-operator/managing-domains/domain-on-pv-initialization#pv",
736736
"$ref": "#/definitions/PersistentVolume"
737737
},
738+
"wdtModelEncryptionPassphraseSecret": {
739+
"description": "Specifies the secret name of the WebLogic Deployment Tool encryption passphrase if the WDT models provided in the \u0027domainCreationImages\u0027 or \u0027domainCreationConfigMap\u0027 are encrypted using the WebLogic Deployment Tool \u0027encryptModel\u0027 command. The secret must use the key \u0027passphrase\u0027 containing the actual passphrase for decryption.",
740+
"type": "string"
741+
},
738742
"domain": {
739743
"description": "Describes the configuration for creating an initial WebLogic Domain in persistent volume (`Domain in PV`). The operator will not recreate or update the domain if it already exists. Required.",
740744
"$ref": "#/definitions/DomainOnPV"

documentation/domains/Domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ The current status of the operation of the WebLogic domain. Updated automaticall
249249
| `runDomainInitContainerAsRoot` | Boolean | Specifies whether the operator will run the domain initialization init container in the introspector job as root. This may be needed in some environments to create the domain home directory on PV. Defaults to false. |
250250
| `setDefaultSecurityContextFsGroup` | Boolean | Specifies whether the operator will set the default 'fsGroup' in the introspector job pod security context. This is needed to create the domain home directory on PV in some environments. If the 'fsGroup' is specified as part of 'spec.introspector.serverPod.podSecurityContext', then the operator will use that 'fsGroup' instead of the default 'fsGroup'. Defaults to true. |
251251
| `waitForPvcToBind` | Boolean | Specifies whether the operator will wait for the PersistentVolumeClaim to be bound before proceeding with the domain creation. Defaults to true. |
252+
| `wdtModelEncryptionPassphraseSecret` | string | Specifies the secret name of the WebLogic Deployment Tool encryption passphrase if the WDT models provided in the 'domainCreationImages' or 'domainCreationConfigMap' are encrypted using the WebLogic Deployment Tool 'encryptModel' command. The secret must use the key 'passphrase' containing the actual passphrase for decryption. |
252253

253254
### Model
254255

documentation/site/content/managing-domains/domain-on-pv/usage.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ To use this feature, provide the following information:
2929
- [Domain information](#domain-information) - This describes the domain type and whether the operator should create the RCU schema.
3030
- [Domain WDT models](#domain-creation-models) - This is where the WDT Home, WDT model, WDT archive, and WDT variables files reside.
3131
- [Optional WDT models ConfigMap](#optional-wdt-models-configmap) - Optional, WDT model, WDT variables files.
32+
- [Using WDT model encryption](#using-wdt-model-encryption) - Optional, using WDT model encryption.
3233
- [Domain resource YAML file]({{< relref "/reference/domain-resource.md">}}) - This is for deploying the domain in WebLogic Kubernetes Operator.
3334

3435

@@ -113,6 +114,21 @@ those in `domainCreationImages`.
113114

114115
The files inside this ConfigMap must have file extensions, `.yaml`, `.properties`, or `.zip`.
115116

117+
#### Using WDT model encryption
118+
119+
Staring in WebLogic Kubernetes Operator version 4.2.18. If the provided WDT models are encrypted using the WDT `encryptModel`
120+
command. You can specify the encryption passphrase as a secret in the domain resource YAML. WDT will use the value in the
121+
secret to decrypt the models for domain creation.
122+
123+
```yaml
124+
initializeDomainOnPV:
125+
wdtModelEncryptionPassphraseSecret: model-encryption-secret
126+
```
127+
128+
The secret must have a key `passphrase` containing the value of the WDT encryption passphrase used to encrypt the models.
129+
130+
`kubectl create secret generic model-encrypion-secret --from-literal=passphrase=<encryption passphrase value>`
131+
116132
#### Volumes and VolumeMounts information
117133

118134
You must provide the `volumes` and `volumeMounts` information in `domain.spec.serverPod`. This allows the pod to mount the persistent

kubernetes/crd/domain-crd.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
weblogic.sha256: 93876ffc518d2d133a9ece2860ee9e02131ae3341f4d69e2b15e0b7697a00a15
8+
weblogic.sha256: d4d20a0a6c4d30fb25539595ecbb553264ab5ac1647009db79c696579f049197
99
name: domains.weblogic.oracle
1010
spec:
1111
group: weblogic.oracle
@@ -276,6 +276,14 @@ spec:
276276
type: object
277277
type: object
278278
type: object
279+
wdtModelEncryptionPassphraseSecret:
280+
description: Specifies the secret name of the WebLogic Deployment
281+
Tool encryption passphrase if the WDT models provided in
282+
the 'domainCreationImages' or 'domainCreationConfigMap'
283+
are encrypted using the WebLogic Deployment Tool 'encryptModel'
284+
command. The secret must use the key 'passphrase' containing
285+
the actual passphrase for decryption.
286+
type: string
279287
domain:
280288
description: Describes the configuration for creating an initial
281289
WebLogic Domain in persistent volume (`Domain in PV`). The

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ String getRuntimeEncryptionSecretName() {
239239
return getDomain().getRuntimeEncryptionSecret();
240240
}
241241

242+
String getWdtModelEncryptionSecretName() {
243+
return getDomain().getWdtModelEncryptionSecret();
244+
}
242245

243246
// ----------------------- step methods ------------------------------
244247

@@ -603,11 +606,18 @@ protected V1PodSpec createPodSpec() {
603606
podSpec.addVolumesItem(new V1Volume().name(OPSS_KEYPASSPHRASE_VOLUME).secret(
604607
getOpssWalletPasswordSecretVolume()));
605608
}
609+
606610
if (getOpssWalletFileSecretName() != null) {
607611
podSpec.addVolumesItem(new V1Volume().name(OPSS_WALLETFILE_VOLUME).secret(
608612
getOpssWalletFileSecretVolume()));
609613
}
610614

615+
if (getWdtModelEncryptionSecretVolume() != null) {
616+
podSpec.addVolumesItem(new V1Volume().name(WDT_MODEL_ENCRYPTION_PASSPHRASE_VOLUME).secret(
617+
getWdtModelEncryptionSecretVolume()
618+
));
619+
}
620+
611621
podSpec.setImagePullSecrets(info.getDomain().getSpec().getImagePullSecrets());
612622

613623
for (V1Volume additionalVolume : getAdditionalVolumes()) {
@@ -730,7 +740,12 @@ protected V1Container createPrimaryContainer() {
730740
if (getOpssWalletFileSecretVolume() != null) {
731741
container.addVolumeMountsItem(readOnlyVolumeMount(OPSS_WALLETFILE_VOLUME, OPSS_WALLETFILE_MOUNT_PATH));
732742
}
733-
743+
744+
if (getWdtModelEncryptionSecretVolume() != null) {
745+
container.addVolumeMountsItem(readOnlyVolumeMount(WDT_MODEL_ENCRYPTION_PASSPHRASE_VOLUME,
746+
WDT_MODEL_ENCRYPTION_PASSPHRASE_MOUNT_PATH));
747+
}
748+
734749
for (V1VolumeMount additionalVolumeMount : getAdditionalVolumeMounts()) {
735750
container.addVolumeMountsItem(additionalVolumeMount);
736751
}
@@ -886,6 +901,17 @@ private V1SecretVolumeSource getOpssWalletFileSecretVolume() {
886901
return null;
887902
}
888903

904+
private V1SecretVolumeSource getWdtModelEncryptionSecretVolume() {
905+
if (getWdtModelEncryptionSecretName() != null) {
906+
V1SecretVolumeSource result = new V1SecretVolumeSource()
907+
.secretName(getWdtModelEncryptionSecretName())
908+
.defaultMode(420);
909+
result.setOptional(true);
910+
return result;
911+
}
912+
return null;
913+
}
914+
889915
private V1ConfigMapVolumeSource getConfigMapVolumeSource() {
890916
return new V1ConfigMapVolumeSource()
891917
.name(KubernetesConstants.SCRIPT_CONFIG_MAP_NAME)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2018, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.operator.helpers;
@@ -11,6 +11,7 @@ public interface StepContextConstants {
1111
String DEBUG_CM_VOLUME = "weblogic-domain-debug-cm-volume";
1212
String INTROSPECTOR_VOLUME = "weblogic-domain-introspect-cm-volume";
1313
String RUNTIME_ENCRYPTION_SECRET_VOLUME = "weblogic-domain-runtime-encryption-volume";
14+
String WDT_MODEL_ENCRYPTION_PASSPHRASE_VOLUME = "wdt-encryption-passphrase-volume";
1415
String FLUENTD_CONFIGMAP_VOLUME = "weblogic-fluentd-configmap-volume";
1516
String OLD_FLUENTD_CONFIGMAP_NAME = "weblogic-fluentd-configmap";
1617
String FLUENTD_CONFIGMAP_NAME_SUFFIX = "-" + OLD_FLUENTD_CONFIGMAP_NAME;
@@ -23,6 +24,7 @@ public interface StepContextConstants {
2324
String FLUENTBIT_CONFIGMAP_NAME_SUFFIX = "-" + "weblogic-fluentbit-configmap";
2425
String SECRETS_MOUNT_PATH = "/weblogic-operator/secrets";
2526
String OPSS_KEY_MOUNT_PATH = "/weblogic-operator/opss-walletkey-secret";
27+
String WDT_MODEL_ENCRYPTION_PASSPHRASE_MOUNT_PATH = "/weblogic-operator/wdt-encryption-passphrase";
2628
String RUNTIME_ENCRYPTION_SECRET_MOUNT_PATH = "/weblogic-operator/model-runtime-secret";
2729
String OVERRIDE_SECRETS_MOUNT_PATH = "/weblogic-operator/config-overrides-secrets";
2830
String OVERRIDES_CM_MOUNT_PATH = "/weblogic-operator/config-overrides";

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainResource.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.weblogic.domain.model;
@@ -449,6 +449,14 @@ public String getModelOpssWalletPasswordSecret() {
449449
return spec.getModelOpssWalletPasswordSecret();
450450
}
451451

452+
/**
453+
* Reference to secret name of the wdt encryption passphrase for domain on pv.
454+
* @return wdt model encryption passphrase secret name
455+
*/
456+
public String getWdtModelEncryptionSecret() {
457+
return spec.getWdtModelEncryptionSecret();
458+
}
459+
452460
/**
453461
* Reference to runtime encryption secret.
454462
*

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/DomainSpec.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2017, 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.weblogic.domain.model;
@@ -982,6 +982,12 @@ private String getModelOpssWalletFileSecret() {
982982
.orElse(null);
983983
}
984984

985+
String getWdtModelEncryptionSecret() {
986+
return Optional.ofNullable(getInitializeDomainOnPV())
987+
.map(InitializeDomainOnPV::getWdtModelEncryptionPassphraseSecret)
988+
.orElse(null);
989+
}
990+
985991
private String getInitializeDomainOnPVOpssWalletFileSecret() {
986992
return Optional.ofNullable(getInitializeDomainOnPV())
987993
.map(InitializeDomainOnPV::getDomain)

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/InitializeDomainOnPV.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2025, Oracle and/or its affiliates.
22
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33

44
package oracle.kubernetes.weblogic.domain.model;
@@ -52,6 +52,12 @@ public class InitializeDomainOnPV {
5252
+ " will use that 'fsGroup' instead of the default 'fsGroup'. Defaults to true.")
5353
Boolean setDefaultSecurityContextFsGroup;
5454

55+
@Description("Specifies the secret name of the WebLogic Deployment Tool encryption passphrase if the WDT models "
56+
+ "provided in the 'domainCreationImages' or 'domainCreationConfigMap' are encrypted using the "
57+
+ "WebLogic Deployment Tool 'encryptModel' command. "
58+
+ "The secret must use the key 'passphrase' containing the actual passphrase for decryption.")
59+
String wdtModelEncryptionPassphraseSecret;
60+
5561
public PersistentVolume getPersistentVolume() {
5662
return persistentVolume;
5763
}
@@ -106,14 +112,24 @@ public InitializeDomainOnPV setDefaultFsGroup(Boolean setDefaultFsGroup) {
106112
return this;
107113
}
108114

115+
public String getWdtModelEncryptionPassphraseSecret() {
116+
return wdtModelEncryptionPassphraseSecret;
117+
}
118+
119+
public InitializeDomainOnPV wdtModelEncryptionPassphraseSecret(String wdtModelEncryptionPassphraseSecret) {
120+
this.wdtModelEncryptionPassphraseSecret = wdtModelEncryptionPassphraseSecret;
121+
return this;
122+
}
123+
109124
@Override
110125
public String toString() {
111126
ToStringBuilder builder =
112127
new ToStringBuilder(this)
113128
.append("persistentVolume", persistentVolume)
114129
.append("persistentVolumeClaim", persistentVolumeClaim)
115130
.append("domain", domain)
116-
.append("waitForPvcToBind", waitForPvcToBind);
131+
.append("waitForPvcToBind", waitForPvcToBind)
132+
.append("runDomainInitContainerAsRoot", runDomainInitContainerAsRoot);
117133

118134
return builder.toString();
119135
}
@@ -124,7 +140,8 @@ public int hashCode() {
124140
.append(persistentVolume)
125141
.append(persistentVolumeClaim)
126142
.append(domain)
127-
.append(waitForPvcToBind);
143+
.append(waitForPvcToBind)
144+
.append(runDomainInitContainerAsRoot);
128145

129146
return builder.toHashCode();
130147
}
@@ -143,7 +160,8 @@ public boolean equals(Object other) {
143160
.append(persistentVolume, rhs.persistentVolume)
144161
.append(persistentVolumeClaim, rhs.persistentVolumeClaim)
145162
.append(domain, rhs.domain)
146-
.append(waitForPvcToBind, rhs.waitForPvcToBind);
163+
.append(waitForPvcToBind, rhs.waitForPvcToBind)
164+
.append(wdtModelEncryptionPassphraseSecret, rhs.wdtModelEncryptionPassphraseSecret);
147165

148166
return builder.isEquals();
149167
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2025, Oracle and/or its affiliates.
33
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
#
55
# This script contains the all the function of creating domain on pv
@@ -12,6 +12,9 @@ source ${SCRIPTPATH}/wdt_common.sh
1212
# we export the opss password file location because it's also used by introspectDomain.py
1313
export OPSS_KEY_PASSPHRASE="/weblogic-operator/opss-walletkey-secret/walletPassword"
1414
OPSS_KEY_B64EWALLET="/weblogic-operator/opss-walletfile-secret/walletFile"
15+
WDT_MODEL_ENCRYPTION_PASSPHRASE_ROOT="/weblogic-operator/wdt-encryption-passphrase"
16+
WDT_MODEL_ENCRYPTION_PASSPHRASE="${WDT_MODEL_ENCRYPTION_PASSPHRASE_ROOT}/passphrase"
17+
1518
IMG_MODELS_HOME="/auxiliary/models"
1619
IMG_MODELS_ROOTDIR="${IMG_MODELS_HOME}"
1720
IMG_ARCHIVES_ROOTDIR="${IMG_MODELS_HOME}"
@@ -210,6 +213,16 @@ createDomainFromWDTModel() {
210213
cp /weblogic-operator/scripts/dopv-filters.json "${WDT_CUSTOM_CONFIG}/model_filters.json" || exitOrLoop
211214
fi
212215

216+
if [ -d "${WDT_MODEL_ENCRYPTION_PASSPHRASE_ROOT}" ]; then
217+
if [ ! -f "${WDT_MODEL_ENCRYPTION_PASSPHRASE}" ]; then
218+
trace SEVERE "Domain Source Type is 'DomainOnPV' and you have specified " \
219+
" 'initializeDomainOnPV.wdtModelEncryptionPassphraseSecret' but this secret does not have the required key " \
220+
" 'passphrase', update the secret and rerun the introspector job."
221+
exitOrLoop
222+
fi
223+
wdtArgs+=" -passphrase_file ${WDT_MODEL_ENCRYPTION_PASSPHRASE}"
224+
fi
225+
213226
if [ -z "${OPSS_FLAGS}" ]; then
214227

215228
# Determine run rcu or not

0 commit comments

Comments
 (0)