Update 2
This use case demonstrates concurrently deploying a domain that is similar to the
Update 1
use case domain to the same sample-domain1-ns namespace, but with a different domain UID, a different WebLogic domain name, and a different WebLogic domain encryption key. It does this by:
- Using the same image, image model YAML file, and application archive as the Initial and Update 1 use cases.
- Using the same model update ConfigMap source file as the Update 1 use case (a data source).
- Using a different (unique) domain UID,
sample-domain2, for the new domain. - Using a different (unique) domain name,
domain2, for the different domains. - Deploying secrets and a model update ConfigMap that are uniquely labeled and named for the new domain.
Note that this use case shows Model in Image’s unique ability to quickly deploy a copy of a WebLogic domain that has a different WebLogic domain name and domain encryption key. This is a useful capability that is not supported by the Domain in Image domain home source type :
-
Domain in Image does not support overriding the domain name, but different domain names are necessary when two domains need to interoperate. This use case takes advantage of model macros to ensure that its two different domains have a different domain name:
- First, you define the domain name in the model YAML file using the
@@ENV:CUSTOM_DOMAIN_NAME@@environment variable macro. - Second, you set the value of the
CUSTOM_DOMAIN_NAMEenvironment variable to be different using theenvstanza in each Domain’s YAML file.
- First, you define the domain name in the model YAML file using the
-
Domain in Image requires that its images embed a WebLogic
security/SerializedSystemIni.datdomain encryption key that cannot be changed for the image (see Why layering matters in CI/CD considerations). This necessarily means that two Domain in Image domains that share the same image can decrypt each other’s encrypted passwords. On the other hand, a Model in Image’s domain encryption key is not embedded in the image and instead, is dynamically and uniquely created each time the domain is started.
Warning
Oracle requires interoperating WebLogic domains to have different domain names. This is necessary when two domains communicate, or when a WebLogic Server or WebLogic Java client concurrently connects to multiple domains.
Here are the steps for this use case:
-
Make sure you have deployed the domain from the Update 1 use case.
-
Create a ConfigMap with the WDT model that contains the data source definition.
Run the following commands:
If you’ve created your own data source file in the Update 1 use case, then substitute the file name in the
--from-file=parameter (we suggested/tmp/sample/mydatasource.yamlearlier). Note that the-from-file=parameter can reference a single file, in which case it puts the designated file in the ConfigMap, or it can reference a directory, in which case it populates the ConfigMap with all of the files in the designated directory.Observations:
- We are leaving the namespace
sample-domain1-nsunchanged for the ConfigMap because you will deploy domainsample-domain2to the same namespace assample-domain1. - You name and label the ConfigMap using its associated domain UID for two reasons:
- To make it obvious which ConfigMap belongs to which domain.
- To make it easier to clean up a domain. Typical cleanup scripts use the
weblogic.domainUIDlabel as a convenience for finding all resources associated with a domain.
- You use a different ConfigMap for the new domain for two reasons:
- To make it easier to keep the life cycle and/or CI/CD process for the two domains simple and independent.
- To ‘future proof’ the new domain so that changes to the original domain or new domain’s ConfigMap can be independent.
- We are leaving the namespace
-
Create the secrets that are referenced by the WDT model files in the image and ConfigMap; they also will be referenced by the Domain YAML file.
Run the following commands:
NOTE: Substitute a password of your choice for
MY_WEBLOGIC_ADMIN_PASSWORD. This password should contain at least seven letters plus one digit.NOTE: Substitute a password of your choice for
MY_RUNTIME_PASSWORD. It should be unique and different than the admin password, but this is not required.Observations:
- We are leaving the namespace
sample-domain1-nsunchanged for each secret because you will deploy domainsample-domain2to the same namespace assample-domain1. - You name and label the secrets using their associated domain UID for two reasons:
- To make it obvious which secret belongs to which domain.
- To make it easier to clean up a domain. Typical cleanup scripts use the
weblogic.domainUIDlabel as a convenience for finding all resources associated with a domain.
- You use a different set of secrets for the new domain for two reasons:
- To make it easier to keep the life cycle and/or CI/CD process for the two domains simple and independent.
- To ‘future proof’ the new domain so that changes to the original domain’s secrets or new domain’s secrets can be independent.
- We deliberately specify an incorrect password and a low maximum pool capacity in the data source secret because we will demonstrate dynamically correcting the data source attributes for
sample-domain1in the Update 4 use case.
- We are leaving the namespace
-
Set up a Domain YAML file that is similar to your Update 1 use case Domain YAML file but with a different domain UID, domain name, model update ConfigMap reference, and Secret references:
-
Option 1: Update a copy of your Domain YAML file from the Update 1 use case.
-
In the Update 1 use case, we suggested creating a file named
/tmp/sample/mii-update1.yamlor using the/tmp/sample/domain-resources/WLS/mii-update1-d1-WLS-v1-ds.yamlfile that is supplied with the sample.-
We suggest copying this Domain YAML file and naming the copy
/tmp/sample/mii-update2.yamlbefore making any changes. -
Working on a copy is not strictly necessary, but it helps keep track of your work for the different use cases in this sample and provides you a backup of your previous work.
-
-
Change the
/tmp/sample/mii-update2.yamlDomain YAML file name andweblogic.domainUIDlabel tosample-domain2.The final result will look something like this:
NOTE: We are leaving the namespace
sample-domain1-nsunchanged because you will be deploying domainsample-domain2to the same namespace assample-domain1. -
Change the
/tmp/sample/mii-update2.yamlDomain YAML file’sCUSTOM_DOMAIN_NAMEenvironment variable fromdomain1todomain2.The model file in the image uses macro
@@ENV:CUSTOM_DOMAIN_NAME@@to reference this environment variable when setting its domain name.Specifically, change the corresponding Domain
spec.serverPod.envYAML file stanza to look something like this: -
Change the
/tmp/sample/mii-update2.yamlDomain YAML file’sspec.domainHomevalue to/u01/domains/sample-domain2. The corresponding YAML file stanza will look something like this:(This change is not strictly needed, but it is a helpful convention to decorate a WebLogic domain’s home directory with its domain name or domain UID.)
-
Change the
/tmp/sample/mii-update2.yamlsecret references in thespec.webLogicCredentialsSecretandspec.configuration.secretsstanzas to reference this use case’s secrets. Specifically, change:To this:
-
Change the Domain YAML file’s
spec.configuration.model.configMapvalue fromsample-domain1-wdt-config-maptosample-domain2-wdt-config-map. The corresponding YAML file stanza will look something like this: -
Now, compare your original and changed Domain YAML files to double check your changes.
NOTE: The diff should not contain a namespace change. You are deploying domain
sample-domain2to the same namespace assample-domain1(namespacesample-domain1-ns). -
Apply your changed Domain YAML file:
NOTE: Before you deploy the domain custom resource, ensure all nodes in your Kubernetes cluster can access
auxiliary-imageand other images .
-
-
Option 2: Use the updated Domain YAML file that is supplied with the sample:
NOTE: Before you deploy the domain custom resource, ensure all nodes in your Kubernetes cluster can access
auxiliary-imageand other images .
-
-
Wait for
sample-domain2to start.If you run
kubectl get pods -n sample-domain1-ns --watch, then you will see the introspector job forsample-domain2run and your WebLogic Server pods start. The output will look something like this:For a more detailed view of this activity, you can use the
waitForDomain.shsample lifecycle script. This script provides useful information about a domain’s pods and optionally waits for itsCompletedstatus condition to becomeTrue. ACompleteddomain indicates that all of its expected pods have reached areadystate plus their targetrestartVersion,introspectVersion, andimage. For example: -
After the
sample-domain2domain is running, you can call its sample web application to verify that it’s fully active.Send a web application request to the ingress controller for
sample-domain2:Or, if Traefik is unavailable and your
domain2Administration Server pod is running, you can runkubectl exec:You will see something like the following:
A TestPool Failure is expected because we will demonstrate dynamically correcting the data source attributes for sample-domain1 in
Update 4
.
If you see an error other than the expected TestPool Failure, then consult
Debugging
.
You will not be using the sample-domain2 domain again in this sample; if you wish, you can shut it down now by calling kubectl -n sample-domain1-ns delete domain sample-domain2.
To remove the resources you have created in the samples, see Cleanup .