You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -10,44 +10,81 @@ This document describes approaches for scaling WebLogic clusters in a Kubernetes
10
10
11
11
{{< table_of_contents >}}
12
12
13
-
####Overview
13
+
### Overview
14
14
15
-
WebLogic Server supports two types of clustering configurations, configured and dynamic. Configured clusters are created by defining each individual Managed Server instance. In dynamic clusters, the Managed Server configurations are generated from a single, shared template. With dynamic clusters, when additional server capacity is needed, new server instances can be added to the cluster without having to configure them individually. Also, unlike configured clusters, scaling up of dynamic clusters is not restricted to the set of servers defined in the cluster but can be increased based on runtime demands. For more information on how to create, configure, and use dynamic clusters in WebLogic Server, see [Dynamic Clusters](https://docs.oracle.com/en/middleware/standalone/weblogic-server/14.1.1.0/clust/dynamic_clusters.html#GUID-DA7F7FAD-49AA-4F3D-8A05-0D9921B96971).
15
+
WebLogic Server supports two types of clustering configurations, configured and dynamic. Configured clusters are created by defining each individual Managed Server instance. In dynamic clusters, the Managed Server configurations are generated from a single, shared template. With dynamic clusters, when additional server capacity is needed, new server instances can be added to the cluster without having to configure them individually. Also, unlike configured clusters, scaling up of dynamic clusters is not restricted to the set of servers defined in the cluster but can be increased based on runtime demands. For more information on how to create, configure, and use dynamic clusters in WebLogic Server, see [Dynamic Clusters](https://docs.oracle.com/en/middleware/standalone/weblogic-server/14.1.1.0/clust/dynamic_clusters.html#GUID-DA7F7FAD-49AA-4F3D-8A05-0D9921B96971).
16
16
17
-
For more in-depth information on support for scaling WebLogic clusters in Kubernetes, see [WebLogic Dynamic Clusters on Kubernetes](https://blogs.oracle.com/weblogicserver/weblogic-dynamic-clusters-on-kubernetes).
17
+
WebLogic Kubernetes Operator 4.0 introduces a new custom resource, `Cluster`. A [Cluster resource]({{< relref "/managing-domains/domain-resource.md" >}}) references an individual WebLogic cluster and its configuration. It also controls how many member servers are running, along with potentially any additional Kubernetes resources that are specific to that WebLogic cluster. Because the Cluster resource enables the Kubernetes[Scale subresource](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#scale-subresource), the `kubectl scale` command and the [Kubernetes Horizontal Pod Autoscaler (HPA)](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) are fully supported for scaling individual WebLogic clusters.
18
18
19
19
The operator provides several ways to initiate scaling of WebLogic clusters, including:
20
20
21
-
*[On-demand, updating the Domain directly (using `kubectl`)](#on-demand-updating-the-domain-directly).
22
-
*[Calling the operator's REST scale API, for example, from `curl`](#calling-the-operators-rest-scale-api).
23
-
*[Using a WLDF policy rule and script action to call the operator's REST scale API](#using-a-wldf-policy-rule-and-script-action-to-call-the-operators-rest-scale-api).
24
-
*[Using a Prometheus alert action to call the operator's REST scale API](#using-a-prometheus-alert-action-to-call-the-operators-rest-scale-api).
21
+
*[`kubectl` CLI commands](#kubectl-cli-commands)
22
+
*[On-demand, updating the Cluster or Domain directly](#on-demand-updating-the-cluster-or-domain-directly) (using `kubectl`)
*[Calling the operator's REST scale API, for example, from `curl`](#calling-the-operators-rest-scale-api)
25
+
*[Kubernetes Horizontal Pod Autoscalar (HPA)](#kubernetes-horizontal-pod-autoscalar-hpa)
26
+
*[Using a WLDF policy rule and script action to call the operator's REST scale API](#using-a-wldf-policy-rule-and-script-action-to-call-the-operators-rest-scale-api)
27
+
*[Using a Prometheus alert action to call the operator's REST scale API](#using-a-prometheus-alert-action-to-call-the-operators-rest-scale-api)
25
28
26
-
#### On-demand, updating the Domain directly
27
-
The easiest way to scale a WebLogic cluster in Kubernetes is to simply edit the `replicas` field of a Domain. This can be done by using `kubectl`. More specifically, you can modify the Domain directly by using the `kubectl edit` command. For example:
29
+
### `kubectl` CLI commands
30
+
Use the Kubernetes command-line tool, `kubectl`, to manually scale WebLogic clusters with the following commands:
31
+
32
+
*`scale` - Set a new size for a resource.
33
+
*`patch` - Update a field or fields of a resource using a strategic merge patch.
34
+
35
+
#### `kubectl scale` command
36
+
You can scale an individual WebLogic cluster directly using the `kubectl scale` command. For example, the following command sets `.spec.replicas` of the Cluster resource `cluster-1` to `5`:
28
37
```shell
29
-
$ kubectl edit domain domain1 -n [namespace]
38
+
$ kubectl scale --replicas=5 clusters/cluster-1
39
+
clusters "cluster-1" scaled
40
+
41
+
$ kubectl get clusters cluster-1 -o jsonpath='{.spec.replicas}'
42
+
5
43
+
```
44
+
45
+
#### `kubectl patch` command
46
+
Also, you can scale an individual WebLogic cluster directly using the `kubectl patch` command with your patch object inline. For example, the following command sets `.spec.replicas` of the Cluster resource `cluster-1` to `3`:
$ kubectl get clusters cluster-1 -o jsonpath='{.spec.replicas}'
52
+
3
53
+
```
54
+
55
+
### On-demand, updating the Cluster or Domain directly
56
+
You can use on-demand scaling (scaling a cluster manually) by directly updating the `.spec.replicas` field of the Cluster or Domain resources.
57
+
#### Updating the Cluster directly
58
+
To scale an individual WebLogic cluster directly, simply edit the `replicas` field of its associated Cluster resource; you can do this using `kubectl`. More specifically, you can modify the Cluster directly by using the `kubectl edit` command. For example:
59
+
```shell
60
+
$ kubectl edit cluster cluster-1 -n [namespace]
30
61
```
31
-
Here we are editing a Domain named `domain1`. The `kubectl edit` command will open the Domain definition in an editor and allow you to modify the `replicas` value directly. Once committed, the operator will be notified of the change and will immediately attempt to scale the corresponding cluster by reconciling the number of running pods/Managed Server instances with the `replicas` value specification.
62
+
In this command, you are editing a Cluster named `cluster-1`. The `kubectl edit` command opens the Cluster definition in an editor and lets you modify the `replicas` value directly. Once committed, the operator will be notified of the change and will immediately attempt to scale the corresponding cluster by reconciling the number of running pods/Managed Server instances with the `replicas` value specification.
32
63
```yaml
33
64
spec:
34
65
...
35
-
clusters:
36
-
- clusterName: cluster-1
37
-
replicas: 1
66
+
clusterName: cluster-1
67
+
replicas: 1
38
68
...
39
69
```
70
+
#### Updating the Domain directly
71
+
To scale every WebLogic cluster in a domain that does not have a corresponding Cluster resource, or that has a Cluster resource which does not specify a `cluster.spec.replicas` field, modify the `domain.spec.replicas` field using the `kubectl edit` command:
40
72
41
-
Alternatively, you can specify a default `replicas` value for all the clusters. If you do this, then you don't need to list the cluster in the Domain (unless you want to customize another property of the cluster).
73
+
```shell
74
+
$ kubectl edit domain domain1 -n [namespace]
75
+
```
76
+
In this command, you are editing a Domain named `domain1`. The `kubectl edit` command opens the Domain definition in an editor and lets you modify the `replicas` value directly. Once committed, the operator will be notified of the change and will immediately attempt to scale the corresponding cluster or clusters by reconciling the number of running pods/Managed Server instances with the `replicas` value specification.
42
77
```yaml
43
78
spec:
44
79
...
45
80
replicas: 1
46
81
...
47
82
```
48
-
In addition, see the helper scripts in the [Domain lifecycle sample scripts]({{< relref "/managing-domains/domain-lifecycle/startup#domain-lifecycle-sample-scripts" >}}) section.
49
83
50
-
#### Calling the operator's REST scale API
84
+
### Using Domain lifecycle sample scripts
85
+
Beginning in version 3.1.0, the operator provides sample lifecycle scripts. See the helper scripts in the [Domain lifecycle sample scripts]({{< relref "/managing-domains/domain-lifecycle/scripts.md" >}}) section, which you can use for scaling WebLogic clusters.
86
+
87
+
### Calling the operator's REST scale API
51
88
52
89
Scaling up or scaling down a WebLogic cluster provides increased reliability of customer applications as well as optimization of resource usage. In Kubernetes environments, scaling WebLogic clusters involves scaling the number of corresponding Pods in which Managed Server instances are running. Because the operator manages the life cycle of a WebLogic domain, the operator exposes a REST API that allows an authorized actor to request scaling of a WebLogic cluster.
53
90
@@ -56,7 +93,6 @@ The following URL format is used for describing the resources for scaling (up an
@@ -85,7 +121,7 @@ The `replicas` value designates the number of Managed Server instances to scale
85
121
86
122
When you POST to the `/scale` REST endpoint, you must send the following headers:
87
123
88
-
*`X-Requested-By` request value. The value is an arbitrary name such as `MyClient`.
124
+
*`X-Requested-By` request value. The value is an arbitrary name such as `MyClient`.
89
125
*`Authorization: Bearer` request value. The value of the `Bearer` token is the WebLogic domain service account token.
90
126
91
127
For example, when using `curl`:
@@ -112,10 +148,10 @@ rules:
112
148
verbs: ["get", "list", "watch"]
113
149
- apiGroups: ["weblogic.oracle"]
114
150
resources: ["domains"]
115
-
verbs: ["get", "list", "patch", update"]
151
+
verbs: ["get", "list", "patch", "update"]
116
152
---
117
153
```
118
-
#####Operator REST endpoints
154
+
#### Operator REST endpoints
119
155
120
156
The WebLogic Kubernetes Operator can expose both an internal and external REST HTTPS endpoint.
121
157
The internal REST endpoint is only accessible from within the Kubernetes cluster. The external REST endpoint
@@ -128,19 +164,62 @@ Detailed instructions for configuring the external REST endpoint are available [
128
164
Regardless of which endpoint is being invoked, the URL format for scaling is the same.
129
165
{{% /notice %}}
130
166
131
-
#####What does the operator do in response to a scaling request?
167
+
#### What does the operator do in response to a scaling request?
132
168
133
169
When the operator receives a scaling request, it will:
134
170
135
-
* Perform an authentication and authorization check to verify that the specified user is allowed to perform the specified operation on the specified resource.
136
-
* Validate that the specified domain, identified by `domainUID`, exists.
137
-
* Validate that the WebLogic cluster, identified by `clusterName`, exists.
138
-
* Verify that the specified WebLogic cluster has a sufficient number of configured servers or sufficient dynamic cluster size to satisfy the scaling request.
139
-
* Initiate scaling by setting the `replicas` field within the corresponding Domain, which can be done in either:
140
-
* A `cluster` entry, if defined within its cluster list.
141
-
* At the domain level, if not defined in a `cluster` entry.
171
+
* Perform an authentication and authorization check to verify that the specified user is allowed to perform the specified operation on the specified resource.
172
+
* Validate that the specified domain, identified by `domainUID`, exists.
173
+
* Validate that the WebLogic cluster, identified by `clusterName`, exists.
174
+
* Verify that the specified WebLogic cluster has a sufficient number of configured servers or sufficient dynamic cluster size to satisfy the scaling request.
175
+
* Verify that the specified cluster has a corresponding Cluster resource defined or else creates one if necessary.
176
+
* Initiate scaling by setting the `replicas` field within the corresponding Cluster resource.
177
+
178
+
In response to a change in the `replicas` field in the Cluster resource, the operator will increase or decrease the number of Managed Server instance Pods to match the desired replica count.
142
179
143
-
In response to a change to either `replicas` field, in the Domain, the operator will increase or decrease the number of Managed Server instance Pods to match the desired replica count.
180
+
### Supported autoscaling controllers
181
+
While continuing to support automatic scaling of WebLogic clusters with the WebLogic Diagnostic Framework (WLDF) and Prometheus, Operator 4.0 now supports the [Kubernetes Horizontal Pod Autoscaler (HPA)](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/).
182
+
#### Kubernetes Horizontal Pod Autoscalar (HPA)
183
+
Automatic scaling of an individual WebLogic cluster, by the Kubernetes Horizontal Pod Autoscalar, is now supported since the Cluster custom resource has enabled the Kubernetes [/scale subresource](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#scale-subresource/). Autoscaling based on resource metrics requires the installation of the [Kubernetes Metrics Server](https://kubernetes-sigs.github.io/metrics-server/) or another implementation of the resource metrics API. If using Prometheus for monitoring WebLogic Server metrics, then you can use the [Prometheus Adapter](https://github.com/kubernetes-sigs/prometheus-adapter) in place of the [Kubernetes Metrics Server](https://kubernetes-sigs.github.io/metrics-server/).
184
+
185
+
The following step-by-step example illustrates how to configure and run an HPA to scale a WebLogic cluster, `cluster-1`, based on the `cpu utilization` resource metric.
186
+
187
+
1. To illustrate scaling of a WebLogic cluster based on CPU utilization, deploy the Kubernetes Metrics Server to the Kubernetes cluster.
2. Confirm that the Kubernetes Metric Server is running by listing the pods in the `kube-system` namespace.
192
+
```shell
193
+
$ kubectl get po -n kube-system
194
+
```
195
+
{{% notice note %}}
196
+
If the Kubernetes Metric Server does not reach the READY state (for example, `READY 0/1` ) due to `Readiness probe failed: HTTP probe failed with statuscode: 500`, then you may need to install a valid cluster certificate. For testing purposes, you can resolve this issue by downloading the `components.yaml` file and adding the argument `--kubelet-insecure-tls` to the Metrics Server container.
197
+
{{% /notice %}}
198
+
199
+
3. Assuming a WebLogic domain running in the default namespace, use the following command to create an HPA resource targeted at the Cluster resource (`sample-domain1-cluster-1`) that will autoscale WebLogic Server instances from a minimum of `2` cluster members up to `5` cluster members, and the scale up or down will occur when the average CPU is consistently over 50%.
Beginning with Operator 4.0, the `allowReplicasBelowMinDynClusterSize` field has been removed from the Domain resource schema. When scaling down, the minimum allowed replica count must now be configured on the selected autoscaling controller.
206
+
{{% /notice %}}
207
+
208
+
4. Verify the status of the autoscaler and its behavior by inspecting the HPA resource.
209
+
```shell
210
+
$ kubectl get hpa
211
+
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
5. To see the HPA scale up the WebLogic cluster `sample-domain1-cluster-1`, generate a loaded CPU by getting a shell to a running container in one of the cluster member pods and run the following command.
6. By listing the Managed Server pods, you will see the autoscaler increase the replicas on the Cluster resource and the operator respond by starting additional cluster member servers. Conversely, after stopping the load and when the CPU utilization average is consistently under 50%, the autoscalar will scale down the WebLogic cluster by decreasing the replicas value on the Cluster resource.
221
+
222
+
For more in-depth information on the Kubernetes Horizontal Pod Autoscalar, see [Horizontal Pod Autoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/).
144
223
145
224
#### Using a WLDF policy rule and script action to call the operator's REST scale API
146
225
The WebLogic Diagnostics Framework (WLDF) is a suite of services and APIs that collect and surface metrics that provide visibility into server and application performance.
@@ -216,7 +295,6 @@ A more in-depth description and example on using WLDF's Policies and Actions com
216
295
*[Automatic Scaling of WebLogic Clusters on Kubernetes](https://blogs.oracle.com/weblogicserver/automatic-scaling-of-weblogic-clusters-on-kubernetes-v2)
217
296
*[WebLogic Dynamic Clusters on Kubernetes](https://blogs.oracle.com/weblogicserver/weblogic-dynamic-clusters-on-kubernetes)
218
297
219
-
220
298
##### Create ClusterRoleBindings to allow a namespace user to query WLS Kubernetes cluster information
221
299
The script `scalingAction.sh`, specified in the WLDF script action, needs the appropriate RBAC permissions granted for the service account user (in the namespace in which the WebLogic domain is deployed) to query the Kubernetes API server for both configuration and runtime information of the Domain.
222
300
The following is an example YAML file for creating the appropriate Kubernetes ClusterRole bindings:
@@ -236,7 +314,7 @@ rules:
236
314
verbs: ["get", "list", "watch"]
237
315
- apiGroups: ["weblogic.oracle"]
238
316
resources: ["domains"]
239
-
verbs: ["get", "list", "patch", update"]
317
+
verbs: ["get", "list", "patch", "update"]
240
318
---
241
319
#
242
320
# creating role-bindings for cluster role
@@ -280,8 +358,8 @@ In addition to using the WebLogic Diagnostic Framework for automatic scaling of
280
358
you can use a third-party monitoring application like Prometheus. Please read the following blog for
281
359
details about [Using Prometheus to Automatically Scale WebLogic Clusters on Kubernetes](https://blogs.oracle.com/weblogicserver/using-prometheus-to-automatically-scale-weblogic-clusters-on-kubernetes-v5).
282
360
283
-
####Helpful tips
284
-
#####Debugging scalingAction.sh
361
+
### Helpful tips
362
+
#### Debugging scalingAction.sh
285
363
The [`scalingAction.sh`](https://github.com/oracle/weblogic-kubernetes-operator/blob/{{< latestMinorVersion >}}/operator/scripts/scaling/scalingAction.sh) script was designed to be executed within a container of the
286
364
Administration Server Pod because the associated diagnostic module is targeted to the Administration Server.
287
365
@@ -302,7 +380,7 @@ $ cd /u01/oracle/user-projects/domains/domain1/bin/scripts && \
302
380
303
381
A log, `scalingAction.log`, will be generated in the same directory in which the script was executed and can be examined for errors.
304
382
305
-
#####Example on accessing the external REST endpoint
383
+
#### Example on accessing the external REST endpoint
306
384
The easiest way to test scaling using the external REST endpoint is to use a command-line tool like `curl`. Using `curl` to issue
307
385
an HTTPS scale request requires these mandatory header properties:
0 commit comments