Skip to content

Commit e59a9ed

Browse files
authored
Disable REST endpoint by default (#3958)
* Disable REST endpoint by default
1 parent 4db1de0 commit e59a9ed

File tree

23 files changed

+295
-149
lines changed

23 files changed

+295
-149
lines changed

documentation/4.0/content/managing-domains/domain-lifecycle/scaling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ operations on a cluster. These policies monitor one or more types of WebLogic Se
228228
in a policy is met, the policy is triggered, and the corresponding scaling action is executed. The WebLogic Kubernetes Operator project provides a shell script, [`scalingAction.sh`](https://github.com/oracle/weblogic-kubernetes-operator/blob/{{< latestMinorVersion >}}/operator/scripts/scaling/scalingAction.sh),
229229
for use as a Script Action, which illustrates how to issue a request to the operator’s REST endpoint.
230230

231+
{{% notice note %}}
232+
Beginning with operator version 4.0.5, the operator's REST endpoint is disabled by default. Install the operator with the Helm install option `--set "enableRest=true"` to enable the REST endpoint.
233+
{{% /notice %}}
234+
231235
##### Configure automatic scaling of WebLogic clusters in Kubernetes with WLDF
232236
The following steps are provided as a guideline on how to configure a WLDF Policy and Script Action component for issuing scaling requests to the operator's REST endpoint:
233237

documentation/4.0/content/managing-operators/the-rest-api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ or for getting certain aspects of a domain's status (for example, instead of cal
1515
You also can use the REST API as an alternative approach for initiating scaling operations
1616
(instead of using the Kubernetes API or command line to alter a domain resource's `replicas` values).
1717

18+
{{% notice note %}}
19+
Beginning with operator version 4.0.5, the operator's REST endpoint is disabled by default. Install the operator with the Helm install option `--set "enableRest=true"` to enable the REST endpoint.
20+
{{% /notice %}}
21+
1822
### Configure the operator's external REST HTTPS interface
1923

2024
The operator can expose an external REST HTTPS interface which can be accessed from outside the Kubernetes cluster. As with the operator's internal REST interface, the external REST interface requires an SSL/TLS certificate and private key that the operator will use as the identity of the external REST interface.

documentation/4.0/content/managing-operators/using-helm.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,16 @@ The REST interface configuration options are advanced settings for configuring t
493493

494494
For usage information, see the operator [REST Services]({{<relref "/managing-operators/the-rest-api.md">}}).
495495

496+
##### `enableRest`
497+
Determines whether the operator's REST endpoint is enabled.
498+
499+
Beginning with operator version 4.0.5, the operator's REST endpoint is disabled by default.
500+
501+
Defaults to `false`.
502+
496503
##### `externalRestEnabled`
497-
Determines whether the operator's REST interface will be exposed outside the Kubernetes cluster using a node port.
504+
Determines whether the operator's REST interface will be exposed outside the Kubernetes cluster using a node port. This
505+
value is ignored if `enableRest` is not `true`.
498506

499507
See also `externalRestHttpsPort` for customizing the port number.
500508

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItDiagnosticsCompleteAvailableCondition.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2022, 2023, 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.weblogic.kubernetes;
@@ -33,7 +33,7 @@
3333
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
3434
import static oracle.weblogic.kubernetes.actions.TestActions.imageTag;
3535
import static oracle.weblogic.kubernetes.actions.TestActions.patchClusterCustomResource;
36-
import static oracle.weblogic.kubernetes.actions.TestActions.scaleClusterWithRestApi;
36+
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
3737
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
3838
import static oracle.weblogic.kubernetes.assertions.TestAssertions.verifyRollingRestartOccurred;
3939
import static oracle.weblogic.kubernetes.utils.CommonMiiTestUtils.createMiiDomainAndVerify;
@@ -43,8 +43,6 @@
4343
import static oracle.weblogic.kubernetes.utils.DomainUtils.verifyDomainStatusConditionTypeDoesNotExist;
4444
import static oracle.weblogic.kubernetes.utils.ImageUtils.createBaseRepoSecret;
4545
import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry;
46-
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
47-
import static oracle.weblogic.kubernetes.utils.OKDUtils.setTlsTerminationForRoute;
4846
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
4947
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodDoesNotExist;
5048
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodCreationTime;
@@ -107,13 +105,6 @@ public static void initAll(@Namespaces(2) List<String> namespaces) {
107105
installAndVerifyOperator(opNamespace, opServiceAccount, true, 0, domainNamespace1);
108106
externalRestHttpsPort = getServiceNodePort(opNamespace, "external-weblogic-operator-svc");
109107

110-
// This test uses the operator restAPI to scale the domain. To do this in OKD cluster,
111-
// we need to expose the external service as route and set tls termination to passthrough
112-
logger.info("Create a route for the operator external service - only for OKD");
113-
createRouteForOKD("external-weblogic-operator-svc", opNamespace);
114-
// Patch the route just created to set tls termination to passthrough
115-
setTlsTerminationForRoute("external-weblogic-operator-svc", opNamespace);
116-
117108
// create pull secrets for WebLogic image when running in non Kind Kubernetes cluster
118109
// this secret is used only for non-kind cluster
119110
createBaseRepoSecret(domainNamespace1);
@@ -512,7 +503,7 @@ void testCompleteAvailableConditionWithScaleUpDownCluster() {
512503
// scale down the cluster
513504
int newReplicaCount = 1;
514505
assertDoesNotThrow(() ->
515-
scaleClusterWithRestApi(domainUid, cluster1Name, 1, externalRestHttpsPort, opNamespace, opServiceAccount));
506+
scaleCluster(clusterResName, domainNamespace1, 1));
516507

517508
// verify the admin server service exists
518509
checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace1);
@@ -544,7 +535,7 @@ void testCompleteAvailableConditionWithScaleUpDownCluster() {
544535
// scale up the cluster
545536
newReplicaCount = 2;
546537
assertDoesNotThrow(() ->
547-
scaleClusterWithRestApi(domainUid, cluster1Name, 2, externalRestHttpsPort, opNamespace, opServiceAccount));
538+
scaleCluster(clusterResName, domainNamespace1, 2));
548539

549540
// verify the admin server service exists
550541
checkPodReadyAndServiceExists(adminServerPodName, domainUid, domainNamespace1);

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItKubernetesDomainEvents.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
6262
import static oracle.weblogic.kubernetes.actions.TestActions.getServicePort;
6363
import static oracle.weblogic.kubernetes.actions.TestActions.now;
64-
import static oracle.weblogic.kubernetes.actions.TestActions.scaleClusterWithRestApi;
64+
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
6565
import static oracle.weblogic.kubernetes.actions.TestActions.shutdownDomain;
6666
import static oracle.weblogic.kubernetes.actions.impl.Cluster.listClusterCustomResources;
6767
import static oracle.weblogic.kubernetes.actions.impl.Domain.patchDomainCustomResource;
@@ -70,7 +70,6 @@
7070
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResource;
7171
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
7272
import static oracle.weblogic.kubernetes.utils.ClusterUtils.removeReplicasSettingAndVerify;
73-
import static oracle.weblogic.kubernetes.utils.ClusterUtils.scaleCluster;
7473
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodReadyAndServiceExists;
7574
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkServiceExists;
7675
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.getNextFreePort;
@@ -104,8 +103,6 @@
104103
import static oracle.weblogic.kubernetes.utils.K8sEvents.checkDomainFailedEventWithReason;
105104
import static oracle.weblogic.kubernetes.utils.K8sEvents.getDomainEventCount;
106105
import static oracle.weblogic.kubernetes.utils.K8sEvents.getOpGeneratedEventCount;
107-
import static oracle.weblogic.kubernetes.utils.OKDUtils.createRouteForOKD;
108-
import static oracle.weblogic.kubernetes.utils.OKDUtils.setTlsTerminationForRoute;
109106
import static oracle.weblogic.kubernetes.utils.OperatorUtils.installAndVerifyOperator;
110107
import static oracle.weblogic.kubernetes.utils.PatchDomainUtils.patchDomainResource;
111108
import static oracle.weblogic.kubernetes.utils.PersistentVolumeUtils.createPV;
@@ -162,6 +159,7 @@ class ItKubernetesDomainEvents {
162159
static String managedServerPodNamePrefix = domainUid + "-" + managedServerNameBase;
163160
static final int managedServerPort = 8001;
164161
static int replicaCount = 2;
162+
String clusterRes2Name = cluster2Name;
165163
String clusterRes1Name = cluster1Name;
166164

167165
static final String pvName1 = getUniqueName(domainUid + "-pv-");
@@ -219,13 +217,6 @@ public static void initAll(@Namespaces(6) List<String> namespaces) {
219217
domainNamespace4, domainNamespace5);
220218
externalRestHttpsPort = getServiceNodePort(opNamespace, "external-weblogic-operator-svc");
221219

222-
// This test uses the operator restAPI to scale the domain. To do this in OKD cluster,
223-
// we need to expose the external service as route and set tls termination to passthrough
224-
logger.info("Create a route for the operator external service - only for OKD");
225-
String opExternalSvc = createRouteForOKD("external-weblogic-operator-svc", opNamespace);
226-
// Patch the route just created to set tls termination to passthrough
227-
setTlsTerminationForRoute("external-weblogic-operator-svc", opNamespace);
228-
229220
createDomain(domainNamespace3, domainUid, pvName3, pvcName3);
230221
}
231222

@@ -394,8 +385,7 @@ void testK8SEventsMultiClusterEvents() {
394385
createNewCluster();
395386
OffsetDateTime timestamp2 = now();
396387
logger.info("Scale the newly-added cluster");
397-
scaleClusterWithRestApi(domainUid, cluster2Name, 1,
398-
externalRestHttpsPort, opNamespace, opServiceAccount);
388+
scaleCluster(clusterRes2Name, domainNamespace3, 1);
399389
logger.info("verify the Domain_Available event is generated");
400390
checkEvent(opNamespace, domainNamespace3, domainUid,
401391
DOMAIN_AVAILABLE, "Normal", timestamp);

integration-tests/src/test/java/oracle/weblogic/kubernetes/ItManageNameSpace.java

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2020, 2023, 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.weblogic.kubernetes;
@@ -52,7 +52,7 @@
5252
import static oracle.weblogic.kubernetes.actions.TestActions.deleteNamespace;
5353
import static oracle.weblogic.kubernetes.actions.TestActions.deleteSecret;
5454
import static oracle.weblogic.kubernetes.actions.TestActions.getServiceNodePort;
55-
import static oracle.weblogic.kubernetes.actions.TestActions.scaleClusterWithRestApi;
55+
import static oracle.weblogic.kubernetes.actions.TestActions.scaleCluster;
5656
import static oracle.weblogic.kubernetes.actions.TestActions.uninstallOperator;
5757
import static oracle.weblogic.kubernetes.utils.CleanupUtil.deleteNamespacedArtifacts;
5858
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResourceAndAddReferenceToDomain;
@@ -249,13 +249,7 @@ void testNameSpaceManageByRegularExpression() {
249249
//verify domain is started
250250
createSecrets(manageByLabelNS);
251251
assertTrue(createDomainResourceAndVerifyDomainIsRunning(manageByLabelNS,manageByLabelDomainUid));
252-
checkOperatorCanScaleDomain(opNamespaces[1],manageByLabelDomainUid);
253-
254-
//check operator can't manage anymore manageByExp1NS
255-
assertTrue(isOperatorFailedToScaleDomain(opNamespaces[1], manageByExpDomain1Uid,
256-
manageByExp1NS), "Operator can still manage domain "
257-
+ manageByExp1NS + " in the namespace " + manageByExp1NS);
258-
252+
checkOperatorCanScaleDomain(manageByLabelNS, manageByLabelDomainUid);
259253
}
260254

261255
/**
@@ -299,7 +293,7 @@ void testNameSpaceManagedByLabelSelector() {
299293
"Failed to create domain CRD or "
300294
+ "verify that domain " + domainsUid[1]
301295
+ " is running in namespace " + domainNamespaces[1]);
302-
checkOperatorCanScaleDomain(opNamespaces[0], domainsUid[1]);
296+
checkOperatorCanScaleDomain(domainNamespaces[1], domainsUid[1]);
303297

304298
//check that with specific Selector default namespace is not under operator management
305299
checkDomainNotStartedInDefaultNS();
@@ -325,11 +319,7 @@ void testNameSpaceManagedByLabelSelector() {
325319
//verify domain is started in namespace with name starting with weblogic* and operator can scale it.
326320
createSecrets(manageByExpDomainNS);
327321
assertTrue(createDomainResourceAndVerifyDomainIsRunning(manageByExpDomainNS,manageByExpDomainUid));
328-
checkOperatorCanScaleDomain(opNamespaces[0],manageByExpDomainUid);
329-
//verify operator can't manage anymore domain running in the namespace with label
330-
assertTrue(isOperatorFailedToScaleDomain(opNamespaces[0], domainsUid[0], domainNamespaces[0]),
331-
"Operator can still manage domain "
332-
+ domainsUid[0] + " in the namespace " + domainNamespaces[0]);
322+
checkOperatorCanScaleDomain(manageByExpDomainNS, manageByExpDomainUid);
333323

334324
checkUpgradeFailedToAddNSManagedByAnotherOperator();
335325
}
@@ -374,7 +364,7 @@ void testNameSpaceWithOperatorRbacFalse() {
374364

375365
assertTrue(upgradeAndVerifyOperator(opNamespaces[3], opParams));
376366
assertTrue(createDomainResourceAndVerifyDomainIsRunning(manageByLabelDomainNS, manageByLabelDomainUid));
377-
checkOperatorCanScaleDomain(opNamespaces[3], manageByLabelDomainUid);
367+
checkOperatorCanScaleDomain(manageByLabelDomainNS, manageByLabelDomainUid);
378368
}
379369

380370
private void checkUpgradeFailedToAddNSManagedByAnotherOperator() {
@@ -411,7 +401,7 @@ private HelmParams installAndVerifyOperatorCanManageDomainBySelector(Map<String,
411401
createSecrets(domainNS);
412402
assertTrue(createDomainResourceAndVerifyDomainIsRunning(domainNS, domainUid),
413403
"can't start or verify domain in namespace " + domainNS);
414-
checkOperatorCanScaleDomain(opNamespace, domainUid);
404+
checkOperatorCanScaleDomain(domainNS, domainUid);
415405
}
416406
);
417407
if (domainNamespacesValue != null) {
@@ -429,15 +419,13 @@ private HelmParams installAndVerifyOperatorCanManageDomainBySelector(Map<String,
429419
return opHelmParam;
430420
}
431421

432-
private boolean isOperatorFailedToScaleDomain(String opNamespace, String domainUid, String domainNamespace) {
422+
private boolean isOperatorFailedToScaleDomain(String domainUid, String domainNamespace) {
433423
try {
434424
//check operator can't manage domainNamespace by trying to scale domain
435-
int externalRestHttpsPort = getServiceNodePort(opNamespace, "external-weblogic-operator-svc");
436425
String managedServerPodNamePrefix = domainUid + "-managed-server";
437-
String opServiceAccount = OPERATOR_RELEASE_NAME + "-sa";
438426
scaleAndVerifyCluster("cluster-1", domainUid, domainNamespace,
439427
managedServerPodNamePrefix, 2, 1,
440-
true, externalRestHttpsPort, opNamespace, opServiceAccount,
428+
false, 0, null, null,
441429
false, "", "scaleDown", 1, "", "", null, null);
442430
return false;
443431
} catch (TimeoutException ex) {
@@ -454,10 +442,8 @@ private static void setLabelToNamespace(String domainNS, Map<String, String> lab
454442
assertDoesNotThrow(() -> Kubernetes.replaceNamespace(namespaceObject1));
455443
}
456444

457-
private void checkOperatorCanScaleDomain(String opNamespace, String domainUid) {
458-
int externalRestHttpsPort = getServiceNodePort(opNamespace, "external-weblogic-operator-svc");
459-
assertTrue(scaleClusterWithRestApi(domainUid, clusterName, 3,
460-
externalRestHttpsPort, opNamespace, OPERATOR_RELEASE_NAME + "-sa"),
445+
private void checkOperatorCanScaleDomain(String domainNamespace, String domainUid) {
446+
assertTrue(scaleCluster(domainUid + "-" + clusterName, domainNamespace, 3),
461447
"Domain " + domainUid + " scaling operation failed");
462448
}
463449

0 commit comments

Comments
 (0)