Skip to content

Commit c0e5400

Browse files
authored
Merge pull request #1136 from oracle/cluster-template
Pod templates at the domain, cluster, and server level + New domain resource doc.
2 parents 1b4e345 + b11d28b commit c0e5400

File tree

19 files changed

+624
-131
lines changed

19 files changed

+624
-131
lines changed

docs-source/content/userguide/managing-domains/domain-resource.md

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ pre = "<b> </b>"
88

99

1010

11-
Use this document to set up and configure your own [domain resource](https://github.com/oracle/weblogic-kubernetes-operator/blob/master/docs/domains/Domain.md) which can be used to configure your WLS domain. Then, you can use the domain resource to start the Kubernetes artifacts of the corresponding domain.
11+
Use this document to set up and configure your own [domain resource](https://github.com/oracle/weblogic-kubernetes-operator/blob/master/docs/domains/Domain.md) which can be used to configure the operation of your WebLogic domain. The domain resource does not replace the traditional configuration of WebLogic domains found in the domain configuration files, but instead cooperates with those files to describe the Kubernetes artifacts of the corresponding domain. For instance, the WebLogic domain configuration will still specify deployed applications, data sources, and most other details about the domain while the domain resource will specify the number of cluster members currently running or the persistent volumes that will be mounted into the containers running WebLogic Server instances.
12+
13+
Many of the samples accompanying the operator project include scripts to generate an initial domain resource from a set of simplified inputs; however, the domain resource is the actual source of truth for how the WebLogic operator will manage each WebLogic domain. You are encouraged to either start with the domain resource YAML files generated by the various samples or create domain resources manually or by using other tools based on the schema referenced here or this documentation.
1214

1315
Swagger documentation is available [here](https://oracle.github.io/weblogic-kubernetes-operator/swagger/index.html).
1416

@@ -41,3 +43,66 @@ To confirm that the domain resource was created, use this command:
4143
```
4244
$ kubectl describe domain [domain name] -n [namespace]
4345
```
46+
47+
#### Domain resource overview
48+
49+
The domain resource, like all [Kubernetes objects](https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/), is described by three sections: `metadata`, `spec`, and `status`.
50+
51+
The `metadata` section names the domain resource and its namespace. The name of the domain resource is the default value for the "domain UID" which is used by the operator to distinguish domains running in the Kubernetes cluster that may have the same domain name. The domain resource name is required to be unique in the namespace and the domain UID should be unique across the cluster. The domain UID, domain resource name, and domain name (from the WebLogic domain configuration) may all be different.
52+
53+
The `spec` section describes the intended running state of the domain, including intended runtime state of server instances, number of cluster members started, and details about Kubernetes pod or service generation, such as resource constraints, scheduling requirements, or volume mounts.
54+
55+
The `status` section is updated by the operator and describes the actual running state of the domain, including WebLogic Server instance runtime states and current health.
56+
57+
#### Domain resource spec elements
58+
59+
The domain resource `spec` section contains elements for configuring the domain operation and sub-sections specific to the Administration Server, specific clusters or specific Managed Servers.
60+
61+
Elements related to domain identification, Docker image, and domain home:
62+
* `domainUID`: The domain unique identifier. Must be unique across the Kubernetes cluster. Not required. Defaults to the value of `metadata.name`.
63+
* `image`: The WebLogic Docker image. Required when `domainHomeInImage` is true; otherwise, defaults to "container-registry.oracle.com/middleware/weblogic:12.2.1.3".
64+
* `imagePullPolicy`: The image pull policy for the WebLogic Docker image. Legal values are `Always`, `Never` and `IfNotPresent`. Defaults to `Always` if image ends in ":latest", `IfNotPresent` otherwise.
65+
* `imagePullSecrets`: A list of image pull secrets for the WebLogic Docker image.
66+
* `domainHome`: The folder for the WebLogic Domain. Not required. Defaults to "/shared/domains/domains/domainUID" if `domainHomeInImage` is false. Defaults to "/u01/oracle/user_projects/domains/" if `domainHomeInImage` is true.
67+
* `domainHomeInImage`: True if this domain's home is defined in the Docker image for the domain. Defaults to true.
68+
69+
Elements related to logging:
70+
* `includeServerOutInPodLog`: If true (the default), the server ".out" file will be included in the pod's stdout.
71+
* `logHome`: The in-pod name of the directory in which to store the domain, Node Manager, server logs, and server ".out" files.
72+
* `logHomeEnabled`: Specifies whether the log home folder is enabled. Not required. Defaults to true if `domainHomeInImage` is false. Defaults to false if `domainHomeInImage` is true.
73+
74+
Elements related to security:
75+
* `webLogicCredentialsSecret`: The name of a pre-created Kubernetes secret, in the domain resource's namespace, that holds the user name and password needed to boot WebLogic Server under the 'username' and 'password' fields.
76+
77+
Elements related to domain [startup and shutdown](domain-lifecycle/startup.md):
78+
* `serverStartPolicy`: The strategy for deciding whether to start a server. Legal values are `ADMIN_ONLY`, `NEVER`, or `IF_NEEDED`.
79+
* `serverStartState`: The state in which the server is to be started. Use `ADMIN` if server should start in the admin state. Defaults to `RUNNING`.
80+
* `restartVersion`: If present, every time this value is updated, the operator will restart the required servers.
81+
* `replicas`: The number of Managed Servers to run in any cluster that does not specify a `replicas` count.
82+
83+
Elements related to overriding WebLogic domain configuration:
84+
* `configOverrides`: The name of the config map for optional WebLogic configuration overrides.
85+
* `configOverrideSecrets`: A list of names of the secrets for optional WebLogic configuration overrides.
86+
87+
Elements related to Kubernetes pod and service generation:
88+
* `serverPod`: Configuration affecting server pods.
89+
* `serverService`: Customization affecting ClusterIP Kubernetes services for WebLogic Server instances.
90+
91+
Sub-sections related to the Administration Server, specific clusters or specific Managed Servers:
92+
* `adminServer`: Configuration for the Administration Server.
93+
* `clusters`: Configuration for specific clusters.
94+
* `managedServers`: Configuration for specific Managed Servers.
95+
96+
The elements `serverStartPolicy`, `serverStartState`, `serverPod` and `serverService` are repeated under `adminServer` and under each entry of `clusters` or `managedServers`. The values directly under `spec` set the defaults for the entire domain. The values under a specific entry under `clusters` set the defaults for cluster members of that cluster. The values under `adminServer` or an entry under `managedServers` set the values for that specific server. Values from the domain scope and values from the cluster (for cluster members) are merged with or overridden by the setting for the specific server depending on the element. See the [startup and shutdown](domain-lifecycle/startup.md) documentation for details about `serverStartPolicy` combination.
97+
98+
### Pod generation
99+
100+
The operator creates a pod for each running WebLogic Server instance. This pod will have a container based on the Docker image specified by the `image` field. Additional pod or container content can be specified using the elements under `serverPod`. This includes Kubernetes labels and annotations, additional volumes on the pod or volume mounts on the container, [resource requirements](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/) or [security context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/).
101+
102+
Prior to creating a pod, the operator replaces variable references allowing the pod content to be templates. The format of these variable references is `$(VARIABLE_NAME)` where *VARIABLE_NAME* is one of the variable names available in the container for the WebLogic Server instance. The default set of environment variables includes:
103+
* DOMAIN_NAME: The WebLogic domain name
104+
* DOMAIN_UID: The domain unique identifier
105+
* DOMAIN_HOME: The domain home location as a file system path within the container
106+
* SERVER_NAME: The WebLogic Server name
107+
* CLUSTER_NAME: The WebLogic cluster name, if this is a cluster member
108+
* LOG_HOME: The WebLogic log location as a file system path within the container

integration-tests/USECASES.MD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,7 @@ Configuration Overrides Usecases
144144
| Upgrade 2.1 operator to develop | Upgrade the 2.1 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows latest version |
145145
| Upgrade 2.2.0 operator to develop | Upgrade the 2.2.0 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows latest version |
146146
| Upgrade 2.2.1 operator to develop | Upgrade the 2.2.1 operator running a Weblogic domain to develop version of the Operator and verify apiVersion of the domain CRD shows latest version |
147+
148+
| Pod Templates | Use Case |
149+
| --- | --- |
150+
| Using pod templates/variables | Use DOMAIN_UID, DOMAIN_NAME, DOMAIN_HOME, SERVER_NAME, LOG_HOME variables at domain level and CLUSTER_NAME at cluster level. Bring up the domain and make sure domain started successfully when pod templates are used |

integration-tests/src/test/java/oracle/kubernetes/operator/BaseTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.logging.SimpleFormatter;
1515
import javax.jms.Connection;
1616
import javax.jms.ConnectionFactory;
17+
1718
import oracle.kubernetes.operator.utils.Domain;
1819
import oracle.kubernetes.operator.utils.ExecCommand;
1920
import oracle.kubernetes.operator.utils.ExecResult;

integration-tests/src/test/java/oracle/kubernetes/operator/ItElasticLogging.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ public void testWeblogicLogSearch() throws Exception {
227227
String testMethodName = new Object() {}.getClass().getEnclosingMethod().getName();
228228
logTestBegin(testMethodName);
229229

230-
Map<String, Object> domainMap = domain.getDomainMap();
231-
String domainUid = domain.getDomainUid();
232-
String adminServerName = (String) domainMap.get("adminServerName");
233-
String adminServerPodName = domainUid + "-" + adminServerName;
234-
String managedServerNameBase = domainMap.get("managedServerNameBase").toString();
235-
String managedServerPodName = domainUid + "-" + managedServerNameBase + "1";
230+
final Map<String, Object> domainMap = domain.getDomainMap();
231+
final String domainUid = domain.getDomainUid();
232+
final String adminServerName = (String) domainMap.get("adminServerName");
233+
final String adminServerPodName = domainUid + "-" + adminServerName;
234+
final String managedServerNameBase = domainMap.get("managedServerNameBase").toString();
235+
final String managedServerPodName = domainUid + "-" + managedServerNameBase + "1";
236236

237237
// Wait 30 seconds for WLS log to be pushed to ELK Stack
238238
logger.info("Wait 30 seconds for WLS log to be pushed to ELK Stack");

integration-tests/src/test/java/oracle/kubernetes/operator/ItMonitoringExporter.java

Lines changed: 33 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44

55
package oracle.kubernetes.operator;
66

7-
import static org.junit.Assert.assertFalse;
8-
import static org.junit.Assert.assertNotNull;
9-
import static org.junit.Assert.assertTrue;
10-
11-
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
12-
import com.gargoylesoftware.htmlunit.WebClient;
13-
import com.gargoylesoftware.htmlunit.html.HtmlFileInput;
14-
import com.gargoylesoftware.htmlunit.html.HtmlForm;
15-
import com.gargoylesoftware.htmlunit.html.HtmlPage;
16-
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
17-
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
187
import java.io.File;
198
import java.io.IOException;
209
import java.nio.charset.Charset;
@@ -26,6 +15,14 @@
2615
import java.util.Map;
2716
import java.util.logging.Level;
2817
import javax.xml.bind.DatatypeConverter;
18+
19+
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
20+
import com.gargoylesoftware.htmlunit.WebClient;
21+
import com.gargoylesoftware.htmlunit.html.HtmlFileInput;
22+
import com.gargoylesoftware.htmlunit.html.HtmlForm;
23+
import com.gargoylesoftware.htmlunit.html.HtmlPage;
24+
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
25+
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
2926
import oracle.kubernetes.operator.utils.Domain;
3027
import oracle.kubernetes.operator.utils.ExecCommand;
3128
import oracle.kubernetes.operator.utils.ExecResult;
@@ -39,6 +36,10 @@
3936
import org.junit.Test;
4037
import org.junit.runners.MethodSorters;
4138

39+
import static org.junit.Assert.assertFalse;
40+
import static org.junit.Assert.assertNotNull;
41+
import static org.junit.Assert.assertTrue;
42+
4243
/** This test is used for testing Monitoring Exporter with Operator(s) . */
4344
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
4445
public class ItMonitoringExporter extends BaseTest {
@@ -168,14 +169,14 @@ private static void gitCloneMonitoringExporter() throws Exception {
168169
}
169170

170171
/**
171-
* Build monitoring exporter app
172+
* Build monitoring exporter app.
172173
*
173174
* @throws Exception if could not run the command successfully to clone from github
174175
*/
175176
private static void buildMonitoringExporter() throws Exception {
176177
String monitoringExporterSrcDir = monitoringExporterDir + "/src";
177178
// target dir for monitoring exporter webapp
178-
String monitoringExporterWar =
179+
final String monitoringExporterWar =
179180
monitoringExporterDir + "/apps/monitoringexporter/wls-exporter.war";
180181

181182
// build monitoring exporter project
@@ -797,7 +798,7 @@ public void test18_ChangeConfigEmptyPass() throws Exception {
797798
}
798799

799800
/**
800-
* Test End to End example from MonitoringExporter github project
801+
* Test End to End example from MonitoringExporter github project.
801802
*
802803
* @throws Exception if test fails
803804
*/
@@ -814,18 +815,18 @@ public void test19_EndToEndViaChart() throws Exception {
814815
}
815816
gitCloneMonitoringExporter();
816817
try {
817-
setupPVMYSQL();
818+
setupPvMysql();
818819
} catch (Exception ex) {
819820
deletePvDir();
820821
throw new RuntimeException("FAILURE: failed to install database ");
821822
}
822-
createWLSImageAndDeploy();
823+
createWlsImageAndDeploy();
823824
installWebHookAndAlertManager();
824825
installPrometheusGrafanaViaChart();
825826
fireAlert();
826827
} finally {
827828
uninstallWebHookPrometheusGrafanaViaChart();
828-
uninstallMySQL();
829+
uninstallMysql();
829830

830831
String crdCmd =
831832
" kubectl delete -f " + monitoringExporterEndToEndDir + "/demo-domains/domain1.yaml";
@@ -857,7 +858,7 @@ private void fireAlert() throws Exception {
857858
String command = "kubectl -n webhook logs " + webhookPod;
858859
ExecResult webhookResult = TestUtils.exec(command);
859860
logger.info(" webhook log " + webhookResult.stdout());
860-
assertTrue( webhookResult.stdout().contains("Some WLS cluster has only one running server for more than 1 minutes"));
861+
assertTrue(webhookResult.stdout().contains("Some WLS cluster has only one running server for more than 1 minutes"));
861862
}
862863

863864
private static String getPodName(String app, String namespace) throws Exception {
@@ -951,11 +952,11 @@ private HtmlPage submitConfigureForm(
951952

952953
/**
953954
* Remove monitoring exporter directory if exists and clone latest from github for monitoring
954-
* exporter code
955+
* exporter code.
955956
*
956957
* @throws Exception if could not run the command successfully to install database
957958
*/
958-
private static void setupPVMYSQL() throws Exception {
959+
private static void setupPvMysql() throws Exception {
959960
String pvDir = monitoringExporterEndToEndDir + "pvDir";
960961
if (new File(pvDir).exists()) {
961962
logger.info(" PV dir already exists , cleaning ");
@@ -1041,11 +1042,11 @@ private static void setupPVMYSQL() throws Exception {
10411042
}
10421043

10431044
/**
1044-
* Install wls image tool and update wls pods
1045+
* Install wls image tool and update wls pods.
10451046
*
10461047
* @throws Exception if could not run the command successfully to create WLSImage and deploy
10471048
*/
1048-
private static void createWLSImageAndDeploy() throws Exception {
1049+
private static void createWlsImageAndDeploy() throws Exception {
10491050
operator1 = TestUtils.createOperator(OPERATOR1_YAML);
10501051

10511052
String command =
@@ -1085,7 +1086,7 @@ private static void createWLSImageAndDeploy() throws Exception {
10851086
}
10861087

10871088
/**
1088-
* Install Prometheus and Grafana using helm chart
1089+
* Install Prometheus and Grafana using helm chart.
10891090
*
10901091
* @throws Exception if could not run the command successfully to install Prometheus and Grafana
10911092
*/
@@ -1111,7 +1112,8 @@ private static void installPrometheusGrafanaViaChart() throws Exception {
11111112
crdCmd = "kubectl apply -f " + monitoringExporterEndToEndDir + "/grafana/persistence.yaml";
11121113
TestUtils.exec(crdCmd);
11131114
crdCmd =
1114-
"kubectl --namespace monitoring create secret generic grafana-secret --from-literal=username=admin --from-literal=password=12345678";
1115+
"kubectl --namespace monitoring create secret generic grafana-secret"
1116+
+ " --from-literal=username=admin --from-literal=password=12345678";
11151117
TestUtils.exec(crdCmd);
11161118
logger.info("calling helm install for grafana");
11171119
crdCmd =
@@ -1144,7 +1146,7 @@ private static void installPrometheusGrafanaViaChart() throws Exception {
11441146
}
11451147

11461148
/**
1147-
* Install Prometheus and Grafana using helm chart
1149+
* Install Prometheus and Grafana using helm chart.
11481150
*
11491151
* @throws Exception if could not run the command successfully to install webhook and alert manager
11501152
*/
@@ -1167,7 +1169,7 @@ private static void installWebHookAndAlertManager() throws Exception {
11671169
}
11681170

11691171
/**
1170-
* Uninstall Prometheus and Grafana using helm chart
1172+
* Uninstall Prometheus and Grafana using helm chart.
11711173
*
11721174
* @throws Exception if could not run the command successfully to uninstall deployments
11731175
*/
@@ -1204,11 +1206,11 @@ private static void uninstallWebHookPrometheusGrafanaViaChart() throws Exception
12041206
}
12051207

12061208
/**
1207-
* Unnstall MYSQL
1209+
* Uninstall MYSQL.
12081210
*
12091211
* @throws Exception if could not run the command successfully to uninstall MySQL
12101212
*/
1211-
private static void uninstallMySQL() throws Exception {
1213+
private static void uninstallMysql() throws Exception {
12121214
String monitoringExporterEndToEndDir =
12131215
monitoringExporterDir + "/src/samples/kubernetes/end2end/";
12141216
// unnstall mysql
@@ -1223,7 +1225,7 @@ private static void uninstallMySQL() throws Exception {
12231225
}
12241226

12251227
/**
1226-
* Delete PvDir via docker
1228+
* Delete PvDir via docker.
12271229
*
12281230
* @throws Exception if could not run the command successfully to delete PV
12291231
*/
@@ -1243,7 +1245,7 @@ private static void deletePvDir() throws Exception {
12431245
}
12441246

12451247
/**
1246-
* A utility method to sed files
1248+
* A utility method to sed files.
12471249
*
12481250
* @throws IOException when copying files from source location to staging area fails
12491251
*/
@@ -1259,28 +1261,7 @@ private static void replaceStringInFile(String filePath, String oldValue, String
12591261
}
12601262

12611263
/**
1262-
* A utility method to copy Cross Namespaces RBAC yaml template file replacing the DOMAIN_NS,
1263-
* OPERATOR_NS
1264-
*
1265-
* @throws IOException when copying files from source location to staging area fails
1266-
*/
1267-
private static void createCrossNSRBACFile(String domainNS, String operatorNS) throws IOException {
1268-
String samplesDir = monitoringExporterDir + "/src/samples/kubernetes/deployments/";
1269-
Path src = Paths.get(samplesDir + "/crossnsrbac.yaml");
1270-
Path dst = Paths.get(samplesDir + "/crossnsrbac_" + domainNS + "_" + operatorNS + ".yaml");
1271-
if (!dst.toFile().exists()) {
1272-
logger.log(Level.INFO, "Copying {0}", src.toString());
1273-
Charset charset = StandardCharsets.UTF_8;
1274-
String content = new String(Files.readAllBytes(src), charset);
1275-
content = content.replaceAll("weblogic-domain", domainNS);
1276-
content = content.replaceAll("weblogic-operator", operatorNS);
1277-
logger.log(Level.INFO, "to {0}", dst.toString());
1278-
Files.write(dst, content.getBytes(charset));
1279-
}
1280-
}
1281-
1282-
/**
1283-
* call operator to scale to specified number of replicas
1264+
* call operator to scale to specified number of replicas.
12841265
*
12851266
* @param replicas - number of managed servers
12861267
* @throws Exception if scaling fails

0 commit comments

Comments
 (0)