diff --git a/OracleWebCenterPortal/kubernetes/README.md b/OracleWebCenterPortal/kubernetes/README.md deleted file mode 100755 index 80153b2a0..000000000 --- a/OracleWebCenterPortal/kubernetes/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Oracle WebCenter Portal on Kubernetes - -This directory provides the open source samples which have several key features to assist you with deploying and managing WebCenter Portal in a Kubernetes environment. You can do the following: - -* Create WebCenter Portal instances in a Kubernetes persistent volume. This persistent volume can reside in an NFS file system or other Kubernetes volume types. -* Start servers based on declarative startup parameters and desired states. -* Expose the WebCenter Portal Services for external access. -* Configure WebCenter Portal for Search. -* Publish WebLogic Kubernetes Operator and WebLogic Server logs into Elasticsearch and interact with them in Kibana. -* Monitor the instance using Prometheus and Grafana - -#### Getting started - -Refer the following documentation link for detailed information about deploying Oracle WebCenter Portal domain on Kubernetes. -[Documentation](https://oracle.github.io/fmw-kubernetes/wcportal-domains/) diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-samples/README.md b/OracleWebCenterPortal/kubernetes/charts/apache-samples/README.md new file mode 100644 index 000000000..dcaab57c7 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-samples/README.md @@ -0,0 +1,8 @@ +# Apache load balancer samples + +The sample package contains two samples that use the [Apache Helm chart](../apache-webtier/README.md). The samples use the Docker image for the Apache HTTP Server with the 12.2.1.3.0 and 12.2.1.4.0 Oracle WebLogic Server Proxy Plugin. See the details in [Apache HTTP Server with Oracle WebLogic Server Proxy Plugin on Docker](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-webtier-apache). + +* [The default sample](default-sample/README.md) uses the built-in configuration in the Docker image. + +* [The custom sample](custom-sample/README.md) demonstrates how to customize the configuration of the Apache HTTP Server with the 12.2.1.3.0 and 12.2.1.4.0 Oracle WebLogic Server Proxy Plugins. + diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/README.md b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/README.md new file mode 100644 index 000000000..c35d2d700 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/README.md @@ -0,0 +1,149 @@ +# Apache load balancer custom sample +In this sample, we will configure the Apache webtier as a load balancer for multiple WebLogic domains using a custom configuration. We will demonstrate how to use the Apache webtier to handle traffic to multiple backend WebLogic domains. + +## 1. Create a namespace +In this sample, both the Apache webtier and WebLogic domain instances are located in the namespace `apache-sample`. +```shell +$ kubectl create namespace apache-sample +``` + +## 2. Create WebLogic domains +We need to prepare some backend domains for load balancing by the Apache webtier. Refer to the [sample](/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/README.md), to create two WebLogic domains under the namespace `apache-sample`. + +The first domain uses the following custom configuration parameters: +- namespace: `apache-sample` +- domainUID: `domain1` +- clusterName: `cluster-1` +- adminServerName: `admin-server` +- adminPort: `7001` +- adminNodePort: `30701` +- managedServerPort: `8001` + +The second domain uses the following custom configuration parameters: +- namespace: `apache-sample` +- domainUID: `domain2` +- clusterName: `cluster-1` +- adminServerName: `admin-server` +- adminPort: `7011` +- adminNodePort: `30702` +- managedServerPort: `8021` + +After the domains are successfully created, deploy the sample web application, `testwebapp.war`, on each domain cluster using the WLS Administration Console. The sample web application is located in the `kubernetes/samples/charts/application` directory. + +## 3. Build the Apache webtier Docker image +Refer to the [sample](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-webtier-apache), to build the Apache webtier Docker image. + +## 4. Provide the custom Apache plugin configuration +In this sample, we will provide a custom Apache plugin configuration to fine tune the behavior of Apache. + +* Create a custom Apache plugin configuration file named `custom_mod_wl_apache.conf`. The file content is similar to below. + +``` +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + + +WebLogicHost ${WEBLOGIC_HOST} +WebLogicPort ${WEBLOGIC_PORT} + + +# Directive for weblogic admin Console deployed on Weblogic Admin Server + +SetHandler weblogic-handler +WebLogicHost domain1-admin-server +WebLogicPort ${WEBLOGIC_PORT} + + +# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION variable +# For example, if the LOCAITON is set to '/weblogic', all applications deployed on the cluster can be accessed via +# http://myhost:myport/weblogic/application_end_url +# where 'myhost' is the IP of the machine that runs the Apache web tier, and +# 'myport' is the port that the Apache web tier is publicly exposed to. +# Note that LOCATION cannot be set to '/' unless this is the only Location module configured. + +WLSRequest On +WebLogicCluster domain1-cluster-cluster-1:8001 +PathTrim /weblogic1 + + +# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION2 variable +# For example, if the LOCAITON2 is set to '/weblogic2', all applications deployed on the cluster can be accessed via +# http://myhost:myport/weblogic2/application_end_url +# where 'myhost' is the IP of the machine that runs the Apache web tier, and +# 'myport' is the port that the Apache webt ier is publicly exposed to. + +WLSRequest On +WebLogicCluster domain2-cluster-cluster-1:8021 +PathTrim /weblogic2 + +``` + +* Create a PV / PVC (pv-claim-name) that can be used to store the `custom_mod_wl_apache.conf`. Refer to the [Sample for creating a PV or PVC](/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/README.md). + +## 5. Prepare your own certificate and private key +In production, Oracle strongly recommends that you provide your own certificates. Run the following commands to generate your own certificate and private key using `openssl`. + +```shell +$ cd kubernetes/samples/charts/apache-samples/custom-sample +$ export VIRTUAL_HOST_NAME=apache-sample-host +$ export SSL_CERT_FILE=apache-sample.crt +$ export SSL_CERT_KEY_FILE=apache-sample.key +$ sh certgen.sh +``` + +## 6. Prepare the input values for the Apache webtier Helm chart +Run the following commands to prepare the input value file for the Apache webtier Helm chart. + +```shell +$ base64 -i ${SSL_CERT_FILE} | tr -d '\n' +$ base64 -i ${SSL_CERT_KEY_FILE} | tr -d '\n' +$ touch input.yaml +``` +Edit the input parameters file, `input.yaml`. The file content is similar to below. + +```yaml +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# Use this to provide your own Apache webtier configuration as needed; simply define this +# Persistence Volume which contains your own custom_mod_wl_apache.conf file. +persistentVolumeClaimName: + +# The VirtualHostName of the Apache HTTP server. It is used to enable custom SSL configuration. +virtualHostName: apache-sample-host + +# The customer supplied certificate to use for Apache webtier SSL configuration. +# The value must be a string containing a base64 encoded certificate. Run following command to get it. +# base64 -i ${SSL_CERT_FILE} | tr -d '\n' +customCert: + +# The customer supplied private key to use for Apache webtier SSL configuration. +# The value must be a string containing a base64 encoded key. Run following command to get it. +# base64 -i ${SSL_KEY_FILE} | tr -d '\n' +customKey: +``` + +## 7. Install the Apache webtier Helm chart +The Apache webtier Helm chart is located in the `kubernetes/samples/charts/apache-webtier` directory. Install the Apache webtier Helm chart to the `apache-sample` namespace with the specified input parameters: + +```shell +$ cd kubernetes/samples/charts +$ helm install my-release --values apache-samples/custom-sample/input.yaml --namespace apache-sample apache-webtier +``` + +## 8. Run the sample application +Now you can send requests to different WebLogic domains with the unique entry point of Apache with different paths. Alternatively, you can access the URLs in a web browser. +```shell +$ curl --silent http://${HOSTNAME}:30305/weblogic1/testwebapp/ +$ curl --silent http://${HOSTNAME}:30305/weblogic2/testwebapp/ +``` +Also, you can use SSL URLs to send requests to different WebLogic domains. Access the SSL URL via the `curl` command or a web browser. +```shell +$ curl -k --silent https://${HOSTNAME}:30443/weblogic1/testwebapp/ +$ curl -k --silent https://${HOSTNAME}:30443/weblogic2/testwebapp/ +``` + +## 9. Uninstall the Apache webtier +```shell +$ helm uninstall my-release --namespace apache-sample +``` diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/certgen.sh b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/certgen.sh new file mode 100644 index 000000000..20dd9fa51 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/certgen.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Since: June, 2018 +# Author: dongbo.xiao@oracle.com +# Description: script to start Apache HTTP Server +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + +# Generated configuration file +CONFIG_FILE="config.txt" + +cat > $CONFIG_FILE <<-EOF +[req] +default_bits = 2048 +prompt = no +default_md = sha256 +req_extensions=v3_req +extensions=v3_req +distinguished_name = dn + +[dn] +C = US +ST = CA +L = Redwood Shores +O = Oracle Corporation +OU = Apache HTTP Server With Plugin +CN = $VIRTUAL_HOST_NAME + +[v3_req] +subjectAltName = @alt_names +[alt_names] +DNS.1 = $VIRTUAL_HOST_NAME +DNS.2 = $VIRTUAL_HOST_NAME.cloud.oracle.com +DNS.3 = *.$VIRTUAL_HOST_NAME +DNS.4 = localhost +EOF + +echo "Generating certs for $VIRTUAL_HOST_NAME" + +# Generate our Private Key, CSR and Certificate +# Use SHA-2 as SHA-1 is unsupported from Jan 1, 2017 + +openssl req -x509 -newkey rsa:2048 -sha256 -nodes -keyout "$SSL_CERT_KEY_FILE" -days 3650 -out "$SSL_CERT_FILE" -config "$CONFIG_FILE" + +# OPTIONAL - write an info to see the details of the generated crt +openssl x509 -noout -fingerprint -text < "$SSL_CERT_FILE" > "$SSL_CERT_FILE.info" +# Protect the key +chmod 400 "$SSL_CERT_KEY_FILE" +chmod 400 "$SSL_CERT_FILE.info" diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/custom_mod_wl_apache.conf b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/custom_mod_wl_apache.conf new file mode 100644 index 000000000..8a2d05f0d --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/custom_mod_wl_apache.conf @@ -0,0 +1,37 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + + +WebLogicHost ${WEBLOGIC_HOST} +WebLogicPort ${WEBLOGIC_PORT} + + +# Directive for weblogic admin Console deployed on Weblogic Admin Server + +SetHandler weblogic-handler +WebLogicHost domain1-admin-server +WebLogicPort ${WEBLOGIC_PORT} + + +# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION variable +# For example, if the LOCAITON is set to '/weblogic', all applications deployed on the cluster can be accessed via +# http://myhost:myport/weblogic/application_end_url +# where 'myhost' is the IP of the machine that runs the Apache web tier, and +# 'myport' is the port that the Apache web tier is publicly exposed to. +# Note that LOCATION cannot be set to '/' unless this is the only Location module configured. + +WLSRequest On +WebLogicCluster domain1-cluster-cluster-1:8001 +PathTrim /weblogic1 + + +# Directive for all application deployed on weblogic cluster with a prepath defined by LOCATION2 variable +# For example, if the LOCAITON2 is set to '/weblogic2', all applications deployed on the cluster can be accessed via +# http://myhost:myport/weblogic2/application_end_url +# where 'myhost' is the IP of the machine that runs the Apache web tier, and +# 'myport' is the port that the Apache webt ier is publicly exposed to. + +WLSRequest On +WebLogicCluster domain2-cluster-cluster-1:8021 +PathTrim /weblogic2 + diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/input.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/input.yaml new file mode 100644 index 000000000..95eaec6e9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-samples/custom-sample/input.yaml @@ -0,0 +1,28 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# Use this to provide your own Apache webtier configuration as needed; simply define the +# Persistence Volume which contains your own custom_mod_wl_apache.conf file and provide the Persistence Volume Claim Name +persistentVolumeClaimName: + +# imagePullSecrets contains an optional list of Kubernetes secrets, that are needed +# to access the registry containing the apache webtier image. +# If no secrets are required, then omit this property. +# +# Example : a secret is needed, and has been stored in 'my-apache-webtier-secret' +# +# imagePullSecrets: +# - name: my-apache-webtier-secret + +# The VirtualHostName of the Apache HTTP server. It is used to enable custom SSL configuration. +virtualHostName: apache-sample-host + +# The customer supplied certificate to use for Apache webtier SSL configuration. +# The value must be a string containing a base64 encoded certificate. Run following command to get it. +# base64 -i ${SSL_CERT_FILE} | tr -d '\n' +customCert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURxakNDQXBJQ0NRQ0w2Q2JwRWZ6QnB6QU5CZ2txaGtpRzl3MEJBUXNGQURDQmxqRUxNQWtHQTFVRUJoTUMKVlZNeEN6QUpCZ05WQkFnTUFrTkJNUmN3RlFZRFZRUUhEQTVTWldSM2IyOWtJRk5vYjNKbGN6RWJNQmtHQTFVRQpDZ3dTVDNKaFkyeGxJRU52Y25CdmNtRjBhVzl1TVNjd0pRWURWUVFMREI1QmNHRmphR1VnU0ZSVVVDQlRaWEoyClpYSWdWMmwwYUNCUWJIVm5hVzR4R3pBWkJnTlZCQU1NRW1Gd1lXTm9aUzF6WVcxd2JHVXRhRzl6ZERBZUZ3MHgKT0RFeE1UUXhOVEF3TURGYUZ3MHlPREV4TVRFeE5UQXdNREZhTUlHV01Rc3dDUVlEVlFRR0V3SlZVekVMTUFrRwpBMVVFQ0F3Q1EwRXhGekFWQmdOVkJBY01EbEpsWkhkdmIyUWdVMmh2Y21Wek1Sc3dHUVlEVlFRS0RCSlBjbUZqCmJHVWdRMjl5Y0c5eVlYUnBiMjR4SnpBbEJnTlZCQXNNSGtGd1lXTm9aU0JJVkZSUUlGTmxjblpsY2lCWGFYUm8KSUZCc2RXZHBiakViTUJrR0ExVUVBd3dTWVhCaFkyaGxMWE5oYlhCc1pTMW9iM04wTUlJQklqQU5CZ2txaGtpRwo5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBeXBVWjEzV3ltcUVnSUZOVTZDa2E0SkFqMXFNemZ4T2FjTklNClVKRE9zZUtqdjNOYmpJb0szQTArcE9lRDNPOXBNcUVxM3F5ZWlCTUtnVEQwREhZNS9HQldjeEUvdUJyWk0rQzgKcnl3RVk5QTl5Y1drZ3h4NUFqSFM1ZnRLMFhpQU9OZWdnUnV0RTBTTnRmbmY3T0FwaStzU0k1RlBzT2V2ZWZGVgoybjJHUDg0bHNDTTZ3Y3FLcXRKeStwOC94VEJKdW1MY2RoL1daYktGTDd5YzFGSzdUNXdPVTB3eS9nZ1lVOUVvCk9tT3M3MENQWmloSkNrc1hrd1d0Q0JISEEwWGJPMXpYM1VZdnRpeGMwb2U3aFltd29zZnlQWU1raC9hL2pWYzEKWkhac25wQXZiWTZrVEoyY1dBa1hyS0srVmc5ZGJrWGVPY0FFTnNHazIvcXFxVGNOV1FJREFRQUJNQTBHQ1NxRwpTSWIzRFFFQkN3VUFBNElCQVFDQXZZNzBHVzBTM1V4d01mUHJGYTZvOFJxS3FNSDlCRE9lZ29zZGc5Nm9QakZnClgzRGJjblU5U0QxTzAyZUhNb0RTRldiNFlsK3dwZk9zUDFKekdQTERQcXV0RWRuVjRsbUJlbG15Q09xb0F4R0gKRW1vZGNUSWVxQXBnVDNEaHR1NW90UW4zZTdGaGNRRHhDelN6SldkUTRJTFh4SExsTVBkeHpRN1NwTzVySERGeAo0eEd6dkNHRkMwSlhBZ2w4dFhvR3dUYkpDR1hxYWV2cUIrNXVLY1NpSUo2M2dhQk1USytjUmF5MkR4L1dwcEdBClZWTnJsTWs4TEVQT1VSN2RZMm0xT3RaU1hCckdib3QwQjNEUG9yRkNpeVF5Q20vd0FYMFk0Z0hiMlNmcitOeFoKQkppb2VXajZ6ZGFvU3dPZkwxd2taWlJjVGtlZlZyZXdVRjZRQ3BCcAotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + +# The customer supplied private key to use for Apache webtier SSL configuration. +# The value must be a string containing a base64 encoded key. Run following command to get it. +# base64 -i ${SSL_KEY_FILE} | tr -d '\n' +customKey: LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2Z0lCQURBTkJna3Foa2lHOXcwQkFRRUZBQVNDQktnd2dnU2tBZ0VBQW9JQkFRREtsUm5YZGJLYW9TQWcKVTFUb0tScmdrQ1BXb3pOL0U1cHcwZ3hRa002eDRxTy9jMXVNaWdyY0RUNms1NFBjNzJreW9TcmVySjZJRXdxQgpNUFFNZGpuOFlGWnpFVCs0R3RrejRMeXZMQVJqMEQzSnhhU0RISGtDTWRMbCswclJlSUE0MTZDQkc2MFRSSTIxCitkL3M0Q21MNnhJamtVK3c1Njk1OFZYYWZZWS96aVd3SXpyQnlvcXEwbkw2bnovRk1FbTZZdHgySDlabHNvVXYKdkp6VVVydFBuQTVUVERMK0NCaFQwU2c2WTZ6dlFJOW1LRWtLU3hlVEJhMElFY2NEUmRzN1hOZmRSaSsyTEZ6UwpoN3VGaWJDaXgvSTlneVNIOXIrTlZ6VmtkbXlla0M5dGpxUk1uWnhZQ1Jlc29yNVdEMTF1UmQ0NXdBUTJ3YVRiCitxcXBOdzFaQWdNQkFBRUNnZ0VCQUtPKzR4VnFHRVN1aWxZMnBVSEd2K2ZWK25IcWxweFh6eFQwWTJuWHNvck0KZzhralNGT1AzUGxEWjJoSmppZE9DUDBZa3B0TWNoUFJPRU4ydXowN2J1RlZTV3RXL09jbUpIeXZZalJCWXdiKwo4b0tlVTd4NmprRTgzcGh3aDJoTGUzRDJzZERKK3hyQTViNjZ5OG9lNHRZcTJ3Mk96aGhUSFY1MnVRdVRQS2xpCjJpSHNYQzIwT1dMSmRuMGU1a0IycTJhV3JJaUJBVzI1Y0JyRDQ5MWFyTDh0emJQOWM4eUUyWUdNM1FKaUFtbkYKNUxZUElzZFdVczJYNEhscWtUM0d6ZEVxNUtzV0pzdjN5QUkxOVJ4eXAwZXd1ditTN3hsRjdIZGlhbnR6ZUp4WAp3MnRWbHpjb1BVQVhoVHIxS0N1UDNCT3BQVXNvMG9oaDNzRFVXamVVWUNVQ2dZRUE3L25QYTE5ckpKUExJOFZiCllhQ2pEKzhTR0FvVWZwSDdRTVFyT2RzR0RkcWRKa2VlNEJ0RDBITUEzL1lLVGFUK0JvRVZmQ2czSWpZVWpmeGcKSkp0VWlJVlcya0RsMU5NY0xXaldINExPaFErQlRGbWcvbFlkc2puMW9FbUJ1Rk1NYWF0ejNGdmZscFRCekg4cwpwMHFyL0hJYTFTbllBckVTUXZUVk9MMVhtcThDZ1lFQTJCd1V6NmpQdVVGR3ZKS3RxWTZVbE9yYm05WXFyYVdDCjlhQ3ZBTDFHZ0Q1U1FEcGRVZnl3MVlWdm9hUU9DWHBOL0Z5UHZCdFF2TzYrbHp0MjVTcmMwZk0weHI3d3ZHRmEKSW5FcmlSOXAvMXdXU01yaWFXZitKaE81NENneFZ0alBXZm1pOVNhc0pqOE1jZVk0cUNCNUVJLzM1cjVaa3lFRQozeEhzcEUxVnVuY0NnWUJLYXBveXZzVTM4NGprRDloMW50M1NIQjN0VEhyc2dSSjhGQmtmZU5jWXhybEMzS1RjCjlEZUVWWlZvM2lCMTBYdGd3dmpKcHFMcVBnRUR3c2FCczVWMFBIMGhjMHlTUWVFVUI5V1dzZmFlOXA3dThVQm0KZm9mNDg5WkNuV2pYb3hGUFYzYTNWOW92RlBSQUdSUGMwT0FpaWJQZWRIcGk0MHc1YlRrTnZsR0RTd0tCZ1FESApubWk2eUR2WDZ5dmowN2tGL2VYUkNIK0NHdm1oSEZremVoRXNwYWtSbkg5dFJId2UxMEtnZUhqODNnVDVURGZzCis3THBGbklsa29JS1A2czdVN1JWV2tsTnErSENvRW9adGw5NGNjUC9WSmhnOU1iZWhtaUQwNFRHUVZvUjFvTHgKb1YyZEJQUFBBRDRHbDVtTjh6RGcwNXN4VUhKOUxPckxBa3VNR01NdlVRS0JnQ2RUUGgwVHRwODNUUVZFZnR3bwpuSGVuSEQzMkhrZkR0MTV4Wk84NVZGcTlONVg2MjB2amZKNkNyVnloS1RISllUREs1N2owQ3Z2STBFTksxNytpCi9yaXgwVlFNMTBIMFFuTkZlb0pmS0VITHhXb2czSHVBSVZxTEg4NmJwcytmb25nOCtuMGgvbk5NZUZNYjdSNUMKdmFHNEVkc0VHV0hZS2FiL2lzRlowUVU0Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-samples/default-sample/README.md b/OracleWebCenterPortal/kubernetes/charts/apache-samples/default-sample/README.md new file mode 100644 index 000000000..806bab5c9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-samples/default-sample/README.md @@ -0,0 +1,39 @@ +# Apache load balancer default sample +In this sample, we will configure the Apache webtier as a load balancer for a WebLogic domain using the default configuration. We will demonstrate how to use the Apache webtier to handle traffic to a backend WebLogic domain. + +## 1. Create a WebLogic domain +We need to prepare a backend domain for load balancing by the Apache webtier. Refer to the [sample](/kubernetes/samples/scripts/create-weblogic-domain/domain-home-on-pv/README.md), to create a WebLogic domain. Keep the default values for the following configuration parameters: +- namespace: `default` +- domainUID: `domain1` +- clusterName: `cluster-1` +- adminServerName: `admin-server` +- adminPort: `7001` +- managedServerPort: `8001` + +After the domain is successfully created, deploy the sample web application, `testwebapp.war`, on the domain cluster using the WLS Administration Console. The sample web application is located in the `kubernetes/samples/charts/application` directory. + +## 2. Build the Apache webtier Docker image +Refer to the [sample](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-webtier-apache), to build the Apache webtier Docker image. + +## 3. Install the Apache webtier with a Helm chart +The Apache webtier Helm chart [is located here](../../apache-webtier/README.md). +Install the Apache webtier Helm chart into the default namespace with the default settings: +```shell +$ cd kubernetes/samples/charts +$ helm install my-release apache-webtier +``` + +## 4. Run the sample application +Now you can send request to the WebLogic domain with the unique entry point of Apache. Alternatively, you can access the URL in a web browser. +```shell +$ curl --silent http://${HOSTNAME}:30305/weblogic/testwebapp/ +``` +You can also use an SSL URL to send requests to the WebLogic domain. Access the SSL URL via the `curl` command or a web browser. +```shell +$ curl -k --silent https://${HOSTNAME}:30443/weblogic/testwebapp/ +``` + +## 5. Uninstall the Apache webtier +```shell +$ helm uninstall my-release +``` diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/Chart.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/Chart.yaml new file mode 100644 index 000000000..413b8ba2d --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/Chart.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +apiVersion: v1 +name: apache-webtier +version: 1.0.0 +appVersion: 12.2.1.3 +description: Chart for Apache HTTP Server +keywords: +- apache +- http +- https +- load balance +- proxy +home: https://httpd.apache.org +sources: +- https://github.com/oracle/weblogic-kubernetes-operator/tree/master/kubernetes/samples/charts/apache-webtier +maintainers: +- name: Oracle +engine: gotpl diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/README.md b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/README.md new file mode 100644 index 000000000..2be875dd3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/README.md @@ -0,0 +1,92 @@ +# Apache webtier Helm chart + +This Helm chart bootstraps an Apache HTTP Server deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +The chart depends on the Docker image for the Apache HTTP Server with Oracle WebLogic Server Proxy Plugin (supported versions 12.2.1.3.0 and 12.2.1.4.0). See the details in [Apache HTTP Server with Oracle WebLogic Server Proxy Plugin on Docker](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-webtier-apache). + +## Prerequisites + +You will need to build a Docker image with the Apache webtier in it using the sample provided [here](https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-webtier-apache) +in order to use this load balancer. + +## Installing the Chart +To install the chart with the release name `my-release`: +```shell +$ helm install my-release apache-webtier +``` +The command deploys the Apache HTTP Server on the Kubernetes cluster with the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete `my-release`: + +```shell +$ helm uninstall my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The following table lists the configurable parameters of the Apache webtier chart and their default values. + + +| Parameter | Description | Default | +| -----------------------------------| ------------------------------------------------------------- | ----------------------| +| `image` | Apache webtier Docker image | `oracle/apache:12.2.1.3` | +| `imagePullPolicy` | Image pull policy for the Apache webtier Docker image | `IfNotPresent` | +| `imagePullSecrets` | Image pull Secrets required to access the registry containing the Apache webtier Docker image| ``| +| `persistentVolumeClaimName` | Persistence Volume Claim name Apache webtier | `` | +| `createRBAC` | Boolean indicating if RBAC resources should be created | `true` | +| `httpNodePort` | Node port to expose for HTTP access | `30305` | +| `httpsNodePort` | Node port to expose for HTTPS access | `30443` | +| `virtualHostName` | The `VirtualHostName` of the Apache HTTP Server | `` | +| `customCert` | The customer supplied certificate | `` | +| `customKey` | The customer supplied private key | `` | +| `domainUID` | Unique ID identifying a domain | `domain1` | +| `clusterName` | Cluster name | `cluster-1` | +| `adminServerName` | Name of the Administration Server | `admin-server` | +| `adminPort` | Port number for Administration Server | `7001` | +| `managedServerPort` | Port number for each Managed Server | `8001` | +| `location` | Prepath for all applications deployed on the WebLogic cluster | `/weblogic` | +| `useNonPriviledgedPorts` | Configuration of Apache webtier on NonPriviledgedPort | `false` | + + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example: + +```shell +$ helm install my-release --set persistentVolumeClaimName=webtier-apache-pvc apache-webtier +``` + +Alternatively, a YAML file that specifies the values for the parameters can be provided while +installing the chart. For example: + +```shell +$ helm install my-release --values values.yaml apache-webtier +``` +## useNonPriviledgedPorts +By default, the chart will install the Apache webtier on PriviledgedPort (port 80). Set the flag `useNonPriviledgedPorts=true` to enable the Apache webtier to listen on port `8080` + + +## RBAC +By default, the chart will install the recommended RBAC roles and role bindings. + +Set the flag `--authorization-mode=RBAC` on the API server. See the following document for how to enable [RBAC](https://kubernetes.io/docs/reference/access-authn-authz/rbac/). + +To determine if your cluster supports RBAC, run the following command: + +```shell +$ kubectl api-versions | grep rbac +``` + +If the output contains "beta", you may install the chart with RBAC enabled. + +### Disable RBAC role/rolebinding creation + +To disable the creation of RBAC resources (on clusters with RBAC). Do the following: + +```shell +$ helm install my-release apache-webtier --set createRBAC=false +``` diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/_helpers.tpl b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/_helpers.tpl new file mode 100644 index 000000000..c7999d287 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/_helpers.tpl @@ -0,0 +1,25 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "apache.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +*/}} +{{- define "apache.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "apache.serviceAccountName" -}} +{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 -}} +{{- end -}} diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/cluster-role-binding.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/cluster-role-binding.yaml new file mode 100644 index 000000000..188e54d1a --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/cluster-role-binding.yaml @@ -0,0 +1,17 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{ if .Values.createRBAC }} +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ template "apache.fullname" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "apache.fullname" . }} +subjects: +- kind: ServiceAccount + name: {{ template "apache.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} +{{ end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/cluster-role.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/cluster-role.yaml new file mode 100644 index 000000000..449a87664 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/cluster-role.yaml @@ -0,0 +1,29 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{ if .Values.createRBAC }} +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ template "apache.fullname" . }} +rules: + - apiGroups: + - "" + resources: + - pods + - services + - endpoints + - secrets + verbs: + - get + - list + - watch + - apiGroups: + - extensions + resources: + - ingresses + verbs: + - get + - list + - watch +{{ end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/deployment.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/deployment.yaml new file mode 100644 index 000000000..cd7b07ad3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/deployment.yaml @@ -0,0 +1,106 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +kind: Deployment +apiVersion: apps/v1 +metadata: + name: {{ template "apache.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "apache.fullname" . }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "apache.fullname" . }} + template: + metadata: + labels: + app: {{ template "apache.fullname" . }} + spec: + serviceAccountName: {{ template "apache.serviceAccountName" . }} + terminationGracePeriodSeconds: 60 +{{- if or (and (.Values.virtualHostName) (.Values.customCert)) (.Values.persistentVolumeClaimName) }} + volumes: +{{- end }} +{{- if and (.Values.virtualHostName) (.Values.customCert) }} + - name: serving-cert + secret: + defaultMode: 420 + secretName: {{ template "apache.fullname" . }}-cert +{{- end }} +{{- if .Values.persistentVolumeClaimName }} + - name: {{ template "apache.fullname" . }} + persistentVolumeClaim: + claimName: {{ .Values.persistentVolumeClaimName | quote }} +{{- end }} + {{- if .Values.imagePullSecrets }} + imagePullSecrets: + {{ .Values.imagePullSecrets | toYaml }} + {{- end }} + containers: + - name: {{ template "apache.fullname" . }} + image: {{ .Values.image | quote }} + imagePullPolicy: {{ .Values.imagePullPolicy | quote }} +{{- if or (and (.Values.virtualHostName) (.Values.customCert)) (.Values.persistentVolumeClaimName) }} + volumeMounts: +{{- end }} +{{- if and (.Values.virtualHostName) (.Values.customCert) }} + - name: serving-cert + mountPath: "/var/serving-cert" +{{- end }} +{{- if .Values.persistentVolumeClaimName }} + - name: {{ template "apache.fullname" . }} + mountPath: "/config" +{{- end }} +{{- if or (not (.Values.persistentVolumeClaimName)) (.Values.virtualHostName) }} + env: +{{- end }} +{{- if .Values.useNonPriviledgedPorts }} + - name: NonPriviledgedPorts + value: "true" +{{- end }} +{{- if not (.Values.persistentVolumeClaimName) }} + - name: WEBLOGIC_CLUSTER + value: "{{ .Values.domainUID | replace "_" "-" | lower }}-cluster-{{ .Values.clusterName | replace "_" "-" | lower }}:{{ .Values.managedServerPort }}" + - name: LOCATION + value: {{ .Values.location | quote }} + - name: WEBLOGIC_HOST + value: "{{ .Values.domainUID | replace "_" "-" | lower }}-{{ .Values.adminServerName | replace "_" "-" | lower }}" + - name: WEBLOGIC_PORT + value: {{ .Values.adminPort | quote }} +{{- end }} +{{- if .Values.virtualHostName }} + - name: VIRTUAL_HOST_NAME + value: {{ .Values.virtualHostName | quote }} +{{- if .Values.customCert }} + - name: SSL_CERT_FILE + value: "/var/serving-cert/tls.crt" + - name: SSL_CERT_KEY_FILE + value: "/var/serving-cert/tls.key" +{{- end }} +{{- end }} + readinessProbe: + tcpSocket: +{{- if .Values.useNonPriviledgedPorts }} + port: 8080 +{{- else }} + port: 80 +{{- end }} + failureThreshold: 1 + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 2 + livenessProbe: + tcpSocket: +{{- if .Values.useNonPriviledgedPorts }} + port: 8080 +{{- else }} + port: 80 +{{- end }} + failureThreshold: 3 + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 2 diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/secret.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/secret.yaml new file mode 100644 index 000000000..bb716f50b --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/secret.yaml @@ -0,0 +1,14 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{ if .Values.customCert }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "apache.fullname" . }}-cert + namespace: {{ .Release.Namespace | quote }} +type: Opaque +data: + tls.crt: {{ .Values.customCert | quote }} + tls.key: {{ .Values.customKey | quote }} +{{ end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/service-account.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/service-account.yaml new file mode 100644 index 000000000..f76d46aec --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/service-account.yaml @@ -0,0 +1,8 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "apache.serviceAccountName" . }} + namespace: {{ .Release.Namespace | quote }} diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/service.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/service.yaml new file mode 100644 index 000000000..c8b8089eb --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/templates/service.yaml @@ -0,0 +1,28 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +apiVersion: v1 +kind: Service +metadata: + name: {{ template "apache.fullname" . }} + namespace: {{ .Release.Namespace | quote }} +spec: + type: NodePort + selector: + app: {{ template "apache.fullname" . }} + ports: +{{- if .Values.useNonPriviledgedPorts }} + - port: 8080 +{{- else}} + - port: 80 +{{- end }} + nodePort: {{ .Values.httpNodePort }} + name: http +{{- if .Values.virtualHostName }} + - port: 4433 +{{- else }} + - port: 443 +{{- end }} + nodePort: {{ .Values.httpsNodePort }} + name: https + diff --git a/OracleWebCenterPortal/kubernetes/charts/apache-webtier/values.yaml b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/values.yaml new file mode 100644 index 000000000..ee0a8a815 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/apache-webtier/values.yaml @@ -0,0 +1,79 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# Apache webtier docker image +image: "oracle/apache:12.2.1.3" + +# imagePullPolicy specifies the image pull policy for the apache webiter docker image +imagePullPolicy: "IfNotPresent" + +# imagePullSecrets contains an optional list of Kubernetes secrets, that are needed +# to access the registry containing the apache webtier image. +# If no secrets are required, then omit this property. +# +# Example : a secret is needed, and has been stored in 'my-apache-webtier-secret' +# +# imagePullSecrets: +# - name: my-apache-webtier-secret +# +# imagePullSecrets: +# - name: + +# Volume path for Apache webtier. By default, it is empty, which causes the volume +# mount be disabled and, therefore, the built-in Apache plugin config be used. +# Use this to provide your own Apache webtier configuration as needed; simply define this +# path and put your own custom_mod_wl_apache.conf file under this path. +persistentVolumeClaimName: + +# Boolean indicating if RBAC resources should be created +createRBAC: true + +# NodePort to expose for http access +httpNodePort: 30305 + +# NodePort to expose for https access +httpsNodePort: 30443 + +# The VirtualHostName of the Apache HTTP server. It is used to enable custom SSL configuration. +# If it is set, the Apache HTTP Server is configured to listen to port 4433 for SSL traffic. +virtualHostName: + +# The customer supplied certificate to use for Apache webtier SSL configuration. +# The value must be a string containing a base64 encoded certificate. +# If 'virtualHostName' is set, the custom certificate and private key are not provided, +# the default built-in auto-generated sample certificate and private key in the apache image will be used. +# This parameter is ignored if 'virtualHostName' is not set. +customCert: + +# The customer supplied private key to use for Apache webtier SSL configuration. +# The value must be a string containing a base64 encoded key. +# If 'virtualHostName' is set, the custom certificate and private key are not provided, +# the default built-in auto-generated sample certificate and private key in the apache image will be used. +# This parameter is ignored if 'virtualHostName' is not set. +customKey: + +# Unique ID identifying a domain. +# This ID must not contain an underscore ("_"), and must be lowercase and unique across all domains in a Kubernetes cluster. +domainUID: "domain1" + +# Cluster name +clusterName: "cluster-1" + +# Name of the admin server +adminServerName: "admin-server" + +# Port number for admin server +adminPort: 7001 + +# Port number for each managed server +managedServerPort: 8001 + +# Prepath for all application deployed on WebLogic cluster. +# For example, if it is set to '/weblogic', all applications deployed on the cluster can be accessed via +# http://myhost:myport/weblogic/application_end_url +# where 'myhost' is the IP of the machine that runs the Apache web tier, and +# 'myport' is the port that the Apache web tier is publicly exposed to. +location: "/weblogic" + +# Use non privileged port 8080 to listen. If set to false, default privileged port 80 will be used. +useNonPriviledgedPorts: false diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/Chart.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/Chart.yaml old mode 100755 new mode 100644 similarity index 80% rename from OracleWebCenterPortal/kubernetes/ingress-per-domain/Chart.yaml rename to OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/Chart.yaml index b42d4f9fa..dc3981291 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/Chart.yaml +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/Chart.yaml @@ -1,6 +1,6 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - +# apiVersion: v1 appVersion: "1.0" description: A Helm chart to create an Ingress for a WLS domain. diff --git a/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/nginx-ingress-k8s1.19.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/nginx-ingress-k8s1.19.yaml new file mode 100644 index 000000000..ea79521df --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/nginx-ingress-k8s1.19.yaml @@ -0,0 +1,101 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if eq .Values.type "NGINX" }} +{{- if or (eq .Values.sslType "NONSSL") (eq .Values.sslType "SSL") }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Values.wlsDomain.domainUID }}-nginx + namespace: {{ .Release.Namespace }} + annotations: + kubernetes.io/ingress.class: 'nginx' + nginx.ingress.kubernetes.io/proxy-connect-timeout: '{{ .Values.nginx.connectTimeout }}' + nginx.ingress.kubernetes.io/proxy-read-timeout: '{{ .Values.nginx.readTimeout }}' + nginx.ingress.kubernetes.io/proxy-send-timeout: '{{ .Values.nginx.sendTimeout }}' + nginx.ingress.kubernetes.io/affinity: 'cookie' + nginx.ingress.kubernetes.io/session-cookie-name: 'stickyid' + nginx.ingress.kubernetes.io/session-cookie-expires: '{{ .Values.nginx.cookieExpires }}' + nginx.ingress.kubernetes.io/session-cookie-max-age: '{{ .Values.nginx.cookieMaxAge }}' + nginx.ingress.kubernetes.io/ssl-redirect: 'false' + nginx.ingress.kubernetes.io/affinity-mode: 'persistent' +{{- if eq .Values.sslType "SSL" }} + nginx.ingress.kubernetes.io/configuration-snippet: | + more_set_input_headers "X-Forwarded-Proto: https"; + more_set_input_headers "WL-Proxy-SSL: true"; + nginx.ingress.kubernetes.io/ingress.allow-http: 'false' +{{- end }} +spec: + rules: + - host: '{{ .Values.nginx.hostname }}' + http: + paths: + - path: /webcenter + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /console + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.adminServerPort }} + - path: /rsscrawl + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /webcenterhelp + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /rest + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /em + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /wsrp-tools + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} + - path: /portalTools + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} +{{- if eq .Values.sslType "SSL" }} + tls: + - hosts: + - '{{ .Values.nginx.hostname }}' + secretName: {{ .Values.wlsDomain.domainUID }}-tls-cert +{{- end }} + +{{- end }} +{{- end }} +{{- end }} + diff --git a/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/nginx-ingress.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/nginx-ingress.yaml new file mode 100644 index 000000000..41917e342 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/nginx-ingress.yaml @@ -0,0 +1,77 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +{{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if eq .Values.type "NGINX" }} +{{- if or (eq .Values.sslType "NONSSL") (eq .Values.sslType "SSL") }} +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Values.wlsDomain.domainUID }}-nginx + namespace: {{ .Release.Namespace }} + annotations: + kubernetes.io/ingress.class: 'nginx' + nginx.ingress.kubernetes.io/proxy-connect-timeout: '{{ .Values.nginx.connectTimeout }}' + nginx.ingress.kubernetes.io/proxy-read-timeout: '{{ .Values.nginx.readTimeout }}' + nginx.ingress.kubernetes.io/proxy-send-timeout: '{{ .Values.nginx.sendTimeout }}' + nginx.ingress.kubernetes.io/affinity: 'cookie' + nginx.ingress.kubernetes.io/session-cookie-name: 'stickyid' + nginx.ingress.kubernetes.io/session-cookie-expires: '{{ .Values.nginx.cookieExpires }}' + nginx.ingress.kubernetes.io/session-cookie-max-age: '{{ .Values.nginx.cookieMaxAge }}' + nginx.ingress.kubernetes.io/ssl-redirect: 'false' + nginx.ingress.kubernetes.io/affinity-mode: 'persistent' +{{- if eq .Values.sslType "SSL" }} + nginx.ingress.kubernetes.io/configuration-snippet: | + more_set_input_headers "X-Forwarded-Proto: https"; + more_set_input_headers "WL-Proxy-SSL: true"; + nginx.ingress.kubernetes.io/ingress.allow-http: 'false' +{{- end }} +spec: + rules: + - host: '{{ .Values.nginx.hostname }}' + http: + paths: + - path: /webcenter + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /console + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.adminServerPort }} + - path: /rsscrawl + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /webcenterhelp + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /rest + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /em + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /wsrp-tools + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} + - path: /portalTools + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} +{{- if eq .Values.sslType "SSL" }} + tls: + - hosts: + - '{{ .Values.nginx.hostname }}' + secretName: {{ .Values.wlsDomain.domainUID }}-tls-cert +{{- end }} + +{{- end }} +{{- end }} +{{- end }} + diff --git a/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/traefik-ingress-k8s1.19.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/traefik-ingress-k8s1.19.yaml new file mode 100644 index 000000000..1965ccd59 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/traefik-ingress-k8s1.19.yaml @@ -0,0 +1,110 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if eq .Values.type "TRAEFIK" }} +{{- if or (eq .Values.sslType "NONSSL") (eq .Values.sslType "SSL") }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Values.wlsDomain.domainUID }}-traefik + namespace: {{ .Release.Namespace }} + labels: + weblogic.resourceVersion: domain-v2 + annotations: + kubernetes.io/ingress.class: 'traefik' +{{- if eq .Values.sslType "SSL" }} + traefik.ingress.kubernetes.io/router.entrypoints: 'websecure' + traefik.ingress.kubernetes.io/router.tls: 'true' + traefik.ingress.kubernetes.io/router.middlewares: '{{ .Release.Namespace}}-wls-proxy-ssl@kubernetescrd' +{{- end }} +spec: + rules: + - host: '{{ .Values.traefik.hostname }}' + http: + paths: + - path: /webcenter + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /console + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.adminServerPort }} + - path: /rsscrawl + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /webcenterhelp + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /rest + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /em + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /wsrp-tools + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} + - path: /portalTools + pathType: ImplementationSpecific + backend: + service: + name: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + port: + number: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} +{{- if eq .Values.sslType "SSL" }} + tls: + - hosts: + - '{{ .Values.traefik.hostname }}' + secretName: {{ .Values.wlsDomain.domainUID }}-tls-cert +{{- end }} +--- +#Create Traefik Middleware custom resource for SSL Termination +{{- if eq .Values.sslType "SSL" }} +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: wls-proxy-ssl + namespace: {{ .Release.Namespace }} +spec: + headers: + customRequestHeaders: + X-Custom-Request-Header: "" + X-Forwarded-For: "" + WL-Proxy-Client-IP: "" + WL-Proxy-SSL: "" + WL-Proxy-SSL: "true" + sslRedirect: true +{{- end }} + +{{- end }} +{{- end }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/traefik-ingress.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/traefik-ingress.yaml new file mode 100644 index 000000000..3a4df423c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/templates/traefik-ingress.yaml @@ -0,0 +1,87 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +{{- if semverCompare "<1.19-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if eq .Values.type "TRAEFIK" }} +{{- if or (eq .Values.sslType "NONSSL") (eq .Values.sslType "SSL") }} +--- +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ .Values.wlsDomain.domainUID }}-traefik + namespace: {{ .Release.Namespace }} + labels: + weblogic.resourceVersion: domain-v2 + annotations: + kubernetes.io/ingress.class: 'traefik' +{{- if eq .Values.sslType "SSL" }} + traefik.ingress.kubernetes.io/router.entrypoints: 'websecure' + traefik.ingress.kubernetes.io/router.tls: 'true' + traefik.ingress.kubernetes.io/router.middlewares: '{{ .Release.Namespace}}-wls-proxy-ssl@kubernetescrd' +{{- end }} +spec: + rules: + - host: '{{ .Values.traefik.hostname }}' + http: + paths: + - path: /webcenter + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /console + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.adminServerPort }} + - path: /rsscrawl + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /webcenterhelp + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /rest + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /em + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpManagedServerPort }} + - path: /wsrp-tools + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} + - path: /portalTools + backend: + serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.wcpPortletClusterName | lower | replace "_" "-" }}' + servicePort: {{ .Values.wlsDomain.wcpPortletManagedServerPort }} +{{- if eq .Values.sslType "SSL" }} + tls: + - hosts: + - '{{ .Values.traefik.hostname }}' + secretName: {{ .Values.wlsDomain.domainUID }}-tls-cert +{{- end }} +--- +#Create Traefik Middleware custom resource for SSL Termination +{{- if eq .Values.sslType "SSL" }} +apiVersion: traefik.containo.us/v1alpha1 +kind: Middleware +metadata: + name: wls-proxy-ssl + namespace: {{ .Release.Namespace }} +spec: + headers: + customRequestHeaders: + X-Custom-Request-Header: "" + X-Forwarded-For: "" + WL-Proxy-Client-IP: "" + WL-Proxy-SSL: "" + WL-Proxy-SSL: "true" + sslRedirect: true +{{- end }} + +{{- end }} +{{- end }} +{{- end }} + diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/nginx-tls.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/tls/nginx-tls.yaml old mode 100755 new mode 100644 similarity index 89% rename from OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/nginx-tls.yaml rename to OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/tls/nginx-tls.yaml index e34c0bcd9..3024b9349 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/nginx-tls.yaml +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/tls/nginx-tls.yaml @@ -12,7 +12,7 @@ spec: tls: - hosts: - domain1.org - secretName: domain1-tls-cert + secretName: wcp-domain-tls-cert rules: - host: domain1.org http: @@ -20,6 +20,6 @@ spec: - path: backend: serviceName: wcp-domain-cluster-wcp-cluster - servicePort: 8889 + servicePort: 8788 diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/traefik-tls.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/tls/traefik-tls.yaml old mode 100755 new mode 100644 similarity index 96% rename from OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/traefik-tls.yaml rename to OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/tls/traefik-tls.yaml index 96d51a5ab..636b07073 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/traefik-tls.yaml +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/tls/traefik-tls.yaml @@ -13,7 +13,7 @@ spec: - match: HostSNI(`wcp-domain.example.org`) services: - name: wcp-domain-cluster-wcp-cluster - port: 8889 + port: 8788 weight: 3 TerminationDelay: 400 tls: diff --git a/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/values.yaml b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/values.yaml new file mode 100644 index 000000000..9678cc41d --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/ingress-per-domain/values.yaml @@ -0,0 +1,43 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# +# Default values for ingress-per-domain. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +# +# Load balancer type. Supported values are: TRAEFIK, NGINX +type: TRAEFIK + +# Type of Configuration Supported Values are : NONSSL, SSL +sslType: NONSSL + +# domainType Supported values are soa,osb and soaosb. +domainType: wcp + +#WLS domain as backend to the load balancer +wlsDomain: + domainUID: wcp-domain + adminServerName: adminserver + adminServerPort: 7001 + adminServerSSLPort: + wcpClusterName: wcp-cluster + wcpManagedServerPort: 8888 + wcpManagedServerSSLPort: + wcpPortletClusterName: wcportlet-cluster + wcpPortletManagedServerPort: 8889 + wcpPortletManagedServerSSLPort: + +# Host specific values +traefik: + hostname: domain1.org + +# Ngnix specific values +nginx: + connectTimeout: 1800 + readTimeout: 1800 + sendTimeout: 1800 + cookieExpires: 172800 + cookieMaxAge: 172800 + + diff --git a/OracleWebCenterPortal/kubernetes/charts/traefik/values.yaml b/OracleWebCenterPortal/kubernetes/charts/traefik/values.yaml index 3acc04e5a..e94bf24f2 100755 --- a/OracleWebCenterPortal/kubernetes/charts/traefik/values.yaml +++ b/OracleWebCenterPortal/kubernetes/charts/traefik/values.yaml @@ -1,34 +1,52 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. -image: - name: traefik - tag: 2.2.8 - pullPolicy: IfNotPresent -ingressRoute: - dashboard: - enabled: true - annotations: {} - labels: {} -providers: - kubernetesCRD: - enabled: true - kubernetesIngress: - enabled: true -ports: - traefik: - port: 9000 - expose: true - exposedPort: 9000 - protocol: TCP - web: - port: 8000 - expose: true - exposedPort: 30305 - nodePort: 30305 - protocol: TCP - websecure: - port: 8443 - expose: true - exposedPort: 30443 - protocol: TCP - nodePort: 30443 \ No newline at end of file +# +image: + name: traefik + tag: 2.2.8 + pullPolicy: IfNotPresent +ingressRoute: + dashboard: + enabled: true + # Additional ingressRoute annotations (e.g. for kubernetes.io/ingress.class) + annotations: {} + # Additional ingressRoute labels (e.g. for filtering IngressRoute by custom labels) + labels: {} +providers: + kubernetesCRD: + enabled: true + kubernetesIngress: + enabled: true + # IP used for Kubernetes Ingress endpoints +ports: + traefik: + port: 9000 + expose: true + # The exposed port for this service + exposedPort: 9000 + # The port protocol (TCP/UDP) + protocol: TCP + web: + port: 8000 + # hostPort: 8000 + expose: true + exposedPort: 30305 + nodePort: 30305 + # The port protocol (TCP/UDP) + protocol: TCP + # Use nodeport if set. This is useful if you have configured Traefik in a + # LoadBalancer + # nodePort: 32080 + # Port Redirections + # Added in 2.2, you can make permanent redirects via entrypoints. + # https://docs.traefik.io/routing/entrypoints/#redirection + # redirectTo: websecure + websecure: + port: 8443 +# # hostPort: 8443 + expose: true + exposedPort: 30443 + # The port protocol (TCP/UDP) + protocol: TCP + nodePort: 30443 + diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/.helmignore b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/.helmignore new file mode 100644 index 000000000..1397cc19f --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/.helmignore @@ -0,0 +1,12 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +.git/ +.gitignore +*.bak +*.tmp +*.orig +*~ +.project +.idea/ diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/Chart.yaml b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/Chart.yaml new file mode 100644 index 000000000..b5cac770e --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/Chart.yaml @@ -0,0 +1,10 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +apiVersion: v1 +name: weblogic-operator +description: Helm chart for configuring the WebLogic operator. + +type: application +version: 3.3.0 +appVersion: 3.3.0 diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_domain-namespaces.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_domain-namespaces.tpl new file mode 100644 index 000000000..08988c28d --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_domain-namespaces.tpl @@ -0,0 +1,134 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.domainNamespaces" }} +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +{{- $args := include "utils.cloneDictionary" . | fromYaml -}} +{{- $key := .Release.Namespace -}} +{{- $ignore := set $args "domainNamespace" $key -}} +{{- include "operator.operatorRoleBindingNamespace" $args -}} +{{- else if eq (default "List" .domainNamespaceSelectionStrategy) "List" }} +{{- $args := include "utils.cloneDictionary" . | fromYaml -}} +{{- range $key := $args.domainNamespaces -}} +{{- $ignore := set $args "domainNamespace" $key -}} +{{- include "operator.operatorRoleBindingNamespace" $args -}} +{{- end }} +{{- else if eq .domainNamespaceSelectionStrategy "LabelSelector" }} +{{- $args := include "utils.cloneDictionary" . | fromYaml -}} +{{- /* + Split terms on commas not contained in parentheses. Unfortunately, the regular expression + support included with Helm templates does not include lookarounds. +*/ -}} +{{- $working := dict "rejected" (list) "terms" (list $args.domainNamespaceLabelSelector) }} +{{- if contains "," $args.domainNamespaceLabelSelector }} +{{- $cs := regexSplit "," $args.domainNamespaceLabelSelector -1 }} +{{- $ignore := set $working "st" (list) }} +{{- $ignore := set $working "item" "" }} +{{- range $c := $cs }} +{{- if and (contains "(" $c) (not (contains ")" $c)) }} +{{- $ignore := set $working "item" (print $working.item $c) }} +{{- else if not (eq $working.item "") }} +{{- $ignore := set $working "st" (append $working.st (print $working.item "," $c)) }} +{{- if contains ")" $c }} +{{- $ignore := set $working "item" "" }} +{{- end }} +{{- else }} +{{- $ignore := set $working "st" (append $working.st $c) }} +{{- end }} +{{- end }} +{{- $ignore := set $working "terms" $working.st }} +{{- end }} +{{- $namespaces := (lookup "v1" "Namespace" "" "").items }} +{{- range $t := $working.terms }} +{{- $term := trim $t }} +{{- range $index, $namespace := $namespaces }} +{{- /* + Label selector patterns + Equality-based: =, ==, != + Set-based: x in (a, b), x notin (a, b) + Existence: x, !x +*/ -}} +{{- if not $namespace.metadata.labels }} +{{- $ignore := set $namespace.metadata "labels" (dict) }} +{{- end }} +{{- if hasPrefix "!" $term }} +{{- if hasKey $namespace.metadata.labels (trimPrefix "!" $term) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- else if contains "!=" $term }} +{{- $split := regexSplit "!=" $term 2 }} +{{- $key := nospace (first $split) }} +{{- if hasKey $namespace.metadata.labels $key }} +{{- if eq (last $split | nospace) (get $namespace.metadata.labels $key) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- end }} +{{- else if contains "==" $term }} +{{- $split := regexSplit "==" $term 2 }} +{{- $key := nospace (first $split) }} +{{- if or (not (hasKey $namespace.metadata.labels $key)) (not (eq (last $split | nospace) (get $namespace.metadata.labels $key))) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- else if contains "=" $term }} +{{- $split := regexSplit "=" $term 2 }} +{{- $key := nospace (first $split) }} +{{- if or (not (hasKey $namespace.metadata.labels $key)) (not (eq (last $split | nospace) (get $namespace.metadata.labels $key))) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- else if contains " notin " $term }} +{{- $split := regexSplit " notin " $term 2 }} +{{- $key := nospace (first $split) }} +{{- if hasKey $namespace.metadata.labels $key }} +{{- $second := nospace (last $split) }} +{{- $parenContents := substr 1 (int (sub (len $second) 1)) $second }} +{{- $values := regexSplit "," $parenContents -1 }} +{{- range $value := $values }} +{{- if eq ($value | nospace) (get $namespace.metadata.labels $key) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- end }} +{{- end }} +{{- else if contains " in " $term }} +{{- $split := regexSplit " in " $term 2 }} +{{- $key := nospace (first $split) }} +{{- if not (hasKey $namespace.metadata.labels $key) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- else }} +{{- $second := nospace (last $split) }} +{{- $parenContents := substr 1 (int (sub (len $second) 1)) $second }} +{{- $values := regexSplit "," $parenContents -1 }} +{{- $ignore := set $working "found" false }} +{{- range $value := $values }} +{{- if eq ($value | nospace) (get $namespace.metadata.labels $key) }} +{{- $ignore := set $working "found" true }} +{{- end }} +{{- end }} +{{- if not $working.found }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- end }} +{{- else }} +{{- if not (hasKey $namespace.metadata.labels $term) }} +{{- $ignore := set $working "rejected" (append $working.rejected $namespace.metadata.name) }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} +{{- range $index, $namespace := $namespaces }} +{{- $key := $namespace.metadata.name -}} +{{- if not (has $key $working.rejected) }} +{{- $ignore := set $args "domainNamespace" $key -}} +{{- include "operator.operatorRoleBindingNamespace" $args -}} +{{- end }} +{{- end }} +{{- else if eq .domainNamespaceSelectionStrategy "RegExp" }} +{{- $args := include "utils.cloneDictionary" . | fromYaml -}} +{{- range $index, $namespace := (lookup "v1" "Namespace" "" "").items }} +{{- if regexMatch $args.domainNamespaceRegExp $namespace.metadata.name }} +{{- $key := $namespace.metadata.name -}} +{{- $ignore := set $args "domainNamespace" $key -}} +{{- include "operator.operatorRoleBindingNamespace" $args -}} +{{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-domain-admin.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-domain-admin.tpl new file mode 100644 index 000000000..94cab9df7 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-domain-admin.tpl @@ -0,0 +1,40 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorClusterRoleDomainAdmin" }} +--- +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "Role" +{{- else }} +kind: "ClusterRole" +{{- end }} +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-role-domain-admin" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-domain-admin" | join "-" | quote }} + {{- end }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +rules: +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +- apiGroups: [""] + resources: ["secrets", "pods", "events"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get", "list"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["get", "create"] +- apiGroups: ["weblogic.oracle"] + resources: ["domains"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +- apiGroups: ["weblogic.oracle"] + resources: ["domains/status"] + verbs: ["get", "watch"] +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-general.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-general.tpl new file mode 100644 index 000000000..2eba13b95 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-general.tpl @@ -0,0 +1,39 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorClusterRoleGeneral" }} +--- +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "Role" +{{- else }} +kind: "ClusterRole" +{{- end }} +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-role-general" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-general" | join "-" | quote }} + {{- end }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +rules: +{{- if not (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["get", "list", "watch"] +- apiGroups: ["apiextensions.k8s.io"] + resources: ["customresourcedefinitions"] + verbs: ["get", "list", "watch", "create", "update", "patch"] +{{- end }} +- apiGroups: ["weblogic.oracle"] + resources: ["domains", "domains/status"] + verbs: ["get", "list", "watch", "update", "patch"] +- apiGroups: ["authentication.k8s.io"] + resources: ["tokenreviews"] + verbs: ["create"] +- apiGroups: ["authorization.k8s.io"] + resources: ["selfsubjectrulesreviews"] + verbs: ["create"] +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-namespace.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-namespace.tpl new file mode 100644 index 000000000..6310779bb --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-namespace.tpl @@ -0,0 +1,40 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorClusterRoleNamespace" }} +--- +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "Role" +{{- else }} +kind: "ClusterRole" +{{- end }} +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-role-namespace" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-namespace" | join "-" | quote }} + {{- end }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +rules: +- apiGroups: [""] + resources: ["services", "configmaps", "pods", "events"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get", "list"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["get", "create"] +- apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +- apiGroups: ["policy"] + resources: ["poddisruptionbudgets"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-nonresource.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-nonresource.tpl new file mode 100644 index 000000000..e3b6a2785 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-nonresource.tpl @@ -0,0 +1,15 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorClusterRoleNonResource" }} +--- +kind: "ClusterRole" +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-nonresource" | join "-" | quote }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +rules: +- nonResourceURLs: ["/version/*"] + verbs: ["get"] +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-operator-admin.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-operator-admin.tpl new file mode 100644 index 000000000..46faed184 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrole-operator-admin.tpl @@ -0,0 +1,34 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorClusterRoleOperatorAdmin" }} +--- +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "Role" +{{- else }} +kind: "ClusterRole" +{{- end }} +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-role-operator-admin" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-operator-admin" | join "-" | quote }} + {{- end }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +rules: +- apiGroups: [""] + resources: ["configmaps", "secrets"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +- apiGroups: [""] + resources: ["pods", "events"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get", "list"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["get", "create"] +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-auth-delegator.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-auth-delegator.tpl new file mode 100644 index 000000000..783f970e7 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-auth-delegator.tpl @@ -0,0 +1,30 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.clusterRoleBindingAuthDelegator" }} +--- +apiVersion: "rbac.authorization.k8s.io/v1" +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "RoleBinding" +{{- else }} +kind: "ClusterRoleBinding" +{{- end }} +metadata: + labels: + weblogic.operatorName: {{ .Release.Namespace | quote}} + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-rolebinding-auth-delegator" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrolebinding-auth-delegator" | join "-" | quote }} + {{- end }} +roleRef: + apiGroup: "rbac.authorization.k8s.io" + kind: "ClusterRole" + name: "system:auth-delegator" +subjects: +- kind: "ServiceAccount" + apiGroup: "" + name: {{ .serviceAccount | quote }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-discovery.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-discovery.tpl new file mode 100644 index 000000000..48c505fa5 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-discovery.tpl @@ -0,0 +1,30 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.clusterRoleBindingDiscovery" }} +--- +apiVersion: "rbac.authorization.k8s.io/v1" +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "RoleBinding" +{{- else }} +kind: "ClusterRoleBinding" +{{- end }} +metadata: + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-rolebinding-discovery" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrolebinding-discovery" | join "-" | quote }} + {{- end }} +roleRef: + apiGroup: "rbac.authorization.k8s.io" + kind: "ClusterRole" + name: "system:discovery" +subjects: +- kind: "ServiceAccount" + apiGroup: "" + name: {{ .serviceAccount | quote }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-general.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-general.tpl new file mode 100644 index 000000000..f2994da33 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-general.tpl @@ -0,0 +1,35 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.clusterRoleBindingGeneral" }} +--- +apiVersion: "rbac.authorization.k8s.io/v1" +{{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +kind: "RoleBinding" +{{- else }} +kind: "ClusterRoleBinding" +{{- end }} +metadata: + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + name: "weblogic-operator-rolebinding-general" + namespace: {{ .Release.Namespace | quote }} + {{- else }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrolebinding-general" | join "-" | quote }} + {{- end }} +roleRef: + apiGroup: "rbac.authorization.k8s.io" + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + kind: "Role" + name: "weblogic-operator-role-general" + {{- else }} + kind: "ClusterRole" + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-general" | join "-" | quote }} + {{- end }} +subjects: +- kind: "ServiceAccount" + apiGroup: "" + name: {{ .serviceAccount | quote }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-nonresource.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-nonresource.tpl new file mode 100644 index 000000000..d998ab0e9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-clusterrolebinding-nonresource.tpl @@ -0,0 +1,21 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.clusterRoleBindingNonResource" }} +--- +apiVersion: "rbac.authorization.k8s.io/v1" +kind: "ClusterRoleBinding" +metadata: + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrolebinding-nonresource" | join "-" | quote }} +roleRef: + apiGroup: "rbac.authorization.k8s.io" + kind: "ClusterRole" + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-nonresource" | join "-" | quote }} +subjects: +- kind: "ServiceAccount" + apiGroup: "" + name: {{ .serviceAccount | quote }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-cm.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-cm.tpl new file mode 100644 index 000000000..dd6594de2 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-cm.tpl @@ -0,0 +1,58 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorConfigMap" }} +--- +apiVersion: "v1" +data: + {{- if .externalRestEnabled }} + {{- if (hasKey . "externalRestIdentitySecret") }} + externalRestIdentitySecret: {{ .externalRestIdentitySecret | quote }} + {{- else }} + externalOperatorCert: {{ .externalOperatorCert | quote }} + {{- end }} + {{- end }} + {{- $configmap := (lookup "v1" "ConfigMap" .Release.Namespace "weblogic-operator-cm") }} + {{- if (and $configmap $configmap.data) }} + {{- $internalOperatorCert := index $configmap.data "internalOperatorCert" }} + {{- if $internalOperatorCert }} + internalOperatorCert: {{ $internalOperatorCert }} + {{- end }} + {{- end }} + serviceaccount: {{ .serviceAccount | quote }} + domainNamespaceSelectionStrategy: {{ (default "List" .domainNamespaceSelectionStrategy) | quote }} + domainNamespaces: {{ .domainNamespaces | uniq | sortAlpha | join "," | quote }} + {{- if .dedicated }} + dedicated: {{ .dedicated | quote }} + {{- end }} + {{- if .domainNamespaceLabelSelector }} + domainNamespaceLabelSelector: {{ .domainNamespaceLabelSelector | quote }} + {{- end }} + {{- if .domainNamespaceRegExp }} + domainNamespaceRegExp: {{ .domainNamespaceRegExp | quote }} + {{- end }} + {{- if .dns1123Fields }} + dns1123Fields: {{ .dns1123Fields | quote }} + {{- end }} + {{- if .featureGates }} + featureGates: {{ .featureGates | quote }} + {{- end }} + {{- if .introspectorJobNameSuffix }} + introspectorJobNameSuffix: {{ .introspectorJobNameSuffix | quote }} + {{- end }} + {{- if .externalServiceNameSuffix }} + externalServiceNameSuffix: {{ .externalServiceNameSuffix | quote }} + {{- end }} + {{- if .clusterSizePaddingValidationEnabled }} + clusterSizePaddingValidationEnabled: {{ .clusterSizePaddingValidationEnabled | quote }} + {{- end }} + {{- if .tokenReviewAuthentication }} + tokenReviewAuthentication: {{ .tokenReviewAuthentication | quote }} + {{- end }} +kind: "ConfigMap" +metadata: + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + name: "weblogic-operator-cm" + namespace: {{ .Release.Namespace | quote }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl new file mode 100644 index 000000000..3fadac7dc --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-dep.tpl @@ -0,0 +1,158 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorDeployment" }} +--- +apiVersion: "apps/v1" +kind: "Deployment" +metadata: + name: "weblogic-operator" + namespace: {{ .Release.Namespace | quote }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +spec: + strategy: + type: Recreate + selector: + matchLabels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + replicas: 1 + template: + metadata: + {{- with .annotations }} + annotations: + {{- end }} + {{- range $key, $value := .annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + app: "weblogic-operator" + {{- range $key, $value := .labels }} + {{ $key }}: {{ $value | quote }} + {{- end }} + spec: + serviceAccountName: {{ .serviceAccount | quote }} + {{- with .nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: "weblogic-operator" + image: {{ .image | quote }} + imagePullPolicy: {{ .imagePullPolicy | quote }} + command: ["bash"] + args: ["/operator/operator.sh"] + env: + - name: "OPERATOR_NAMESPACE" + valueFrom: + fieldRef: + fieldPath: "metadata.namespace" + - name: "OPERATOR_POD_NAME" + valueFrom: + fieldRef: + fieldPath: "metadata.name" + - name: "OPERATOR_POD_UID" + valueFrom: + fieldRef: + fieldPath: "metadata.uid" + - name: "OPERATOR_VERBOSE" + value: "false" + - name: "JAVA_LOGGING_LEVEL" + value: {{ .javaLoggingLevel | quote }} + - name: "JAVA_LOGGING_MAXSIZE" + value: {{ .javaLoggingFileSizeLimit | default 20000000 | quote }} + - name: "JAVA_LOGGING_COUNT" + value: {{ .javaLoggingFileCount | default 10 | quote }} + {{- if .remoteDebugNodePortEnabled }} + - name: "REMOTE_DEBUG_PORT" + value: {{ .internalDebugHttpPort | quote }} + - name: "DEBUG_SUSPEND" + {{- if .suspendOnDebugStartup }} + value: "y" + {{- else }} + value: "n" + {{- end }} + {{- end }} + {{- if .mockWLS }} + - name: "MOCK_WLS" + value: "true" + {{- end }} + resources: + requests: + cpu: {{ .cpuRequests | default "250m" }} + memory: {{ .memoryRequests | default "512Mi" }} + limits: + {{- if .cpuLimits}} + cpu: {{ .cpuLimits }} + {{- end }} + {{- if .memoryLimits}} + memory: {{ .memoryLimits }} + {{- end }} + volumeMounts: + - name: "weblogic-operator-cm-volume" + mountPath: "/operator/config" + - name: "weblogic-operator-debug-cm-volume" + mountPath: "/operator/debug-config" + - name: "weblogic-operator-secrets-volume" + mountPath: "/operator/secrets" + readOnly: true + {{- if .elkIntegrationEnabled }} + - mountPath: "/logs" + name: "log-dir" + readOnly: false + {{- end }} + {{- if not .remoteDebugNodePortEnabled }} + livenessProbe: + exec: + command: + - "bash" + - "/operator/livenessProbe.sh" + initialDelaySeconds: 20 + periodSeconds: 5 + readinessProbe: + exec: + command: + - "bash" + - "/operator/readinessProbe.sh" + initialDelaySeconds: 2 + periodSeconds: 10 + {{- end }} + {{- if .elkIntegrationEnabled }} + - name: "logstash" + image: {{ .logStashImage | quote }} + args: [ "-f", "/logs/logstash.conf" ] + volumeMounts: + - name: "log-dir" + mountPath: "/logs" + env: + - name: "ELASTICSEARCH_HOST" + value: {{ .elasticSearchHost | quote }} + - name: "ELASTICSEARCH_PORT" + value: {{ .elasticSearchPort | quote }} + {{- end }} + {{- if .imagePullSecrets }} + imagePullSecrets: + {{ .imagePullSecrets | toYaml }} + {{- end }} + volumes: + - name: "weblogic-operator-cm-volume" + configMap: + name: "weblogic-operator-cm" + - name: "weblogic-operator-debug-cm-volume" + configMap: + name: "weblogic-operator-debug-cm" + optional: true + - name: "weblogic-operator-secrets-volume" + secret: + secretName: "weblogic-operator-secrets" + {{- if .elkIntegrationEnabled }} + - name: "log-dir" + emptyDir: + medium: "Memory" + {{- end }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-external-svc.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-external-svc.tpl new file mode 100644 index 000000000..44bfc1191 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-external-svc.tpl @@ -0,0 +1,30 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorExternalService" }} +{{- if or .externalRestEnabled .remoteDebugNodePortEnabled }} +--- +apiVersion: "v1" +kind: "Service" +metadata: + name: "external-weblogic-operator-svc" + namespace: {{ .Release.Namespace | quote }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +spec: + type: "NodePort" + selector: + app: "weblogic-operator" + ports: + {{- if .externalRestEnabled }} + - name: "rest" + port: 8081 + nodePort: {{ .externalRestHttpsPort }} + {{- end }} + {{- if .remoteDebugNodePortEnabled }} + - name: "debug" + port: {{ .internalDebugHttpPort }} + nodePort: {{ .externalDebugHttpPort }} + {{- end }} +{{- end }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-internal-svc.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-internal-svc.tpl new file mode 100644 index 000000000..0108738de --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-internal-svc.tpl @@ -0,0 +1,20 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorInternalService" }} +--- +apiVersion: "v1" +kind: "Service" +metadata: + name: "internal-weblogic-operator-svc" + namespace: {{ .Release.Namespace | quote }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +spec: + type: "ClusterIP" + selector: + app: "weblogic-operator" + ports: + - port: 8082 + name: "rest" +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-role.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-role.tpl new file mode 100644 index 000000000..e0c386b98 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-role.tpl @@ -0,0 +1,17 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorRole" }} +--- +kind: "Role" +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + name: "weblogic-operator-role" + namespace: {{ .Release.Namespace | quote }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +rules: +- apiGroups: [""] + resources: ["events", "secrets", "configmaps"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete", "deletecollection"] +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-rolebinding-namespace.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-rolebinding-namespace.tpl new file mode 100644 index 000000000..d55ed3f47 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-rolebinding-namespace.tpl @@ -0,0 +1,35 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorRoleBindingNamespace" }} +--- +{{- if .enableClusterRoleBinding }} +kind: "ClusterRoleBinding" +{{- else }} +kind: "RoleBinding" +{{- end }} +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + {{- if .enableClusterRoleBinding }} + name: {{ list .Release.Namespace "weblogic-operator-clusterrolebinding-namespace" | join "-" | quote }} + {{- else }} + name: "weblogic-operator-rolebinding-namespace" + namespace: {{ .domainNamespace | quote }} + {{- end }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +subjects: +- kind: "ServiceAccount" + name: {{ .serviceAccount | quote }} + namespace: {{ .Release.Namespace | quote }} + apiGroup: "" +roleRef: + {{- if (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} + kind: "Role" + name: "weblogic-operator-role-namespace" + {{- else }} + kind: "ClusterRole" + name: {{ list .Release.Namespace "weblogic-operator-clusterrole-namespace" | join "-" | quote }} + {{- end }} + apiGroup: "rbac.authorization.k8s.io" +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-rolebinding.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-rolebinding.tpl new file mode 100644 index 000000000..98a09424e --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-rolebinding.tpl @@ -0,0 +1,22 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorRoleBinding" }} +--- +kind: "RoleBinding" +apiVersion: "rbac.authorization.k8s.io/v1" +metadata: + name: "weblogic-operator-rolebinding" + namespace: {{ .Release.Namespace | quote }} + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} +subjects: +- kind: "ServiceAccount" + name: {{ .serviceAccount | quote }} + namespace: {{ .Release.Namespace | quote }} + apiGroup: "" +roleRef: + kind: "Role" + name: "weblogic-operator-role" + apiGroup: "rbac.authorization.k8s.io" +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-secret.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-secret.tpl new file mode 100644 index 000000000..6a7442718 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator-secret.tpl @@ -0,0 +1,25 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operatorSecrets" }} +--- +apiVersion: "v1" +kind: "Secret" +data: + {{- if (and .externalRestEnabled (hasKey . "externalOperatorKey")) }} + externalOperatorKey: {{ .externalOperatorKey | quote }} + {{- end }} + {{- $secret := (lookup "v1" "Secret" .Release.Namespace "weblogic-operator-secrets") }} + {{- if (and $secret $secret.data) }} + {{- $internalOperatorKey := index $secret.data "internalOperatorKey" }} + {{- if $internalOperatorKey }} + internalOperatorKey: {{ $internalOperatorKey }} + {{- end }} + {{- end }} +metadata: + labels: + weblogic.operatorName: {{ .Release.Namespace | quote }} + name: "weblogic-operator-secrets" + namespace: {{ .Release.Namespace | quote }} +type: "Opaque" +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator.tpl new file mode 100644 index 000000000..c24d7eebf --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_operator.tpl @@ -0,0 +1,30 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.operator" -}} +{{- include "operator.operatorClusterRoleGeneral" . }} +{{- include "operator.operatorClusterRoleNamespace" . }} +{{- if not (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +{{- include "operator.operatorClusterRoleNonResource" . }} +{{- end }} +{{- include "operator.operatorClusterRoleOperatorAdmin" . }} +{{- include "operator.operatorClusterRoleDomainAdmin" . }} +{{- include "operator.clusterRoleBindingGeneral" . }} +{{- include "operator.clusterRoleBindingAuthDelegator" . }} +{{- include "operator.clusterRoleBindingDiscovery" . }} +{{- if not (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +{{- include "operator.clusterRoleBindingNonResource" . }} +{{- end }} +{{- include "operator.operatorRole" . }} +{{- include "operator.operatorRoleBinding" . }} +{{- include "operator.operatorConfigMap" . }} +{{- include "operator.operatorSecrets" . }} +{{- include "operator.operatorDeployment" . }} +{{- include "operator.operatorInternalService" . }} +{{- include "operator.operatorExternalService" . }} +{{- if .enableClusterRoleBinding }} +{{- include "operator.operatorRoleBindingNamespace" . }} +{{- else }} +{{- include "operator.domainNamespaces" . }} +{{- end }} +{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_utils.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_utils.tpl new file mode 100644 index 000000000..9f2ed825c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_utils.tpl @@ -0,0 +1,493 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{/* +Start validation +*/}} +{{- define "utils.startValidation" -}} +{{- $scope := . -}} +{{- $context := dict "scope" $scope "path" list -}} +{{- $stack := list $context -}} +{{- $ignore := set $scope "validationContextStack" $stack -}} +{{- $ignore := include "utils.setCurrentValidationContext" $scope -}} +{{- end -}} + +{{/* +End validation +If there were any validation errors, report them and kill the helm chart installation. +*/}} +{{- define "utils.endValidation" -}} +{{- $scope := . -}} +{{- if hasKey $scope "validationErrors" -}} +{{- fail $scope.validationErrors -}} +{{- end -}} +{{- end -}} + +{{/* +Push a new validation context +*/}} +{{- define "utils.pushValidationContext" -}} +{{- $scope := index . 0 }} +{{- $scopeName := index . 1 }} +{{- $newScope := index $scope.validationScope $scopeName -}} +{{- $newPath := append $scope.validationPath $scopeName -}} +{{- $newContext := dict "scope" $newScope "path" $newPath -}} +{{- $newStack := append $scope.validationContextStack $newContext -}} +{{- $ignore := set $scope "validationContextStack" $newStack -}} +{{- $ignore := include "utils.setCurrentValidationContext" $scope -}} +{{- end -}} + +{{/* +Pop the validation context +*/}} +{{- define "utils.popValidationContext" -}} +{{- $scope := . }} +{{- $stack := $scope.validationContextStack -}} +{{- $ignore := set $scope "validationContextStack" (initial $stack) -}} +{{- $ignore := include "utils.setCurrentValidationContext" $scope -}} +{{- end -}} + +{{/* +Set the current validation context from the stack +*/}} +{{- define "utils.setCurrentValidationContext" -}} +{{- $scope := . }} +{{- $context := $scope.validationContextStack | last -}} +{{- $ignore := set $scope "validationScope" (index $context "scope") -}} +{{- $ignore := set $scope "validationPath" (index $context "path") -}} +{{- end -}} + +{{/* +Record a validation error (it will get reported later by utils.reportValidationErrors) +*/}} +{{- define "utils.recordValidationError" -}} +{{- $scope := index . 0 -}} +{{- $errorMsg := index . 1 -}} +{{- $path := $scope.validationPath -}} +{{- $pathStr := $path | join "." | trim -}} +{{- $scopedErrorMsg := (list "\n" $pathStr $errorMsg) | compact | join " " -}} +{{- if hasKey $scope "validationErrors" -}} +{{- $newValidationErrors := cat $scope.validationErrors $scopedErrorMsg -}} +{{- $ignore := set $scope "validationErrors" $newValidationErrors -}} +{{- else -}} +{{- $newValidationErrors := $scopedErrorMsg -}} +{{- $ignore := set $scope "validationErrors" $newValidationErrors -}} +{{- end -}} +{{- end -}} + +{{/* +Returns whether any errors have been reported +*/}} +{{- define "utils.haveValidationErrors" -}} +{{- if hasKey . "validationErrors" -}} + true +{{- end -}} +{{- end -}} + +{{/* +Determine whether a dictionary has a non-null value for a key +*/}} +{{- define "utils.dictionaryHasNonNullValue" -}} +{{- $dict := index . 0 -}} +{{- $name := index . 1 -}} +{{- if and (hasKey $dict $name) (not ( eq (typeOf (index $dict $name)) "" )) -}} + true +{{- end -}} +{{- end -}} + +{{/* +Verify that a value of a specific kind has been specified. +*/}} +{{- define "utils.verifyValue" -}} +{{- $requiredKind := index . 0 -}} +{{- $scope := index . 1 -}} +{{- $name := index . 2 -}} +{{- $isRequired := index . 3 -}} +{{- if $scope.trace -}} +{{- $errorMsg := cat "TRACE" $name $requiredKind $isRequired -}} +{{- $ignore := include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- end -}} +{{- $parent := $scope.validationScope -}} +{{- if include "utils.dictionaryHasNonNullValue" (list $parent $name) -}} +{{- $value := index $parent $name -}} +{{- $actualKind := kindOf $value -}} +{{- if eq $requiredKind $actualKind -}} + true +{{- else -}} +{{- $errorMsg := cat $name "must be a" $requiredKind ":" $actualKind -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- end -}} +{{- else -}} +{{- if $isRequired -}} +{{- $errorMsg := cat $requiredKind $name "must be specified" -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- else -}} + true +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Verify that a list value has been specified +*/}} +{{- define "utils.verifyListValue" -}} +{{- $requiredKind := index . 0 -}} +{{- $scope := index . 1 -}} +{{- $name := index . 2 -}} +{{- $isRequired := index . 3 -}} +{{- $parent := $scope.validationScope -}} +{{- $args := . -}} +{{- if include "utils.verifyValue" (list "slice" $scope $name $isRequired) -}} +{{- $status := dict -}} +{{- if hasKey $parent $name -}} +{{- $list := index $parent $name -}} +{{- range $value := $list -}} +{{- $actualKind := kindOf $value -}} +{{- if not (eq $requiredKind $actualKind) -}} +{{- $errorMsg := cat $name "must only contain" $requiredKind "elements:" $actualKind -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- $ignore := set $status "error" true -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- if not (hasKey $status "error") -}} + true +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Verify a string value +*/}} +{{- define "utils.baseVerifyString" -}} +{{- include "utils.verifyValue" (prepend . "string") -}} +{{- end -}} + +{{/* +Verify a required string value +*/}} +{{- define "utils.verifyString" -}} +{{- include "utils.baseVerifyString" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional string value +*/}} +{{- define "utils.verifyOptionalString" -}} +{{- include "utils.baseVerifyString" (append . false) -}} +{{- end -}} + +{{/* +Verify a boolean value +*/}} +{{- define "utils.baseVerifyBoolean" -}} +{{- include "utils.verifyValue" (prepend . "bool") -}} +{{- end -}} + +{{/* +Verify a required boolean value +*/}} +{{- define "utils.verifyBoolean" -}} +{{- include "utils.baseVerifyBoolean" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional boolean value +*/}} +{{- define "utils.verifyOptionalBoolean" -}} +{{- include "utils.baseVerifyBoolean" (append . false) -}} +{{- end -}} + +{{/* +Verify an integer value +*/}} +{{- define "utils.baseVerifyInteger" -}} +{{- include "utils.verifyValue" (prepend . "float64") -}} +{{- end -}} + +{{/* +Verify a required integer value +*/}} +{{- define "utils.verifyInteger" -}} +{{- include "utils.baseVerifyInteger" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional required integer value +*/}} +{{- define "utils.verifyOptionalInteger" -}} +{{- include "utils.baseVerifyInteger" (append . false) -}} +{{- end -}} + +{{/* +Verify a dictionary value +*/}} +{{- define "utils.baseVerifyDictionary" -}} +{{- include "utils.verifyValue" (prepend . "map") -}} +{{- end -}} + +{{/* +Verify a required dictionary value +*/}} +{{- define "utils.verifyDictionary" -}} +{{- include "utils.baseVerifyDictionary" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional dictionary value +*/}} +{{- define "utils.verifyOptionalDictionary" -}} +{{- include "utils.baseVerifyDictionary" (append . false) -}} +{{- end -}} + +{{/* +Verify a enum string value +*/}} +{{- define "utils.baseVerifyEnum" -}} +{{- $scope := index . 0 -}} +{{- $name := index . 1 -}} +{{- $legalValues := index . 2 -}} +{{- $isRequired := index . 3 -}} +{{- if include "utils.baseVerifyString" (list $scope $name $isRequired) -}} +{{- $parent := $scope.validationScope -}} +{{- if include "utils.dictionaryHasNonNullValue" (list $parent $name) -}} +{{- $value := index $parent $name -}} +{{- if has $value $legalValues -}} + true +{{- else -}} +{{ $errorMsg := cat $name "must be one of the following values" $legalValues ":" $value -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Verify a required enum string value +*/}} +{{- define "utils.verifyEnum" -}} +{{- include "utils.baseVerifyEnum" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional enum string value +*/}} +{{- define "utils.verifyOptionalEnum" -}} +{{- include "utils.baseVerifyEnum" (append . false) -}} +{{- end -}} + +{{/* +Verify a kubernetes resource name string value +*/}} +{{- define "utils.baseVerifyResourceName" -}} +{{/* https://kubernetes.io/docs/concepts/overview/working-with-objects/names */}} +{{/* names: only lower case, numbers, dot, dash, max 253 */}} +{{/* https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set */}} +{{/* labels/selectors - upper & lower case, numbers, dot, dash, underscore, max 63 */}} +{{- $scope := index . 0 -}} +{{- $name := index . 1 -}} +{{- $max := index . 2 -}} +{{- $isRequired := index . 3 -}} +{{- if include "utils.baseVerifyString" (list $scope $name $isRequired) -}} +{{- $parent := $scope.validationScope -}} +{{- if include "utils.dictionaryHasNonNullValue" (list $parent $name) -}} +{{- $value := index $parent $name -}} +{{- $len := len $value -}} +{{- if and (le $len $max) (regexMatch "^[a-z0-9.-]+$" $value) -}} + true +{{- else -}} +{{- $errorMsg := cat $name "must only contain lower case letters, numbers, dashes and dots, and must not contain more than" $max "characters: " $value -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- end -}} +{{- end -}} +{{- else -}} +{{- end -}} +{{- end -}} + +{{/* +Verify a required kubernetes resource name string value +*/}} +{{- define "utils.verifyResourceName" -}} +{{- include "utils.baseVerifyResourceName" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional kubernetes resource name string value +*/}} +{{- define "utils.verifyOptionalResourceName" -}} +{{- include "utils.baseVerifyResourceName" (append . false) -}} +{{- end -}} + +{{/* +Verify external service name suffix string value +*/}} +{{- define "utils.verifyExternalServiceNameSuffix" -}} +{{- include "utils.baseVerifyResourceName" (append . false) -}} +{{- end -}} + +{{/* +Verify introspector job name suffix string value +*/}} +{{- define "utils.verifyIntrospectorJobNameSuffix" -}} +{{- include "utils.baseVerifyResourceName" (append . false) -}} +{{- end -}} + +{{/* +Verify a list of strings value +*/}} +{{- define "utils.baseVerifyStringList" -}} +{{- include "utils.verifyListValue" (prepend . "string") -}} +{{- end -}} + +{{/* +Verify a required list of strings value +*/}} +{{- define "utils.verifyStringList" -}} +{{- include "utils.baseVerifyStringList" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional list of strings value +*/}} +{{- define "utils.verifyOptionalStringList" -}} +{{- include "utils.baseVerifyStringList" (append . false) -}} +{{- end -}} + +{{/* +Verify a list of dictionaries value +*/}} +{{- define "utils.baseVerifyDictionaryList" -}} +{{- include "utils.verifyListValue" (prepend . "map") -}} +{{- end -}} + +{{/* +Verify a required list of dictionaries value +*/}} +{{- define "utils.verifyDictionaryList" -}} +{{- include "utils.baseVerifyDictionaryList" (append . true) -}} +{{- end -}} + +{{/* +Verify an optional list of dictionaries value +*/}} +{{- define "utils.verifyOptionalDictionaryList" -}} +{{- include "utils.baseVerifyDictionaryList" (append . false) -}} +{{- end -}} + +{{/* +Merge a set of dictionaries into a single dictionary. + +The scope must be a list of dictionaries, starting with the least specific +and ending with the most specific. + +First it makes an empty destinaction dictionary, then iterates over the dictionaries, +overlaying their values on the destination dictionary. + +If a value is null, then it removes that key from the destination dictionary. + +If the value is already present in the destination dictionary, and the old and +new values are both dictionaries, it merges them into the destination. +*/}} +{{- define "utils.mergeDictionaries" -}} +{{- $dest := dict -}} +{{- range $src := . -}} +{{- if not (empty $src) -}} +{{- range $key, $value := $src -}} +{{- $ignore := include "utils.mergeDictionaryValue" (list $dest $key $value) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- toYaml $dest -}} +{{- end -}} + +{{/* +Merge a value into a dictionary. +This is like helm's 'merge' function, except that it handles null entries too. +*/}} +{{- define "utils.mergeDictionaryValue" -}} +{{- $dest := index . 0 -}} +{{- $key := index . 1 -}} +{{- $newValue := index . 2 -}} +{{- $newType := typeOf $newValue -}} +{{- if hasKey $dest $key -}} +{{- if eq $newType "" -}} +{{/* # if the value already existed, and the new value is null, remove the old value */}} +{{- $ignore := unset $dest $key -}} +{{- else -}} +{{- $oldValue := index $dest $key -}} +{{- $oldKind := kindOf $oldValue -}} +{{- $newKind := kindOf $newValue -}} +{{- if (and (eq $oldKind "map") (eq $newKind "map")) -}} +{{/* # if both values are maps, merge them */}} +{{- $merged := include "utils.mergeDictionaries" (list $oldValue $newValue) | fromYaml -}} +{{- $ignore := set $dest $key $merged -}} +{{- else -}} +{{/* # replace the old value with the new one */}} +{{- $ignore := set $dest $key $newValue -}} +{{- end -}} +{{- end -}} +{{- else -}} +{{- if not (eq $newType "") -}} +{{/* #if there was no old value, and the new value isn't null, use the new value */}} +{{- $ignore := set $dest $key $newValue -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Make a writable copy of a dictionary. +TBD - does helm provide a clone method we can use instead? +*/}} +{{- define "utils.cloneDictionary" -}} +{{- include "utils.mergeDictionaries" (list .) -}} +{{- end -}} + +{{/* +Verify that a list of values (exclude) can not be defined if another value (key) is already defined +*/}} +{{- define "utils.mutexValue" -}} +{{- $scope := index . 0 -}} +{{- $key := index . 1 -}} +{{- $exclude := index . 2 -}} +{{- $type := index . 3 -}} +{{- $parent := $scope.validationScope -}} +{{- $args := . -}} +{{- $status := dict -}} +{{- if hasKey $parent $key -}} +{{- range $value := $exclude -}} +{{- if hasKey $parent $value -}} +{{- $errorMsg := cat $value "can not be present when" $key "is defined" " " -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- $ignore := set $status "error" true -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- if not (hasKey $status "error") -}} + true +{{- end -}} +{{- end -}} + +{{/* +Verify that a list of strings can not be defined if another string is already defined +*/}} +{{- define "utils.mutexString" -}} +{{- include "utils.mutexValue" (append . "string") -}} +{{- end -}} + +{{/* +Verify that a Kubernetes resource exists in a given namespace +*/}} +{{- define "utils.verifyK8SResource" -}} +{{- $scope := index . 0 -}} +{{- $name := index . 1 -}} +{{- $type := index . 2 -}} +{{- $namespace := index . 3 -}} +{{- $foundNS := (lookup "v1" "Namespace" "" $namespace) }} +{{- if $foundNS }} +{{- $foundResource := (lookup "v1" $type $namespace $name) }} +{{- if not $foundResource }} +{{- $errorMsg := cat $type $name " not found in namespace " $namespace -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- end -}} +{{- end -}} +{{- end -}} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_validate-inputs.tpl b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_validate-inputs.tpl new file mode 100644 index 000000000..a6ee7dd02 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/_validate-inputs.tpl @@ -0,0 +1,63 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- define "operator.validateInputs" -}} +{{- $scope := include "utils.cloneDictionary" . | fromYaml -}} +{{- $ignore:= include "utils.startValidation" $scope -}} +{{- $ignore := include "utils.pushValidationContext" (list $scope "Release") -}} +{{- $ignore := include "utils.verifyResourceName" (list $scope "Namespace" 63) -}} +{{- $ignore := include "utils.popValidationContext" $scope -}} +{{- $ignore := include "utils.verifyString" (list $scope "serviceAccount") -}} +{{- $ignore := include "utils.verifyK8SResource" (list $scope .serviceAccount "ServiceAccount" .Release.Namespace) -}} +{{- $ignore := include "utils.verifyString" (list $scope "image") -}} +{{- $ignore := include "utils.verifyEnum" (list $scope "imagePullPolicy" (list "Always" "IfNotPresent" "Never")) -}} +{{- $ignore := include "utils.verifyOptionalDictionaryList" (list $scope "imagePullSecrets") -}} +{{- $ignore := include "utils.verifyEnum" (list $scope "javaLoggingLevel" (list "SEVERE" "WARNING" "INFO" "CONFIG" "FINE" "FINER" "FINEST")) -}} +{{- if include "utils.verifyBoolean" (list $scope "externalRestEnabled") -}} +{{- if $scope.externalRestEnabled -}} +{{- $ignore := include "utils.verifyInteger" (list $scope "externalRestHttpsPort") -}} +{{- $ignore := include "utils.mutexString" (list $scope "externalRestIdentitySecret" (list "externalOperatorKey" "externalOperatorCert")) -}} +{{- if (or (hasKey $scope "externalOperatorCert") (hasKey $scope "externalOperatorKey")) -}} +{{- $ignore := include "utils.verifyString" (list $scope "externalOperatorCert") -}} +{{- $ignore := include "utils.verifyString" (list $scope "externalOperatorKey") -}} +{{- else }} +{{- $ignore := include "utils.verifyString" (list $scope "externalRestIdentitySecret") -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- if include "utils.verifyBoolean" (list $scope "remoteDebugNodePortEnabled") -}} +{{- if $scope.remoteDebugNodePortEnabled -}} +{{- $ignore := include "utils.verifyBoolean" (list $scope "suspendOnDebugStartup") -}} +{{- $ignore := include "utils.verifyInteger" (list $scope "internalDebugHttpPort") -}} +{{- $ignore := include "utils.verifyInteger" (list $scope "externalDebugHttpPort") -}} +{{- end -}} +{{- end -}} +{{- $ignore := include "utils.verifyOptionalBoolean" (list $scope "enableClusterRoleBinding") -}} +{{- if and .enableClusterRoleBinding (or (eq (default "List" .domainNamespaceSelectionStrategy) "Dedicated") (and .dedicated (eq (default "List" .domainNamespaceSelectionStrategy) "List"))) }} +{{- $errorMsg := "The enableClusterRoleBinding value may not be true when either dedicated is true or domainNamespaceSelectionStrategy is Dedicated" -}} +{{- include "utils.recordValidationError" (list $scope $errorMsg) -}} +{{- end -}} +{{- if eq (default "List" $scope.domainNamespaceSelectionStrategy) "List" -}} +{{- $ignore := include "utils.verifyStringList" (list $scope "domainNamespaces") -}} +{{- end -}} +{{- if include "utils.verifyBoolean" (list $scope "elkIntegrationEnabled") -}} +{{- if $scope.elkIntegrationEnabled -}} +{{- $ignore := include "utils.verifyString" (list $scope "logStashImage") -}} +{{- $ignore := include "utils.verifyString" (list $scope "elasticSearchHost") -}} +{{- $ignore := include "utils.verifyInteger" (list $scope "elasticSearchPort") -}} +{{- end -}} +{{- end -}} +{{- $ignore := include "utils.verifyOptionalBoolean" (list $scope "dedicated") -}} +{{- $ignore := include "utils.verifyOptionalEnum" (list $scope "domainNamespaceSelectionStrategy" (list "List" "LabelSelector" "RegExp" "Dedicated")) -}} +{{- if eq (default "List" $scope.domainNamespaceSelectionStrategy) "LabelSelector" -}} +{{- $ignore := include "utils.verifyString" (list $scope "domainNamespaceLabelSelector") -}} +{{- end -}} +{{- if eq (default "List" $scope.domainNamespaceSelectionStrategy) "RegExp" -}} +{{- $ignore := include "utils.verifyString" (list $scope "domainNamespaceRegExp") -}} +{{- end -}} +{{- $ignore := include "utils.verifyOptionalBoolean" (list $scope "mockWLS") -}} +{{- $ignore := include "utils.verifyIntrospectorJobNameSuffix" (list $scope "introspectorJobNameSuffix" 25) -}} +{{- $ignore := include "utils.verifyExternalServiceNameSuffix" (list $scope "externalServiceNameSuffix" 10) -}} +{{- $ignore := include "utils.verifyOptionalBoolean" (list $scope "clusterSizePaddingValidationEnabled") -}} +{{- $ignore := include "utils.endValidation" $scope -}} +{{- end -}} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/main.yaml b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/main.yaml new file mode 100644 index 000000000..fb7e731f9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/templates/main.yaml @@ -0,0 +1,11 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +{{- $scope := include "utils.cloneDictionary" .Values | fromYaml -}} +{{- $ignore := set $scope "Files" .Files -}} +{{- $ignore := set $scope "Chart" .Chart -}} +{{- $ignore := set $scope "Release" .Release -}} +{{- $ignore := set $scope "APIVersions" .Capabilities.APIVersions -}} + +{{ include "operator.validateInputs" $scope }} +{{- include "operator.operator" $scope }} diff --git a/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/values.yaml b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/values.yaml new file mode 100644 index 000000000..dac9a5382 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/charts/weblogic-operator/values.yaml @@ -0,0 +1,224 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# serviceAccount specifies the name of the ServiceAccount in the operator's namespace that the +# operator will use to make requests to the Kubernetes API server. +# The customer is responsible for creating the ServiceAccount in the same namespace as this Helm release. +# If not specified, the the operator will use the Helm release namespace's 'default' ServiceAccount. +serviceAccount: "default" + +# domainNamespaceSelectionStrategy specifies how the operator will select the set of namespaces +# that it will manage. Legal values are: List, LabelSelector, RegExp, and Dedicated. If set to 'List', +# then the operator will manage the set of namespaces listed by the 'domainNamespaces' value. +# If set to 'LabelSelector', then the operator will manage the set of namespaces discovered by a list +# of namespaces using the value specified by 'domainNamespaceLabelSelector' as a label selector. +# If set to 'RegExp', then the operator will manage the set of namespaces discovered by a list +# of namespaces using the value specified by 'domainNamespaceRegExp' as a regular expression matched +# against the namespace names. +# If set to 'Dedicated', then operator will manage WebLogic Domains only in the same namespace +# where the operator itself is deployed, which is the namespace of the Helm release. +domainNamespaceSelectionStrategy: List + +# This value is deprecated. Please use 'domainNamespaceSelectionStrategy: Dedicated'. +# dedicated specifies if this operator will manage WebLogic Domains only in the same namespace in +# which the operator itself is deployed. If set to 'true', then the 'domainNamespaces' value below +# is ignored. This value is ignored if 'domainNamespaceSelectionStrategy' is set to a value other +# than 'List'. +# dedicated: false + +# domainNamespaces specifies list of WebLogic Domain namespaces that this operator manages. This value +# is ignored if 'domainNamespaceSelectionStrategy' is not 'List'. The customer is responsible for creating these +# namespaces. If not specified, then the operator will manage WebLogic Domains in the Kubernetes 'default' namespace. +# +# Example: In the configuration below, the operator will manage namespace1 and namespace2. +# +# domainNamespaces: +# - "namespace1" +# - "namespace2" +domainNamespaces: +- "default" + +# domainNamespaceLabelSelector specifies the label selector value that the operator will use when listing +# namespaces in search of the namespaces that contain WebLogic Domains that this operator will manage. Ignored +# if 'domainNamespaceSelectionStrategy' is not 'LabelSelector'. +# +# Example: manage any namespace with a label named "weblogic-operator". +# +# domainNamespaceLabelSelector: "weblogic-operator" +# +# domainNamespaceLabelSelector: + +# domainNamespaceRegExp specifies a regular expression that will be matched against namespace names when listing +# namespaces in search of the namespaces that contain WebLogic Domains that this operator will manage. Ignored +# if 'domainNamespaceSelectionStrategy' is not 'RegExp'. +# +# Example: manage any namespace where the namespace name starts with "prod". +# +# domainNamespaceRegExp: "^prod" +# +# domainNamespaceRegExp: + +# enableClusterRoleBinding specifies whether the roles necessary for the operator to manage domains +# will be granted using a ClusterRoleBinding rather than using RoleBindings in each managed namespace. +enableClusterRoleBinding: false + +# image specifies the container image containing the operator. +image: "ghcr.io/oracle/weblogic-kubernetes-operator:3.3.0" + +# imagePullPolicy specifies the image pull policy for the operator's container image. +imagePullPolicy: IfNotPresent + +# imagePullSecrets contains an optional list of Kubernetes Secrets, in the operator's namespace, +# that are needed to access the registry containing the operator's container image. +# The customer is responsible for creating the Secret. +# If no Secrets are required, then omit this property. +# +# Example: a Secret is needed, and has been stored in 'my-operator-secret' +# +# imagePullSecrets: +# - name: "my-operator-secret" + +# externalRestEnabled specifies whether the the operator's REST interface is exposed +# outside of the Kubernetes cluster on the port specified by the 'externalRestHttpsPort' +# property. +# +# If set to true, then the customer must provide the SSL certificate and private key for +# the operator's external REST interface by specifying the 'externalOperatorCert' and +# 'externalOperatorKey' properties. +externalRestEnabled: false + +# externalRestHttpsPort specifies the node port that should be allocated for the external operator REST HTTPS interface. +# This parameter is required if 'externalRestEnabled' is true. +# Otherwise, it is ignored. +externalRestHttpsPort: 31001 + +# The name of the Secret used to store the certificate and private key to use for the external operator REST HTTPS interface. +# The Secret has to be created in the same namespace of the WebLogic operator. +# This parameter is required if 'externalRestEnabled' is true. Otherwise, it is ignored. +# As example, an external REST identity can be created using the following sample script +# kubernetes/samples/scripts/rest/generate-external-rest-identity.sh +# externalRestIdentitySecret: + +# elkIntegrationEnabled specifies whether or not ELK integration is enabled. +elkIntegrationEnabled: false + +# logStashImage specifies the container image containing logstash. +# This parameter is ignored if 'elkIntegrationEnabled' is false. +logStashImage: "logstash:6.6.0" + +# elasticSearchHost specifies the hostname of where elasticsearch is running. +# This parameter is ignored if 'elkIntegrationEnabled' is false. +elasticSearchHost: "elasticsearch.default.svc.cluster.local" + +# elasticSearchPort specifies the port number of where elasticsearch is running. +# This parameter is ignored if 'elkIntegrationEnabled' is false. +elasticSearchPort: 9200 + +# featureGates specifies a set of key=value pairs separated by commas that describe whether a given +# operator feature is enabled. You enable a feature by including a key=value pair where the key is the +# feature name and the value is "true". This will allow the operator team to release features that +# are not yet ready to be enabled by default, but that are ready for testing by customers. Once a feature is +# stable then it will be enabled by default and can not be disabled using this configuration. +# featureGates: "...,AuxiliaryImage=true" + +# javaLoggingLevel specifies the Java logging level for the operator. This affects the operator pod's +# log output and the contents of log files in the container's /logs/ directory. +# Valid values are: "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", and "FINEST". +javaLoggingLevel: "INFO" + +# javaLoggingFileSizeLimit specifies the maximum size in bytes for an individual Java logging file in the operator container's +# /logs/ directory. +javaLoggingFileSizeLimit: 20000000 + +# javaLoggingFileCount specifies the number of Java logging files to preserve in the operator container's /logs/ +# directory as the files are rotated. +javaLoggingFileCount: 10 + +# labels specifies a set of key-value labels that will be added to each pod running the operator. +# See https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +#labels: + +# annotations specifies a set of key-value annotations that will be added to each pod running the operator. +# See https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +#annotations: + +# nodeSelector specifies a matching rule that the Kubernetes scheduler will use when selecting the node +# where the operator will run. If the nodeSelector value is specified, then this content will be added to +# the operator's deployment. See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector +# for more information on node selectors. +#nodeSelector: + +# affinity specifies a set of matching rules related to the presence of other workloads that the Kubernetes scheduler +# will use when selecting the node where the operator will run. If the affinity value is specified, then this content +# will be added to the operator's deployment. See https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity +# for more information on affinity and anti-affinity. +#affinity: + +# Values related to debugging the operator. +# Customers should not need to use the following properties + +# remoteDebugNodePortEnabled specifies whether or not the operator will provide a Java remote debug interface on the +# provided port. If the 'suspendOnDebugStartup' property is specified, the operator will suspend execution +# until a remote debugger has attached. +# The 'internalDebugHttpPort' property controls the port number inside the Kubernetes +# cluster and the 'externalDebugHttpPort' property controls the port number outside +# the Kubernetes cluster. +remoteDebugNodePortEnabled: false + +#suspendOnDebugStartup specifies whether the operator will suspend on startup when a Java remote debugging is enabled. +suspendOnDebugStartup: false + +# internalDebugHttpPort specifies the port number inside the Kubernetes cluster for the operator's Java +# remote debug interface. +# This parameter is required if 'remoteDebugNodePortEnabled' is true. +# Otherwise, it is ignored. +internalDebugHttpPort: 30999 + +# externalDebugHttpPort specifies the node port that should be allocated for the operator's +# Java remote debug interface. +# This parameter is required if 'remoteDebugNodePortEnabled' is true. +# Otherwise, it is ignored. +externalDebugHttpPort: 30999 + +# dns1123Fields overrides the default list of field names that the operator +# converts to DNS-1123 legal values when replacing variable references in the +# Domain resource. The default list can be found inside the class LegalNames +# in the oracle.kubernetes.operator.helpers package. +# Supply a comma separated list of field names to customize the list of fields +# such as "name, claimName, volumeName", or leave it commented out to use +# the default list of field names. +# dns1123Fields: "" + +# introspectorJobNameSuffix overrides the default suffix that the operator uses +# to append to the domainUID to form the name of the domain introspector job name. +# Note that the resultant job name should not be more than 58 characters due to +# the Kubernetes limit to the name of a job and Kubernetes appends five additional +# characters to the name of the pod that is created by the job controller. +# The default suffix is '-introspector'. +# The default suffix in pre-3.1.0 is "-introspect-domain-job" +introspectorJobNameSuffix: "-introspector" + +# externalServiceNameSuffix overrides the default suffix that the operator uses +# to append to the domainUID and the WebLogic admin server name, to form the name +# of the domain's admin server external service. +# Note that the resultant name should not be more than 63 characters due to +# the Kubernetes limit to the name of a service. +# The default suffix is '-ext'. +# The default suffix in pre-3.1.0 is "-external". +externalServiceNameSuffix: "-ext" + +# clusterSizePaddingValidationEnabled specifies if additional one or two characters +# need to be reserved to account for longer managed server names because of an increased +# cluster size. +# The default value is true. +clusterSizePaddingValidationEnabled: true + +# tokenReviewAuthentication, if set to true, specifies whether the the operator's REST API should use +# 1. Kubernetes token review API for authenticating users, and +# 2. Kubernetes subject access review API for authorizing a user's operation (get, list, +# patch, etc) on a resource. +# 3. Update the Domain resource using the operator's privileges. +# This parameter, if set to false, will use the caller's bearer token for any update +# to the Domain resource so that it is done using the caller's privileges. +# The default value is false. +#tokenReviewAuthentication: false diff --git a/OracleWebCenterPortal/kubernetes/common/createFMWJRFDomain.py b/OracleWebCenterPortal/kubernetes/common/createFMWJRFDomain.py new file mode 100644 index 000000000..bde936ca5 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/createFMWJRFDomain.py @@ -0,0 +1,332 @@ +# Copyright (c) 2014, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +import os +import sys + +import com.oracle.cie.domain.script.jython.WLSTException as WLSTException + +class Infra12213Provisioner: + + MACHINES = { + 'machine1' : { + 'NMType': 'SSL', + 'ListenAddress': 'localhost', + 'ListenPort': 5658 + } + } + + JRF_12213_TEMPLATES = { + 'baseTemplate' : '@@ORACLE_HOME@@/wlserver/common/templates/wls/wls.jar', + 'extensionTemplates' : [ + '@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.jrf_template.jar', + '@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.jrf.ws.async_template.jar', + '@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.wsmpm_template.jar', + '@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.ums_template.jar', + '@@ORACLE_HOME@@/em/common/templates/wls/oracle.em_wls_template.jar' + ], + 'serverGroupsToTarget' : [ 'JRF-MAN-SVR', 'WSMPM-MAN-SVR' ] + } + + def __init__(self, oracleHome, javaHome, domainParentDir, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName): + self.oracleHome = self.validateDirectory(oracleHome) + self.javaHome = self.validateDirectory(javaHome) + self.domainParentDir = self.validateDirectory(domainParentDir, create=True) + return + + def createInfraDomain(self, domainName, user, password, db, dbPrefix, dbPassword, adminListenPort, adminName, + managedNameBase, managedServerPort, prodMode, managedCount, clusterName, + exposeAdminT3Channel=None, t3ChannelPublicAddress=None, t3ChannelPort=None): + domainHome = self.createBaseDomain(domainName, user, password, adminListenPort, adminName, managedNameBase, + managedServerPort, prodMode, managedCount, clusterName + ) + self.extendDomain(domainHome, db, dbPrefix, dbPassword, exposeAdminT3Channel, t3ChannelPublicAddress, + t3ChannelPort) + + def createBaseDomain(self, domainName, user, password, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName): + baseTemplate = self.replaceTokens(self.JRF_12213_TEMPLATES['baseTemplate']) + + readTemplate(baseTemplate) + setOption('DomainName', domainName) + setOption('JavaHome', self.javaHome) + if (prodMode == 'true'): + setOption('ServerStartMode', 'prod') + else: + setOption('ServerStartMode', 'dev') + set('Name', domainName) + + admin_port = int(adminListenPort) + ms_port = int(managedServerPort) + ms_count = int(managedCount) + + # Create Admin Server + # ======================= + print 'Creating Admin Server...' + cd('/Servers/AdminServer') + #set('ListenAddress', '%s-%s' % (domain_uid, admin_server_name_svc)) + set('ListenPort', admin_port) + set('Name', adminName) + + # Define the user password for weblogic + # ===================================== + cd('/Security/' + domainName + '/User/weblogic') + set('Name', user) + set('Password', password) + + # Create a cluster + # ====================== + print 'Creating cluster...' + cd('/') + cl=create(clusterName, 'Cluster') + + # Create managed servers + for index in range(0, ms_count): + cd('/') + msIndex = index+1 + cd('/') + name = '%s%s' % (managedNameBase, msIndex) + create(name, 'Server') + cd('/Servers/%s/' % name ) + print('managed server name is %s' % name); + set('ListenPort', ms_port) + set('NumOfRetriesBeforeMSIMode', 0) + set('RetryIntervalBeforeMSIMode', 1) + set('Cluster', clusterName) + + # Create Node Manager + # ======================= + print 'Creating Node Managers...' + for machine in self.MACHINES: + cd('/') + create(machine, 'Machine') + cd('Machine/' + machine) + create(machine, 'NodeManager') + cd('NodeManager/' + machine) + for param in self.MACHINES[machine]: + set(param, self.MACHINES[machine][param]) + + + setOption('OverwriteDomain', 'true') + domainHome = self.domainParentDir + '/' + domainName + print 'Will create Base domain at ' + domainHome + + print 'Writing base domain...' + writeDomain(domainHome) + closeTemplate() + print 'Base domain created at ' + domainHome + return domainHome + + + def extendDomain(self, domainHome, db, dbPrefix, dbPassword, exposeAdminT3Channel, t3ChannelPublicAddress, + t3ChannelPort): + print 'Extending domain at ' + domainHome + print 'Database ' + db + readDomain(domainHome) + setOption('AppDir', self.domainParentDir + '/applications') + + print 'ExposeAdminT3Channel %s with %s:%s ' % (exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) + if 'true' == exposeAdminT3Channel: + self.enable_admin_channel(t3ChannelPublicAddress, t3ChannelPort) + + print 'Applying JRF templates...' + for extensionTemplate in self.JRF_12213_TEMPLATES['extensionTemplates']: + addTemplate(self.replaceTokens(extensionTemplate)) + + print 'Extension Templates added' + + print 'Configuring the Service Table DataSource...' + fmwDb = 'jdbc:oracle:thin:@' + db + print 'fmwDatabase ' + fmwDb + cd('/JDBCSystemResource/LocalSvcTblDataSource/JdbcResource/LocalSvcTblDataSource') + cd('JDBCDriverParams/NO_NAME_0') + set('DriverName', 'oracle.jdbc.OracleDriver') + set('URL', fmwDb) + set('PasswordEncrypted', dbPassword) + + stbUser = dbPrefix + '_STB' + cd('Properties/NO_NAME_0/Property/user') + set('Value', stbUser) + + print 'Getting Database Defaults...' + getDatabaseDefaults() + + print 'Targeting Server Groups...' + managedName= '%s%s' % (managedNameBase, 1) + print "Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:" + managedName + serverGroupsToTarget = list(self.JRF_12213_TEMPLATES['serverGroupsToTarget']) + cd('/') + setServerGroups(managedName, serverGroupsToTarget) + print "Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:" + managedName + cd('/Servers/' + managedName) + set('CoherenceClusterSystemResource', 'defaultCoherenceCluster') + + print 'Targeting Cluster ...' + cd('/') + print "Set CoherenceClusterSystemResource to defaultCoherenceCluster for cluster:" + clusterName + cd('/Cluster/' + clusterName) + set('CoherenceClusterSystemResource', 'defaultCoherenceCluster') + print "Set WLS clusters as target of defaultCoherenceCluster:" + clusterName + cd('/CoherenceClusterSystemResource/defaultCoherenceCluster') + set('Target', clusterName) + + print 'Preparing to update domain...' + updateDomain() + print 'Domain updated successfully' + closeDomain() + return + + + ########################################################################### + # Helper Methods # + ########################################################################### + + def validateDirectory(self, dirName, create=False): + directory = os.path.realpath(dirName) + if not os.path.exists(directory): + if create: + os.makedirs(directory) + else: + message = 'Directory ' + directory + ' does not exist' + raise WLSTException(message) + elif not os.path.isdir(directory): + message = 'Directory ' + directory + ' is not a directory' + raise WLSTException(message) + return self.fixupPath(directory) + + + def fixupPath(self, path): + result = path + if path is not None: + result = path.replace('\\', '/') + return result + + + def replaceTokens(self, path): + result = path + if path is not None: + result = path.replace('@@ORACLE_HOME@@', oracleHome) + return result + + def enable_admin_channel(self, admin_channel_address, admin_channel_port): + if admin_channel_address == None or admin_channel_port == 'None': + return + cd('/') + admin_server_name = get('AdminServerName') + print('setting admin server t3channel for ' + admin_server_name) + cd('/Servers/' + admin_server_name) + create('T3Channel', 'NetworkAccessPoint') + cd('/Servers/' + admin_server_name + '/NetworkAccessPoint/T3Channel') + set('ListenPort', int(admin_channel_port)) + set('PublicPort', int(admin_channel_port)) + set('PublicAddress', admin_channel_address) + +############################# +# Entry point to the script # +############################# + +def usage(): + print sys.argv[0] + ' -oh -jh -parent -name ' + \ + '-user -password ' + \ + '-rcuDb -rcuPrefix -rcuSchemaPwd ' \ + '-adminListenPort -adminName ' \ + '-managedNameBase -managedServerPort -prodMode ' \ + '-managedServerCount -clusterName ' \ + '-exposeAdminT3Channel -t3ChannelPublicAddress
' \ + '-t3ChannelPort ' + sys.exit(0) + +# Uncomment for Debug only +#print str(sys.argv[0]) + " called with the following sys.argv array:" +#for index, arg in enumerate(sys.argv): +# print "sys.argv[" + str(index) + "] = " + str(sys.argv[index]) + +if len(sys.argv) < 16: + usage() + +#oracleHome will be passed by command line parameter -oh. +oracleHome = None +#javaHome will be passed by command line parameter -jh. +javaHome = None +#domainParentDir will be passed by command line parameter -parent. +domainParentDir = None +#domainUser is hard-coded to weblogic. You can change to other name of your choice. Command line paramter -user. +domainUser = 'weblogic' +#domainPassword will be passed by Command line parameter -password. +domainPassword = None +#rcuDb will be passed by command line parameter -rcuDb. +rcuDb = None +#change rcuSchemaPrefix to your infra schema prefix. Command line parameter -rcuPrefix. +rcuSchemaPrefix = 'DEV12' +#change rcuSchemaPassword to your infra schema password. Command line parameter -rcuSchemaPwd. +rcuSchemaPassword = None +exposeAdminT3Channel = None +t3ChannelPort = None +t3ChannelPublicAddress = None +i = 1 +while i < len(sys.argv): + if sys.argv[i] == '-oh': + oracleHome = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-jh': + javaHome = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-parent': + domainParentDir = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-name': + domainName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-user': + domainUser = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-password': + domainPassword = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-rcuDb': + rcuDb = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-rcuPrefix': + rcuSchemaPrefix = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-rcuSchemaPwd': + rcuSchemaPassword = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-adminListenPort': + adminListenPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-adminName': + adminName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-managedNameBase': + managedNameBase = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-managedServerPort': + managedServerPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-prodMode': + prodMode = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-managedServerCount': + managedCount = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-clusterName': + clusterName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-t3ChannelPublicAddress': + t3ChannelPublicAddress = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-t3ChannelPort': + t3ChannelPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-exposeAdminT3Channel': + exposeAdminT3Channel = sys.argv[i + 1] + i += 2 + else: + print 'Unexpected argument switch at position ' + str(i) + ': ' + str(sys.argv[i]) + usage() + sys.exit(1) + +provisioner = Infra12213Provisioner(oracleHome, javaHome, domainParentDir, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName) +provisioner.createInfraDomain(domainName, domainUser, domainPassword, rcuDb, rcuSchemaPrefix, rcuSchemaPassword, + adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, + clusterName, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) \ No newline at end of file diff --git a/OracleWebCenterPortal/kubernetes/common/createFMWRestrictedJRFDomain.py b/OracleWebCenterPortal/kubernetes/common/createFMWRestrictedJRFDomain.py new file mode 100644 index 000000000..acfe5da80 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/createFMWRestrictedJRFDomain.py @@ -0,0 +1,291 @@ +# Copyright (c) 2014, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +import os +import sys + +import com.oracle.cie.domain.script.jython.WLSTException as WLSTException + +class Infra12213Provisioner: + + MACHINES = { + 'machine1' : { + 'NMType': 'SSL', + 'ListenAddress': 'localhost', + 'ListenPort': 5658 + } + } + + JRF_12213_TEMPLATES = { + 'baseTemplate' : '@@ORACLE_HOME@@/wlserver/common/templates/wls/wls.jar', + 'extensionTemplates' : [ + '@@ORACLE_HOME@@/oracle_common/common/templates/wls/oracle.jrf_restricted_template.jar', + '@@ORACLE_HOME@@/em/common/templates/wls/oracle.em_wls_restricted_template.jar' + ], + 'serverGroupsToTarget' : [ 'JRF-MAN-SVR', 'WSMPM-MAN-SVR' ] + } + + def __init__(self, oracleHome, javaHome, domainParentDir, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName): + self.oracleHome = self.validateDirectory(oracleHome) + self.javaHome = self.validateDirectory(javaHome) + self.domainParentDir = self.validateDirectory(domainParentDir, create=True) + return + + def createInfraDomain(self, domainName, user, password, adminListenPort, adminName, + managedNameBase, managedServerPort, prodMode, managedCount, clusterName, + exposeAdminT3Channel=None, t3ChannelPublicAddress=None, t3ChannelPort=None): + domainHome = self.createBaseDomain(domainName, user, password, adminListenPort, adminName, managedNameBase, + managedServerPort, prodMode, managedCount, clusterName + ) + self.extendDomain(domainHome, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) + + def createBaseDomain(self, domainName, user, password, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName): + baseTemplate = self.replaceTokens(self.JRF_12213_TEMPLATES['baseTemplate']) + + readTemplate(baseTemplate) + setOption('DomainName', domainName) + setOption('JavaHome', self.javaHome) + if (prodMode == 'true'): + setOption('ServerStartMode', 'prod') + else: + setOption('ServerStartMode', 'dev') + set('Name', domainName) + + admin_port = int(adminListenPort) + ms_port = int(managedServerPort) + ms_count = int(managedCount) + + # Create Admin Server + # ======================= + print 'Creating Admin Server...' + cd('/Servers/AdminServer') + #set('ListenAddress', '%s-%s' % (domain_uid, admin_server_name_svc)) + set('ListenPort', admin_port) + set('Name', adminName) + + # Define the user password for weblogic + # ===================================== + cd('/Security/' + domainName + '/User/weblogic') + set('Name', user) + set('Password', password) + + # Create a cluster + # ====================== + print 'Creating cluster...' + cd('/') + cl=create(clusterName, 'Cluster') + + # Create managed servers + for index in range(0, ms_count): + cd('/') + msIndex = index+1 + cd('/') + name = '%s%s' % (managedNameBase, msIndex) + create(name, 'Server') + cd('/Servers/%s/' % name ) + print('managed server name is %s' % name); + set('ListenPort', ms_port) + set('NumOfRetriesBeforeMSIMode', 0) + set('RetryIntervalBeforeMSIMode', 1) + set('Cluster', clusterName) + + # Create Node Manager + # ======================= + print 'Creating Node Managers...' + for machine in self.MACHINES: + cd('/') + create(machine, 'Machine') + cd('Machine/' + machine) + create(machine, 'NodeManager') + cd('NodeManager/' + machine) + for param in self.MACHINES[machine]: + set(param, self.MACHINES[machine][param]) + + + setOption('OverwriteDomain', 'true') + domainHome = self.domainParentDir + '/' + domainName + print 'Will create Base domain at ' + domainHome + + print 'Writing base domain...' + writeDomain(domainHome) + closeTemplate() + print 'Base domain created at ' + domainHome + return domainHome + + + def extendDomain(self, domainHome, exposeAdminT3Channel, t3ChannelPublicAddress, + t3ChannelPort): + print 'Extending domain at ' + domainHome + readDomain(domainHome) + setOption('AppDir', self.domainParentDir + '/applications') + + print 'ExposeAdminT3Channel %s with %s:%s ' % (exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) + if 'true' == exposeAdminT3Channel: + self.enable_admin_channel(t3ChannelPublicAddress, t3ChannelPort) + + print 'Applying JRF templates...' + for extensionTemplate in self.JRF_12213_TEMPLATES['extensionTemplates']: + addTemplate(self.replaceTokens(extensionTemplate)) + + print 'Extension Templates added' + + print 'Preparing to update domain...' + updateDomain() + print 'Domain updated successfully' + closeDomain() + return + + + ########################################################################### + # Helper Methods # + ########################################################################### + + def validateDirectory(self, dirName, create=False): + directory = os.path.realpath(dirName) + if not os.path.exists(directory): + if create: + os.makedirs(directory) + else: + message = 'Directory ' + directory + ' does not exist' + raise WLSTException(message) + elif not os.path.isdir(directory): + message = 'Directory ' + directory + ' is not a directory' + raise WLSTException(message) + return self.fixupPath(directory) + + + def fixupPath(self, path): + result = path + if path is not None: + result = path.replace('\\', '/') + return result + + + def replaceTokens(self, path): + result = path + if path is not None: + result = path.replace('@@ORACLE_HOME@@', oracleHome) + return result + + def enable_admin_channel(self, admin_channel_address, admin_channel_port): + if admin_channel_address == None or admin_channel_port == 'None': + return + cd('/') + admin_server_name = get('AdminServerName') + print('setting admin server t3channel for ' + admin_server_name) + cd('/Servers/' + admin_server_name) + create('T3Channel', 'NetworkAccessPoint') + cd('/Servers/' + admin_server_name + '/NetworkAccessPoint/T3Channel') + set('ListenPort', int(admin_channel_port)) + set('PublicPort', int(admin_channel_port)) + set('PublicAddress', admin_channel_address) + +############################# +# Entry point to the script # +############################# + +def usage(): + print sys.argv[0] + ' -oh -jh -parent -name ' + \ + '-user -password ' + \ + '-rcuDb -rcuPrefix -rcuSchemaPwd ' \ + '-adminListenPort -adminName ' \ + '-managedNameBase -managedServerPort -prodMode ' \ + '-managedServerCount -clusterName ' \ + '-exposeAdminT3Channel -t3ChannelPublicAddress
' \ + '-t3ChannelPort ' + sys.exit(0) + +# Uncomment for Debug only +#print str(sys.argv[0]) + " called with the following sys.argv array:" +#for index, arg in enumerate(sys.argv): +# print "sys.argv[" + str(index) + "] = " + str(sys.argv[index]) + +if len(sys.argv) < 16: + usage() + +#oracleHome will be passed by command line parameter -oh. +oracleHome = None +#javaHome will be passed by command line parameter -jh. +javaHome = None +#domainParentDir will be passed by command line parameter -parent. +domainParentDir = None +#domainUser is hard-coded to weblogic. You can change to other name of your choice. Command line paramter -user. +domainUser = 'weblogic' +#domainPassword will be passed by Command line parameter -password. +domainPassword = None +#rcuDb will be passed by command line parameter -rcuDb. +rcuDb = None +#change rcuSchemaPrefix to your infra schema prefix. Command line parameter -rcuPrefix. +rcuSchemaPrefix = 'DEV12' +#change rcuSchemaPassword to your infra schema password. Command line parameter -rcuSchemaPwd. +rcuSchemaPassword = None +exposeAdminT3Channel = None +t3ChannelPort = None +t3ChannelPublicAddress = None +i = 1 +while i < len(sys.argv): + if sys.argv[i] == '-oh': + oracleHome = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-jh': + javaHome = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-parent': + domainParentDir = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-name': + domainName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-user': + domainUser = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-password': + domainPassword = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-rcuDb': + rcuDb = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-rcuPrefix': + rcuSchemaPrefix = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-rcuSchemaPwd': + rcuSchemaPassword = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-adminListenPort': + adminListenPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-adminName': + adminName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-managedNameBase': + managedNameBase = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-managedServerPort': + managedServerPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-prodMode': + prodMode = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-managedServerCount': + managedCount = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-clusterName': + clusterName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-t3ChannelPublicAddress': + t3ChannelPublicAddress = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-t3ChannelPort': + t3ChannelPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-exposeAdminT3Channel': + exposeAdminT3Channel = sys.argv[i + 1] + i += 2 + else: + print 'Unexpected argument switch at position ' + str(i) + ': ' + str(sys.argv[i]) + usage() + sys.exit(1) + +provisioner = Infra12213Provisioner(oracleHome, javaHome, domainParentDir, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName) +provisioner.createInfraDomain(domainName, domainUser, domainPassword, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, + clusterName, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) diff --git a/OracleWebCenterPortal/kubernetes/common/domain-template.yaml b/OracleWebCenterPortal/kubernetes/common/domain-template.yaml new file mode 100644 index 000000000..2d081de7d --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/domain-template.yaml @@ -0,0 +1,119 @@ +# Copyright (c) 2017, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# This is an example of how to define a Domain resource. +# +apiVersion: "weblogic.oracle/v8" +kind: Domain +metadata: + name: %DOMAIN_UID% + namespace: %NAMESPACE% + labels: + weblogic.domainUID: %DOMAIN_UID% +spec: + # The WebLogic Domain Home + domainHome: %DOMAIN_HOME% + + # The domain home source type + # Set to PersistentVolume for domain-in-pv, Image for domain-in-image, or FromModel for model-in-image + domainHomeSourceType: %DOMAIN_HOME_SOURCE_TYPE% + + # The WebLogic Server image that the Operator uses to start the domain + image: "%WEBLOGIC_IMAGE%" + + # imagePullPolicy defaults to "Always" if image version is :latest + imagePullPolicy: "%WEBLOGIC_IMAGE_PULL_POLICY%" + + # Identify which Secret contains the credentials for pulling an image + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%imagePullSecrets: + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%- name: %WEBLOGIC_IMAGE_PULL_SECRET_NAME% + + # Identify which Secret contains the WebLogic Admin credentials (note that there is an example of + # how to create that Secret at the end of this file) + webLogicCredentialsSecret: + name: %WEBLOGIC_CREDENTIALS_SECRET_NAME% + + # Whether to include the server out file into the pod's stdout, default is true + includeServerOutInPodLog: %INCLUDE_SERVER_OUT_IN_POD_LOG% + + # Whether to enable log home + %LOG_HOME_ON_PV_PREFIX%logHomeEnabled: %LOG_HOME_ENABLED% + + # Whether to write HTTP access log file to log home + %LOG_HOME_ON_PV_PREFIX%httpAccessLogInLogHome: %HTTP_ACCESS_LOG_IN_LOG_HOME% + + # The in-pod location for domain log, server logs, server out, introspector out, and Node Manager log files + %LOG_HOME_ON_PV_PREFIX%logHome: %LOG_HOME% + # An (optional) in-pod location for data storage of default and custom file stores. + # If not specified or the value is either not set or empty (e.g. dataHome: "") then the + # data storage directories are determined from the WebLogic domain home configuration. + dataHome: "%DATA_HOME%" + + + # serverStartPolicy legal values are "NEVER", "IF_NEEDED", or "ADMIN_ONLY" + # This determines which WebLogic Servers the Operator will start up when it discovers this Domain + # - "NEVER" will not start any server in the domain + # - "ADMIN_ONLY" will start up only the administration server (no managed servers will be started) + # - "IF_NEEDED" will start all non-clustered servers, including the administration server and clustered servers up to the replica count + serverStartPolicy: "%SERVER_START_POLICY%" + + serverPod: + # an (optional) list of environment variable to be set on the servers + env: + - name: JAVA_OPTIONS + value: "%JAVA_OPTIONS%" + - name: USER_MEM_ARGS + value: "-Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx512m " + %OPTIONAL_SERVERPOD_RESOURCES% + %LOG_HOME_ON_PV_PREFIX%volumes: + %LOG_HOME_ON_PV_PREFIX%- name: weblogic-domain-storage-volume + %LOG_HOME_ON_PV_PREFIX% persistentVolumeClaim: + %LOG_HOME_ON_PV_PREFIX% claimName: %DOMAIN_PVC_NAME% + %LOG_HOME_ON_PV_PREFIX%volumeMounts: + %LOG_HOME_ON_PV_PREFIX%- mountPath: %DOMAIN_ROOT_DIR% + %LOG_HOME_ON_PV_PREFIX% name: weblogic-domain-storage-volume + + # adminServer is used to configure the desired behavior for starting the administration server. + adminServer: + # serverStartState legal values are "RUNNING" or "ADMIN" + # "RUNNING" means the listed server will be started up to "RUNNING" mode + # "ADMIN" means the listed server will be start up to "ADMIN" mode + serverStartState: "RUNNING" + %EXPOSE_ANY_CHANNEL_PREFIX%adminService: + %EXPOSE_ANY_CHANNEL_PREFIX% channels: + # The Admin Server's NodePort + %EXPOSE_ADMIN_PORT_PREFIX% - channelName: default + %EXPOSE_ADMIN_PORT_PREFIX% nodePort: %ADMIN_NODE_PORT% + # Uncomment to export the T3Channel as a service + %EXPOSE_T3_CHANNEL_PREFIX% - channelName: T3Channel + + # clusters is used to configure the desired behavior for starting member servers of a cluster. + # If you use this entry, then the rules will be applied to ALL servers that are members of the named clusters. + clusters: + - clusterName: %CLUSTER_NAME% + serverStartState: "RUNNING" + serverPod: + # Instructs Kubernetes scheduler to prefer nodes for new cluster members where there are not + # already members of the same cluster. + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: "weblogic.clusterName" + operator: In + values: + - $(CLUSTER_NAME) + topologyKey: "kubernetes.io/hostname" + replicas: %INITIAL_MANAGED_SERVER_REPLICAS% + # The number of managed servers to start for unlisted clusters + # replicas: 1 + + # Istio + %ISTIO_PREFIX%configuration: + %ISTIO_PREFIX% istio: + %ISTIO_PREFIX% enabled: %ISTIO_ENABLED% + %ISTIO_PREFIX% readinessPort: %ISTIO_READINESS_PORT% + diff --git a/OracleWebCenterPortal/kubernetes/common/jrf-domain-template.yaml b/OracleWebCenterPortal/kubernetes/common/jrf-domain-template.yaml new file mode 100644 index 000000000..ccd35b84f --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/jrf-domain-template.yaml @@ -0,0 +1,123 @@ +# Copyright (c) 2017, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# This is an example of how to define a Domain resource. +# +apiVersion: "weblogic.oracle/v8" +kind: Domain +metadata: + name: %DOMAIN_UID% + namespace: %NAMESPACE% + labels: + weblogic.domainUID: %DOMAIN_UID% +spec: + # The WebLogic Domain Home + domainHome: %DOMAIN_HOME% + + # The domain home source type + # Set to PersistentVolume for domain-in-pv, Image for domain-in-image, or FromModel for model-in-image + domainHomeSourceType: %DOMAIN_HOME_SOURCE_TYPE% + + # The WebLogic Server image that the Operator uses to start the domain + image: "%WEBLOGIC_IMAGE%" + + # imagePullPolicy defaults to "Always" if image version is :latest + imagePullPolicy: "%WEBLOGIC_IMAGE_PULL_POLICY%" + + # Identify which Secret contains the credentials for pulling an image + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%imagePullSecrets: + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%- name: %WEBLOGIC_IMAGE_PULL_SECRET_NAME% + + # Identify which Secret contains the WebLogic Admin credentials (note that there is an example of + # how to create that Secret at the end of this file) + webLogicCredentialsSecret: + name: %WEBLOGIC_CREDENTIALS_SECRET_NAME% + + # Whether to include the server out file into the pod's stdout, default is true + includeServerOutInPodLog: %INCLUDE_SERVER_OUT_IN_POD_LOG% + + # Whether to enable log home + %LOG_HOME_ON_PV_PREFIX%logHomeEnabled: %LOG_HOME_ENABLED% + + # Whether to write HTTP access log file to log home + %LOG_HOME_ON_PV_PREFIX%httpAccessLogInLogHome: %HTTP_ACCESS_LOG_IN_LOG_HOME% + + # The in-pod location for domain log, server logs, server out, introspector out, and Node Manager log files + %LOG_HOME_ON_PV_PREFIX%logHome: %LOG_HOME% + # An (optional) in-pod location for data storage of default and custom file stores. + # If not specified or the value is either not set or empty (e.g. dataHome: "") then the + # data storage directories are determined from the WebLogic domain home configuration. + dataHome: "%DATA_HOME%" + + # serverStartPolicy legal values are "NEVER", "IF_NEEDED", or "ADMIN_ONLY" + # This determines which WebLogic Servers the Operator will start up when it discovers this Domain + # - "NEVER" will not start any server in the domain + # - "ADMIN_ONLY" will start up only the administration server (no managed servers will be started) + # - "IF_NEEDED" will start all non-clustered servers, including the administration server and clustered servers up to the replica count + serverStartPolicy: "%SERVER_START_POLICY%" + + serverPod: + # an (optional) list of environment variable to be set on the servers + env: + - name: JAVA_OPTIONS + value: "%JAVA_OPTIONS%" + - name: USER_MEM_ARGS + value: "-Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx1024m " + %OPTIONAL_SERVERPOD_RESOURCES% + %LOG_HOME_ON_PV_PREFIX%volumes: + %LOG_HOME_ON_PV_PREFIX%- name: weblogic-domain-storage-volume + %LOG_HOME_ON_PV_PREFIX% persistentVolumeClaim: + %LOG_HOME_ON_PV_PREFIX% claimName: %DOMAIN_PVC_NAME% + %LOG_HOME_ON_PV_PREFIX%volumeMounts: + %LOG_HOME_ON_PV_PREFIX%- mountPath: %DOMAIN_ROOT_DIR% + %LOG_HOME_ON_PV_PREFIX% name: weblogic-domain-storage-volume + + # adminServer is used to configure the desired behavior for starting the administration server. + adminServer: + # serverStartState legal values are "RUNNING" or "ADMIN" + # "RUNNING" means the listed server will be started up to "RUNNING" mode + # "ADMIN" means the listed server will be start up to "ADMIN" mode + serverStartState: "RUNNING" + %EXPOSE_ANY_CHANNEL_PREFIX%adminService: + %EXPOSE_ANY_CHANNEL_PREFIX% channels: + # The Admin Server's NodePort + %EXPOSE_ADMIN_PORT_PREFIX% - channelName: default + %EXPOSE_ADMIN_PORT_PREFIX% nodePort: %ADMIN_NODE_PORT% + # Uncomment to export the T3Channel as a service + %EXPOSE_T3_CHANNEL_PREFIX% - channelName: T3Channel + serverPod: + # an (optional) list of environment variable to be set on the admin servers + env: + - name: USER_MEM_ARGS + value: "-Djava.security.egd=file:/dev/./urandom -Xms512m -Xmx1024m " + + # clusters is used to configure the desired behavior for starting member servers of a cluster. + # If you use this entry, then the rules will be applied to ALL servers that are members of the named clusters. + clusters: + - clusterName: %CLUSTER_NAME% + serverStartState: "RUNNING" + serverPod: + # Instructs Kubernetes scheduler to prefer nodes for new cluster members where there are not + # already members of the same cluster. + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: "weblogic.clusterName" + operator: In + values: + - $(CLUSTER_NAME) + topologyKey: "kubernetes.io/hostname" + replicas: %INITIAL_MANAGED_SERVER_REPLICAS% + # The number of managed servers to start for unlisted clusters + # replicas: 1 + + # Istio + %ISTIO_PREFIX%configuration: + %ISTIO_PREFIX% istio: + %ISTIO_PREFIX% enabled: %ISTIO_ENABLED% + %ISTIO_PREFIX% readinessPort: %ISTIO_READINESS_PORT% + diff --git a/OracleWebCenterPortal/kubernetes/common/utility.sh b/OracleWebCenterPortal/kubernetes/common/utility.sh new file mode 100644 index 000000000..979207be2 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/utility.sh @@ -0,0 +1,928 @@ +#!/usr/bin/env bash +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# +# Utility functions that are shared by multiple scripts +# + +# +# Function to exit and print an error message +# $1 - text of message +function fail { + printError $* + exit 1 +} + +# Function to print an error message +function printError { + echo [ERROR] $* +} + +# Function to see if there is more than 1 input file. +# This could happen if the user has a properties file from +# running wdt discover domain on a on-prem domain +function checkInputFiles { + if [[ "${valuesInputFile}" =~ [,] ]] ; then + echo "Found a comma separated list of input files" + IFS=',' + read -a temp <<< "${valuesInputFile}" + + # We want to keep valuesInputFile pointing to the yaml since + # the validate function expects it. + local extension=$(echo "${temp[0]}" | sed 's/^.*\.//') + if [ ${extension} == 'yaml' ]; then + valuesInputFile=${temp[0]} + valuesInputFile1=${temp[1]} + else + valuesInputFile=${temp[1]} + valuesInputFile1=${temp[0]} + fi + fi +} + +# +# Function to parse a yaml file and generate the bash exports +# $1 - Input filename +# $2 - Output filename +function parseYaml { + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ + -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + awk -F$fs '{ + if (length($3) > 0) { + # javaOptions may contain tokens that are not allowed in export command + # we need to handle it differently. + if ($2=="javaOptions") { + printf("%s=%s\n", $2, $3); + } else { + printf("export %s=\"%s\"\n", $2, $3); + } + } + }' > $2 +} + +# +# Function to parse a properties file and generate the bash exports +# $1 - Input filename +# $2 - Output filename +function parseProperties { + while IFS='=' read -r key value + do + echo "export ${key}=\"${value}\"" >> $2 + done < $1 +} + +# +# Function to remove a file if it exists +# +function removeFileIfExists { + if [ -f $1 ]; then + rm $1 + fi +} + +# +# Function to parse the common parameter inputs file +# +function parseCommonInputs { + exportValuesFile=$(mktemp /tmp/export-values-XXXXXXXXX.sh) + tmpFile=$(mktemp /tmp/javaoptions_tmp-XXXXXXXXX.dat) + parseYaml ${valuesInputFile} ${exportValuesFile} + + if [ ! -z ${valuesInputFile1} ]; then + parseProperties ${valuesInputFile1} ${exportValuesFile} + fi + + if [ ! -f ${exportValuesFile} ]; then + echo Unable to locate the parsed output of ${valuesInputFile}. + fail 'The file ${exportValuesFile} could not be found.' + fi + + # Define the environment variables that will be used to fill in template values + echo Input parameters being used + cat ${exportValuesFile} + echo + + # If we have 2 input files, we need to create a combined inputs file + # exportsValueFile contains all the properties already + # We just need to remove the term export from the file + if [ ! -z ${valuesInputFile1} ]; then + propsFile="domain.properties" + cat ${exportValuesFile} > ${propsFile} + sed -i 's/export //g' ${propsFile} + sed -i 's/"//g' ${propsFile} + valuesInputFile=${propsFile} + cat ${valuesInputFile} + fi + + # javaOptions may contain tokens that are not allowed in export command + # we need to handle it differently. + # we set the javaOptions variable that can be used later + tmpStr=`grep "javaOptions" ${exportValuesFile}` + javaOptions=${tmpStr//"javaOptions="/} + + # We exclude javaOptions from the exportValuesFile + grep -v "javaOptions" ${exportValuesFile} > ${tmpFile} + source ${tmpFile} + + rm ${exportValuesFile} ${tmpFile} +} + +# +# Function to delete a kubernetes object +# $1 object type +# $2 object name +# $3 yaml file +function deleteK8sObj { + # If the yaml file does not exist yet, unable to do the delete + if [ ! -f $3 ]; then + fail "Unable to delete object type $1 with name $2 because file $3 does not exist" + fi + + echo Checking if object type $1 with name $2 exists + K8SOBJ=`kubectl get $1 -n ${namespace} | grep $2 | wc | awk ' { print $1; }'` + if [ "${K8SOBJ}" = "1" ]; then + echo Deleting $2 using $3 + kubectl delete -f $3 + fi +} + +# +# Function to lowercase a value +# $1 - value to convert to lowercase +function toLower { + local lc=`echo $1 | tr "[:upper:]" "[:lower:]"` + echo "$lc" +} + +# +# Function to lowercase a value and make it a legal DNS1123 name +# $1 - value to convert to lowercase +function toDNS1123Legal { + local val=`echo $1 | tr "[:upper:]" "[:lower:]"` + val=${val//"_"/"-"} + echo "$val" +} + +# +# Check the state of a persistent volume. +# $1 - name of volume +# $2 - expected state of volume +function checkPvState { + + echo "Checking if the persistent volume ${1:?} is ${2:?}" + local pv_state=`kubectl get pv $1 -o jsonpath='{.status.phase}'` + attempts=0 + while [ ! "$pv_state" = "$2" ] && [ ! $attempts -eq 10 ]; do + attempts=$((attempts + 1)) + sleep 1 + pv_state=`kubectl get pv $1 -o jsonpath='{.status.phase}'` + done + if [ "$pv_state" != "$2" ]; then + fail "The persistent volume state should be $2 but is $pv_state" + fi +} + +# +# Function to check if a persistent volume exists +# $1 - name of volume +function checkPvExists { + + echo "Checking if the persistent volume ${1} exists" + PV_EXISTS=`kubectl get pv | grep ${1} | wc | awk ' { print $1; } '` + if [ "${PV_EXISTS}" = "1" ]; then + echo "The persistent volume ${1} already exists" + PV_EXISTS="true" + else + echo "The persistent volume ${1} does not exist" + PV_EXISTS="false" + fi +} + +# +# Function to check if a persistent volume claim exists +# $1 - name of persistent volume claim +# $2 - NameSpace +function checkPvcExists { + echo "Checking if the persistent volume claim ${1} in NameSpace ${2} exists" + PVC_EXISTS=`kubectl get pvc -n ${2} | grep ${1} | wc | awk ' { print $1; } '` + if [ "${PVC_EXISTS}" = "1" ]; then + echo "The persistent volume claim ${1} already exists in NameSpace ${2}" + PVC_EXISTS="true" + else + echo "The persistent volume claim ${1} does not exist in NameSpace ${2}" + PVC_EXISTS="false" + fi +} + +# Copy the inputs file from the command line into the output directory +# for the domain/operator unless the output directory already has an +# inputs file and the file is the same as the one from the commandline. +# $1 the inputs file from the command line +# $2 the file in the output directory that needs to be made the same as $1 +function copyInputsFileToOutputDirectory { + local from=$1 + local to=$2 + local doCopy="true" + if [ -f "${to}" ]; then + local difference=`diff ${from} ${to}` + if [ -z "${difference}" ]; then + # the output file already exists and is the same as the inputs file. + # don't make a copy. + doCopy="false" + fi + fi + if [ "${doCopy}" = "true" ]; then + cp ${from} ${to} + fi +} + +# +# Function to obtain the IP address of the kubernetes cluster. This information +# is used to form the URL's for accessing services that were deployed. +# +function getKubernetesClusterIP { + + # Get name of the current context + local CUR_CTX=`kubectl config current-context | awk ' { print $1; } '` + + # Get the name of the current cluster + local CUR_CLUSTER_CMD="kubectl config view -o jsonpath='{.contexts[?(@.name == \"${CUR_CTX}\")].context.cluster}' | awk ' { print $1; } '" + local CUR_CLUSTER=`eval ${CUR_CLUSTER_CMD}` + + # Get the server address for the current cluster + local SVR_ADDR_CMD="kubectl config view -o jsonpath='{.clusters[?(@.name == \"${CUR_CLUSTER}\")].cluster.server}' | awk ' { print $1; } '" + local SVR_ADDR=`eval ${SVR_ADDR_CMD}` + + # Server address is expected to be of the form http://address:port. Delimit + # string on the colon to obtain the address. + local array=(${SVR_ADDR//:/ }) + K8S_IP="${array[1]/\/\//}" + +} + +# +# Function to set the serverPodResources variable for including into the generated +# domain.yaml, base on the serverPod resource requests and limits input values, +# if specified. +# The serverPodResources variable remains unset if none of the input values are provided. +# +function buildServerPodResources { + + if [ -n "${serverPodMemoryRequest}" ]; then + local memoryRequest=" memory\: \"${serverPodMemoryRequest}\"\n" + fi + if [ -n "${serverPodCpuRequest}" ]; then + local cpuRequest=" cpu\: \"${serverPodCpuRequest}\"\n" + fi + if [ -n "${memoryRequest}" ] || [ -n "${cpuRequest}" ]; then + local requests=" requests\: \n$memoryRequest $cpuRequest" + fi + + if [ -n "${serverPodMemoryLimit}" ]; then + local memoryLimit=" memory\: \"${serverPodMemoryLimit}\"\n" + fi + if [ -n "${serverPodCpuLimit}" ]; then + local cpuLimit=" cpu\: \"${serverPodCpuLimit}\"\n" + fi + if [ -n "${memoryLimit}" ] || [ -n "${cpuLimit}" ]; then + local limits=" limits\: \n$memoryLimit $cpuLimit" + fi + + if [ -n "${requests}" ] || [ -n "${limits}" ]; then + # build resources element and remove last '\n' + serverPodResources=$(echo "resources\:\n${requests}${limits}" | sed -e 's/\\n$//') + fi +} + +# +# Function to generate the properties and yaml files for creating a domain +# +function createFiles { + + update=false + if [ "$#" == 1 ]; then + echo Trying to update the domain + update=true + fi + + # Make sure the output directory has a copy of the inputs file. + # The user can either pre-create the output directory, put the inputs + # file there, and create the domain from it, or the user can put the + # inputs file some place else and let this script create the output directory + # (if needed) and copy the inputs file there. + echo createFiles - valuesInputFile is ${valuesInputFile} + copyInputsFileToOutputDirectory ${valuesInputFile} "${domainOutputDir}/create-domain-inputs.yaml" + + if [ "${domainHomeInImage}" == "true" ]; then + if [ -z "${domainHomeImageBase}" ]; then + fail "Please specify domainHomeImageBase in your input YAML" + fi + else + if [ -z "${image}" ]; then + fail "Please specify image in your input YAML" + fi + fi + + dcrOutput="${domainOutputDir}/domain.yaml" + + domainName=${domainUID} + + enabledPrefix="" # uncomment the feature + disabledPrefix="# " # comment out the feature + + exposeAnyChannelPrefix="${disabledPrefix}" + if [ "${exposeAdminT3Channel}" = true ]; then + exposeAdminT3ChannelPrefix="${enabledPrefix}" + exposeAnyChannelPrefix="${enabledPrefix}" + # set t3PublicAddress if not set + if [ -z "${t3PublicAddress}" ]; then + getKubernetesClusterIP + t3PublicAddress="${K8S_IP}" + fi + else + exposeAdminT3ChannelPrefix="${disabledPrefix}" + fi + + if [ "${exposeAdminNodePort}" = true ]; then + exposeAdminNodePortPrefix="${enabledPrefix}" + exposeAnyChannelPrefix="${enabledPrefix}" + else + exposeAdminNodePortPrefix="${disabledPrefix}" + fi + + if [ "${istioEnabled}" == "true" ]; then + istioPrefix="${enabledPrefix}" + else + istioPrefix="${disabledPrefix}" + fi + + # The FromModel, MII (model-in-image), and WDT_DOMAIN_TYPE updates in this script + # must remain even though they are not referenced by a sample. They're used by the + # Operator integration test code. If you're interested in MII, + # see './kubernetes/samples/scripts/create-weblogic-domain/model-in-image'. + + # MII settings are used for model-in-image integration testing + if [ "${domainHomeSourceType}" == "FromModel" ]; then + miiPrefix="${enabledPrefix}" + else + miiPrefix="${disabledPrefix}" + fi + + # MII settings are used for model-in-image integration testing + if [ -z "${miiConfigMap}" ]; then + miiConfigMapPrefix="${disabledPrefix}" + else + miiConfigMapPrefix="${enabledPrefix}" + fi + + # For some parameters, use the default value if not defined. + if [ -z "${domainPVMountPath}" ]; then + domainPVMountPath="/shared" + fi + + if [ -z "${logHome}" ]; then + logHome="${domainPVMountPath}/logs/${domainUID}" + fi + + if [ -z "${httpAccessLogInLogHome}" ]; then + httpAccessLogInLogHome="true" + fi + + if [ -z "${dataHome}" ]; then + dataHome="" + fi + + if [ -z "${persistentVolumeClaimName}" ]; then + persistentVolumeClaimName="${domainUID}-weblogic-sample-pvc" + fi + + if [ -z "${weblogicCredentialsSecretName}" ]; then + weblogicCredentialsSecretName="${domainUID}-weblogic-credentials" + fi + + if [ "${domainHomeInImage}" == "true" ]; then + domainPropertiesOutput="${domainOutputDir}/domain.properties" + domainHome="${domainHome:-/u01/oracle/user_projects/domains/${domainName}}" + + # Generate the properties file that will be used when creating the weblogic domain + echo Generating ${domainPropertiesOutput} from ${domainPropertiesInput} + + cp ${domainPropertiesInput} ${domainPropertiesOutput} + sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${domainPropertiesOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_PORT%:${adminPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_SERVER_SSL_PORT%:${adminServerSSLPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_SERVER_NAME%:${adminServerName}:g" ${domainPropertiesOutput} + sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%MANAGED_SERVER_SSL_PORT%:${managedServerSSLPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%MANAGED_SERVER_NAME_BASE%:${managedServerNameBase}:g" ${domainPropertiesOutput} + sed -i -e "s:%CONFIGURED_MANAGED_SERVER_COUNT%:${configuredManagedServerCount}:g" ${domainPropertiesOutput} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${domainPropertiesOutput} + sed -i -e "s:%SSL_ENABLED%:${sslEnabled}:g" ${domainPropertiesOutput} + sed -i -e "s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled}:g" ${domainPropertiesOutput} + sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${domainPropertiesOutput} + sed -i -e "s;%JAVA_OPTIONS%;${javaOptions};g" ${domainPropertiesOutput} + sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${domainPropertiesOutput} + sed -i -e "s:%EXPOSE_T3_CHANNEL%:${exposeAdminT3Channel}:g" ${domainPropertiesOutput} + sed -i -e "s:%FMW_DOMAIN_TYPE%:${fmwDomainType}:g" ${domainPropertiesOutput} + sed -i -e "s:%WDT_DOMAIN_TYPE%:${wdtDomainType}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_USER_NAME%:${username}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_USER_PASS%:${password}:g" ${domainPropertiesOutput} + sed -i -e "s:%RCU_SCHEMA_PREFIX%:${rcuSchemaPrefix}:g" ${domainPropertiesOutput} + sed -i -e "s:%RCU_SCHEMA_PASSWORD%:${rcuSchemaPassword}:g" ${domainPropertiesOutput} + sed -i -e "s|%RCU_DB_CONN_STRING%|${rcuDatabaseURL}|g" ${domainPropertiesOutput} + + if [ -z "${image}" ]; then + # calculate the internal name to tag the generated image + defaultImageName="domain-home-in-image" + baseTag=${domainHomeImageBase#*:} + defaultImageName=${defaultImageName}:${baseTag:-"latest"} + sed -i -e "s|%IMAGE_NAME%|${defaultImageName}|g" ${domainPropertiesOutput} + export BUILD_IMAGE_TAG=${defaultImageName} + else + sed -i -e "s|%IMAGE_NAME%|${image}|g" ${domainPropertiesOutput} + export BUILD_IMAGE_TAG=${image} + fi + else + # we're in the domain in PV case + + wdtVersion="${WDT_VERSION:-${wdtVersion}}" + httpsProxy="${https_proxy}" + + createJobOutput="${domainOutputDir}/create-domain-job.yaml" + deleteJobOutput="${domainOutputDir}/delete-domain-job.yaml" + + if [ -z "${domainHome}" ]; then + domainHome="${domainPVMountPath}/domains/${domainUID}" + fi + + # Use the default value if not defined. + if [ -z "${createDomainScriptsMountPath}" ]; then + createDomainScriptsMountPath="/u01/weblogic" + fi + + if [ "${update}" == "true" ]; then + createDomainScriptName="update-domain-job.sh" + elif [ -z "${createDomainScriptName}" ]; then + createDomainScriptName="create-domain-job.sh" + fi + echo createDomainScriptName is ${createDomainScriptName} + + # Must escape the ':' value in image for sed to properly parse and replace + image=$(echo ${image} | sed -e "s/\:/\\\:/g") + + # Generate the yaml to create the kubernetes job that will create the weblogic domain + echo Generating ${createJobOutput} + + cp ${createJobInput} ${createJobOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${createJobOutput} + sed -i -e "s:%SSL_ENABLED%:${sslEnabled}:g" ${createJobOutput} + sed -i -e "s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_SERVER_NAME%:${adminServerName}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_SERVER_NAME_SVC%:${adminServerNameSVC}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_PORT%:${adminPort}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_SERVER_SSL_PORT%:${adminServerSSLPort}:g" ${createJobOutput} + sed -i -e "s:%CONFIGURED_MANAGED_SERVER_COUNT%:${configuredManagedServerCount}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_NAME_BASE%:${managedServerNameBase}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_NAME_BASE_SVC%:${managedServerNameBaseSVC}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_SSL_PORT%:${managedServerSSLPort}:g" ${createJobOutput} + sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${createJobOutput} + sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${createJobOutput} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${createJobOutput} + sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${createJobOutput} + sed -i -e "s:%CREATE_DOMAIN_SCRIPT_DIR%:${createDomainScriptsMountPath}:g" ${createJobOutput} + sed -i -e "s:%CREATE_DOMAIN_SCRIPT%:${createDomainScriptName}:g" ${createJobOutput} + # extra entries for FMW Infra domains + sed -i -e "s:%RCU_CREDENTIALS_SECRET_NAME%:${rcuCredentialsSecret}:g" ${createJobOutput} + sed -i -e "s:%CUSTOM_RCUPREFIX%:${rcuSchemaPrefix}:g" ${createJobOutput} + sed -i -e "s|%CUSTOM_CONNECTION_STRING%|${rcuDatabaseURL}|g" ${createJobOutput} + sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3Channel}:g" ${createJobOutput} + sed -i -e "s:%FRONTEND_HOST%:${frontEndHost}:g" ${createJobOutput} + sed -i -e "s:%FRONTEND_PORT%:${frontEndPort}:g" ${createJobOutput} + # entries for Istio + sed -i -e "s:%ISTIO_PREFIX%:${istioPrefix}:g" ${createJobOutput} + sed -i -e "s:%ISTIO_ENABLED%:${istioEnabled}:g" ${createJobOutput} + sed -i -e "s:%ISTIO_READINESS_PORT%:${istioReadinessPort}:g" ${createJobOutput} + sed -i -e "s:%WDT_VERSION%:${wdtVersion}:g" ${createJobOutput} + sed -i -e "s|%DOMAIN_TYPE%|${domain_type}|g" ${createJobOutput} + sed -i -e "s|%PROXY_VAL%|${httpsProxy}|g" ${createJobOutput} + + # Generate the yaml to create the kubernetes job that will delete the weblogic domain_home folder + echo Generating ${deleteJobOutput} + + cp ${deleteJobInput} ${deleteJobOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${deleteJobOutput} + fi + + if [ "${domainHomeSourceType}" == "FromModel" ]; then + echo domainHomeSourceType is FromModel + # leave domainHomeSourceType to FromModel + if [ "${logHomeOnPV}" == "true" ]; then + logHomeOnPVPrefix="${enabledPrefix}" + else + logHomeOnPVPrefix="${disabledPrefix}" + fi + elif [ "${domainHomeInImage}" == "true" ]; then + domainHomeSourceType="Image" + if [ "${logHomeOnPV}" == "true" ]; then + logHomeOnPVPrefix="${enabledPrefix}" + else + logHomeOnPVPrefix="${disabledPrefix}" + fi + else + domainHomeSourceType="PersistentVolume" + logHomeOnPVPrefix="${enabledPrefix}" + logHomeOnPV=true + fi + + # Generate the yaml file for creating the domain resource + # We want to use wdt's extractDomainResource.sh to get the domain resource + # for domain on pv use case. For others, generate domain resource here + + if [ "${domainHomeSourceType}" != "PersistentVolume" ] || [ "${wdtDomainType}" != "WLS" ] || + [ "${useWdt}" != true ]; then + echo Generating ${dcrOutput} + + cp ${dcrInput} ${dcrOutput} + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${dcrOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${dcrOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${dcrOutput} + sed -i -e "s:%DOMAIN_HOME_SOURCE_TYPE%:${domainHomeSourceType}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${dcrOutput} + sed -i -e "s:%INCLUDE_SERVER_OUT_IN_POD_LOG%:${includeServerOutInPodLog}:g" ${dcrOutput} + sed -i -e "s:%LOG_HOME_ON_PV_PREFIX%:${logHomeOnPVPrefix}:g" ${dcrOutput} + sed -i -e "s:%LOG_HOME_ENABLED%:${logHomeOnPV}:g" ${dcrOutput} + sed -i -e "s:%LOG_HOME%:${logHome}:g" ${dcrOutput} + sed -i -e "s:%HTTP_ACCESS_LOG_IN_LOG_HOME%:${httpAccessLogInLogHome}:g" ${dcrOutput} + sed -i -e "s:%DATA_HOME%:${dataHome}:g" ${dcrOutput} + sed -i -e "s:%SERVER_START_POLICY%:${serverStartPolicy}:g" ${dcrOutput} + sed -i -e "s;%JAVA_OPTIONS%;${javaOptions};g" ${dcrOutput} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${dcrOutput} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${dcrOutput} + + if [ "${istioEnabled}" == "true" ]; then + exposeAdminNodePortPrefix="${disabledPrefix}" + fi + + sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${dcrOutput} + sed -i -e "s:%EXPOSE_ANY_CHANNEL_PREFIX%:${exposeAnyChannelPrefix}:g" ${dcrOutput} + sed -i -e "s:%EXPOSE_ADMIN_PORT_PREFIX%:${exposeAdminNodePortPrefix}:g" ${dcrOutput} + sed -i -e "s:%ADMIN_NODE_PORT%:${adminNodePort}:g" ${dcrOutput} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${dcrOutput} + sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${dcrOutput} + sed -i -e "s:%ISTIO_PREFIX%:${istioPrefix}:g" ${dcrOutput} + sed -i -e "s:%ISTIO_ENABLED%:${istioEnabled}:g" ${dcrOutput} + sed -i -e "s:%ISTIO_READINESS_PORT%:${istioReadinessPort}:g" ${dcrOutput} + # MII settings are used for model-in-image integration testing + sed -i -e "s:%MII_PREFIX%:${miiPrefix}:g" ${dcrOutput} + sed -i -e "s:%MII_CONFIG_MAP_PREFIX%:${miiConfigMapPrefix}:g" ${dcrOutput} + sed -i -e "s:%MII_CONFIG_MAP%:${miiConfigMap}:g" ${dcrOutput} + sed -i -e "s:%WDT_DOMAIN_TYPE%:${wdtDomainType}:g" ${dcrOutput} + + buildServerPodResources + if [ -z "${serverPodResources}" ]; then + sed -i -e "/%OPTIONAL_SERVERPOD_RESOURCES%/d" ${dcrOutput} + else + if [[ $(uname) -eq "Darwin" ]]; then + serverPodResources=$(echo "${serverPodResources}" | sed -e 's/\\n/%NEWLINE%/g') + sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${dcrOutput} + sed -i -e $'s|%NEWLINE%|\\\n|g' ${dcrOutput} + else + sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${dcrOutput} + fi + fi + + if [ "${domainHomeInImage}" == "true" ]; then + + # now we know which image to use, update the domain yaml file + if [ -z $image ]; then + sed -i -e "s|%WEBLOGIC_IMAGE%|${defaultImageName}|g" ${dcrOutput} + else + sed -i -e "s|%WEBLOGIC_IMAGE%|${image}|g" ${dcrOutput} + fi + else + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${dcrOutput} + fi + fi + + # Remove any "...yaml-e" and "...properties-e" files left over from running sed + rm -f ${domainOutputDir}/*.yaml-e + rm -f ${domainOutputDir}/*.properties-e + +} + + +# +# Function to markup the wdt model file +# +function updateModelFile { + # Update the wdt model file with kubernetes section + modelFile="${domainOutputDir}/tmp/wdt_model.yaml" + cat ${scriptDir}/wdt_k8s_model_template.yaml >> ${modelFile} + + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${modelFile} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${modelFile} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${modelFile} + sed -i -e "s:%DOMAIN_HOME_SOURCE_TYPE%:${domainHomeSourceType}:g" ${modelFile} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${modelFile} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${modelFile} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${modelFile} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${modelFile} + sed -i -e "s:%INCLUDE_SERVER_OUT_IN_POD_LOG%:${includeServerOutInPodLog}:g" ${modelFile} + sed -i -e "s:%LOG_HOME_ON_PV_PREFIX%:${logHomeOnPVPrefix}:g" ${modelFile} + sed -i -e "s:%LOG_HOME_ENABLED%:${logHomeOnPV}:g" ${modelFile} + sed -i -e "s:%LOG_HOME%:${logHome}:g" ${modelFile} + sed -i -e "s:%HTTP_ACCESS_LOG_IN_LOG_HOME%:${httpAccessLogInLogHome}:g" ${modelFile} + sed -i -e "s:%DATA_HOME%:${dataHome}:g" ${modelFile} + sed -i -e "s:%SERVER_START_POLICY%:${serverStartPolicy}:g" ${modelFile} + sed -i -e "s;%JAVA_OPTIONS%;${javaOptions};g" ${modelFile} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${modelFile} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${modelFile} + + if [ "${istioEnabled}" == "true" ]; then + exposeAdminNodePortPrefix="${disabledPrefix}" + fi + + sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${modelFile} + sed -i -e "s:%EXPOSE_ANY_CHANNEL_PREFIX%:${exposeAnyChannelPrefix}:g" ${modelFile} + sed -i -e "s:%EXPOSE_ADMIN_PORT_PREFIX%:${exposeAdminNodePortPrefix}:g" ${modelFile} + sed -i -e "s:%ADMIN_NODE_PORT%:${adminNodePort}:g" ${modelFile} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${modelFile} + sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${modelFile} + sed -i -e "s:%ISTIO_PREFIX%:${istioPrefix}:g" ${modelFile} + sed -i -e "s:%ISTIO_ENABLED%:${istioEnabled}:g" ${modelFile} + sed -i -e "s:%ISTIO_READINESS_PORT%:${istioReadinessPort}:g" ${modelFile} + # MII settings are used for model-in-image integration testing + sed -i -e "s:%MII_PREFIX%:${miiPrefix}:g" ${modelFile} + sed -i -e "s:%MII_CONFIG_MAP_PREFIX%:${miiConfigMapPrefix}:g" ${modelFile} + sed -i -e "s:%MII_CONFIG_MAP%:${miiConfigMap}:g" ${modelFile} + sed -i -e "s:%WDT_DOMAIN_TYPE%:${wdtDomainType}:g" ${modelFile} + + buildServerPodResources + if [ -z "${serverPodResources}" ]; then + sed -i -e "/%OPTIONAL_SERVERPOD_RESOURCES%/d" ${modelFile} + else + if [[ $(uname) -eq "Darwin" ]]; then + serverPodResources=$(echo "${serverPodResources}" | sed -e 's/\\n/%NEWLINE%/g') + sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${modelFile} + sed -i -e $'s|%NEWLINE%|\\\n|g' ${modelFile} + else + sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${modelFile} + fi + fi + + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${modelFile} +} + +# +# Function to create the domain recource +# +function createDomainResource { + kubectl apply -f ${dcrOutput} + + attempts=0 + while [ "$DCR_AVAIL" != "1" ] && [ ! $attempts -eq 10 ]; do + attempts=$((attempts + 1)) + sleep 1 + DCR_AVAIL=`kubectl get domain ${domainUID} -n ${namespace} | grep ${domainUID} | wc | awk ' { print $1; } '` + done + if [ "${DCR_AVAIL}" != "1" ]; then + fail "The domain resource ${domainUID} was not found" + fi +} + +# +# Function to create a domain +# $1 - boolean value indicating the location of the domain home +# true means domain home in image +# false means domain home on PV +# +function createDomain { + if [ "$#" != 1 ]; then + fail "The function must be called with domainHomeInImage parameter." + fi + + domainHomeInImage="${1}" + if [ "true" != "${domainHomeInImage}" ] && [ "false" != "${domainHomeInImage}" ]; then + fail "The value of domainHomeInImage must be true or false: ${domainHomeInImage}" + fi + + # Setup the environment for running this script and perform initial validation checks + initialize + + # Generate files for creating the domain + createFiles + + # Check that the domain secret exists and contains the required elements + validateDomainSecret + + # Validate the domain's persistent volume claim + if [ "${doValidation}" == true ] && [ "${domainHomeInImage}" == false -o "${logHomeOnPV}" == true ]; then + validateDomainPVC + fi + + # Create the WebLogic domain home + createDomainHome + + if [ "${executeIt}" = true ]; then + createDomainResource + fi + + # Print a summary + printSummary +} + +# +# Function to update a domain +# $1 - boolean value indicating the location of the domain home +# true means domain home in image +# false means domain home on PV +# +function updateDomain { + + domainHomeInImage="false" + + # Setup the environment for running this script and perform initial validation checks + initialize + + # Generate files for creating the domain + createFiles update + + # Check that the domain secret exists and contains the required elements + validateDomainSecret + + # Validate the domain's persistent volume claim + if [ "${doValidation}" == true ]; then + validateDomainPVC + fi + + # Create the WebLogic domain home + updateDomainHome + + if [ "${executeIt}" = true ]; then + createDomainResource + fi + + # Print a summary + printSummary +} + +# checks if a given pod in a NameSpace has been deleted +function checkPodDelete(){ + + pod=$1 + ns=$2 + status="Terminating" + + if [ -z ${1} ]; then + echo "No Pod name provided " + exit -1 + fi + + if [ -z ${2} ]; then + echo "No NameSpace provided " + exit -2 + fi + + echo "Checking Status for Pod [$pod] in namespace [${ns}]" + max=10 + count=1 + while [ $count -le $max ] ; do + sleep 5 + pod=`kubectl get po/$1 -n ${ns} | grep -v NAME | awk '{print $1}'` + if [ -z ${pod} ]; then + status="Terminated" + echo "Pod [$1] removed from nameSpace [${ns}]" + break; + fi + count=`expr $count + 1` + echo "Pod [$pod] Status [${status}]" + done + + if [ $count -gt $max ] ; then + echo "[ERROR] The Pod[$1] in NameSpace [$ns] could not be deleted in 50s"; + exit 1 + fi +} + +# Checks if all container(s) in a pod are running state based on READY column +#NAME READY STATUS RESTARTS AGE +#domain1-adminserver 1/1 Running 0 4m + +function checkPodState(){ + + status="NotReady" + max=60 + count=1 + + pod=$1 + ns=$2 + state=${3:-1/1} + + echo "Checking Pod READY column for State [$state]" + pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'` + if [ -z ${pname} ]; then + echo "No such pod [$pod] exists in NameSpace [$ns] " + exit -1 + fi + + rcode=`kubectl get po ${pname} -n ${ns} | grep -w ${pod} | awk '{print $2}'` + [[ ${rcode} -eq "${state}" ]] && status="Ready" + + while [ ${status} != "Ready" -a $count -le $max ] ; do + sleep 5 + rcode=`kubectl get po/$pod -n ${ns} | grep -v NAME | awk '{print $2}'` + [[ ${rcode} -eq "1/1" ]] && status="Ready" + echo "Pod [$1] Status is ${status} Iter [$count/$max]" + count=`expr $count + 1` + done + if [ $count -gt $max ] ; then + echo "[ERROR] Unable to start the Pod [$pod] after 300s "; + exit 1 + fi + + pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'` + kubectl -n ${ns} get po ${pname} +} + +# Checks if a pod is available in a given namespace +function checkPod(){ + + max=20 + count=1 + + pod=$1 + ns=$2 + + pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'` + if [ -z ${pname} ]; then + echo "No such pod [$pod] exists in NameSpace [$ns]" + sleep 10 + fi + + rcode=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'` + if [ ! -z ${rcode} ]; then + echo "[$pod] already initialized .. " + return 0 + fi + + echo "The POD [${pod}] has not been initialized ..." + while [ -z ${rcode} ]; do + [[ $count -gt $max ]] && break + echo "Pod[$pod] is being initialized ..." + sleep 5 + rcode=`kubectl get po -n ${ns} | grep $pod | awk '{print $1}'` + count=`expr $count + 1` + done + + if [ $count -gt $max ] ; then + echo "[ERROR] Could not find Pod [$pod] after 120s"; + exit 1 + fi +} + +# Checks if a service is available in a given namespace +function checkService(){ + svc=$1 + ns=$2 + startSecs=$SECONDS + maxWaitSecs=20 + while [ -z "`kubectl get service -n ${ns} | grep -w ${svc}`" ]; do + if [ $((SECONDS - startSecs)) -lt $maxWaitSecs ]; then + echo "Service [$svc] not found after $((SECONDS - startSecs)) seconds, retrying ..." + sleep 5 + else + echo "[Error] Could not find Service [$svc] after $((SECONDS - startSecs)) seconds" + exit 1 + fi + done + echo "Service [$svc] found" +} diff --git a/OracleWebCenterPortal/kubernetes/common/validate.sh b/OracleWebCenterPortal/kubernetes/common/validate.sh new file mode 100644 index 000000000..1a407a99a --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/validate.sh @@ -0,0 +1,481 @@ +#!/usr/bin/env bash +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description +# Common validation functions shared by all other scripts that process inputs properties. +# + +# +# Function to note that a validate error has occurred +# +function validationError { + printError $* + validateErrors=true +} + +# +# Function to cause the script to fail if there were any validation errors +# +function failIfValidationErrors { + if [ "$validateErrors" = true ]; then + fail 'The errors listed above must be resolved before the script can continue' + fi +} + +# +# Function to validate that a list of required input parameters were specified +# +function validateInputParamsSpecified { + for p in $*; do + local name=$p + local val=${!name} + if [ -z "$val" ]; then + validationError "The ${name} parameter in ${valuesInputFile} is missing, null or empty" + fi + done +} + +# +# Function to validate that a list of input parameters have boolean values. +# It assumes that validateInputParamsSpecified will also be called for these params. +# +function validateBooleanInputParamsSpecified { + validateInputParamsSpecified $* + for p in $*; do + local name=$p + local val=${!name} + if ! [ -z $val ]; then + if [ "true" != "$val" ] && [ "false" != "$val" ]; then + validationError "The value of $name must be true or false: $val" + fi + fi + done +} + +# +# Function to validate that a list of input parameters have integer values. +# +function validateIntegerInputParamsSpecified { + validateInputParamsSpecified $* + for p in $*; do + local name=$p + local val=${!name} + if ! [ -z $val ]; then + local intVal="" + printf -v intVal '%d' "$val" 2>/dev/null + if ! [ "${val}" == "${intVal}" ]; then + validationError "The value of $name must be an integer: $val" + fi + fi + done +} + +# +# Function to check if a value is lowercase +# $1 - name of object being checked +# $2 - value to check +function validateLowerCase { + local lcVal=$(toLower $2) + if [ "$lcVal" != "$2" ]; then + validationError "The value of $1 must be lowercase: $2" + fi +} + +# +# Function to check if a value is lowercase and legal DNS name +# $1 - name of object being checked +# $2 - value to check +function validateDNS1123LegalName { + local val=$(toDNS1123Legal $2) + if [ "$val" != "$2" ]; then + validationError "The value of $1 contains invalid charaters: $2" + fi +} + +# +# Function to validate the namespace +# +function validateNamespace { + validateLowerCase "namespace" ${namespace} +} + +# +# Function to validate the version of the inputs file +# +function validateVersion { + local requiredVersion=${requiredInputsVersion} + if [ "${version}" != "${requiredVersion}" ]; then + validationError "Invalid version: \"${version}\". Must be ${requiredVersion}." + fi +} + +# +# Function to ensure the domain uid is a legal DNS name +# +function validateDomainUid { + validateLowerCase "domainUID" ${domainUID} + validateDNS1123LegalName domainUID ${domainUID} +} + +# +# Function to ensure the namespace is lowercase +# +function validateNamespace { + validateLowerCase "namespace" ${namespace} +} + +# +# Create an instance of clusterName to be used in cases where a legal DNS name is required. +# +function validateClusterName { + clusterNameSVC=$(toDNS1123Legal $clusterName) +} + +# +# Create an instance of adminServerName to be used in cases where a legal DNS name is required. +# +function validateAdminServerName { + adminServerNameSVC=$(toDNS1123Legal $adminServerName) +} + +# +# Create an instance of adminServerName to be used in cases where a legal DNS name is required. +# +function validateManagedServerNameBase { + managedServerNameBaseSVC=$(toDNS1123Legal $managedServerNameBase) +} + +# +# Function to validate the secret name +# +function validateWeblogicCredentialsSecretName { + validateLowerCase "weblogicCredentialsSecretName" ${weblogicCredentialsSecretName} +} + +# +# Function to validate the weblogic image pull policy +# +function validateWeblogicImagePullPolicy { + if [ ! -z ${imagePullPolicy} ]; then + case ${imagePullPolicy} in + "IfNotPresent") + ;; + "Always") + ;; + "Never") + ;; + *) + validationError "Invalid value for imagePullPolicy: ${imagePullPolicy}. Valid values are IfNotPresent, Always, and Never." + ;; + esac + else + # Set the default + imagePullPolicy="IfNotPresent" + fi + failIfValidationErrors +} + +# +# Function to validate the fmwDomainType +# +function validateFmwDomainType { + if [ ! -z ${fmwDomainType} ]; then + case ${fmwDomainType} in + "JRF") + ;; + "RestrictedJRF") + ;; + *) + validationError "Invalid value for fmwDomainType: ${fmwDomainType}. Valid values are JRF or restrictedJRF." + ;; + esac + else + # Set the default + fmwDomainType="JRF" + fi + failIfValidationErrors +} + +# +# Function to validate the weblogic image pull secret name +# +function validateWeblogicImagePullSecretName { + if [ ! -z ${imagePullSecretName} ]; then + validateLowerCase imagePullSecretName ${imagePullSecretName} + imagePullSecretPrefix="" + if [ "${generateOnly}" = false ]; then + validateWeblogicImagePullSecret + fi + else + # Set name blank when not specified, and comment out the yaml + imagePullSecretName="" + imagePullSecretPrefix="#" + fi +} + +# +# Function to validate the weblogic image pull secret exists +# +function validateWeblogicImagePullSecret { + # The kubernetes secret for pulling images from a container registry is optional. + # If it was specified, make sure it exists. + validateSecretExists ${imagePullSecretName} ${namespace} + failIfValidationErrors +} + +# try to execute kubectl to see whether kubectl is available +function validateKubectlAvailable { + if ! [ -x "$(command -v kubectl)" ]; then + validationError "kubectl is not installed" + fi +} + +# Function to validate the server start policy value +# +function validateServerStartPolicy { + validateInputParamsSpecified serverStartPolicy + if [ ! -z "${serverStartPolicy}" ]; then + case ${serverStartPolicy} in + "NEVER") + ;; + "ALWAYS") + ;; + "IF_NEEDED") + ;; + "ADMIN_ONLY") + ;; + *) + validationError "Invalid value for serverStartPolicy: ${serverStartPolicy}. Valid values are 'NEVER', 'ALWAYS', 'IF_NEEDED', and 'ADMIN_ONLY'." + ;; + esac + fi +} + +# +# Function to validate the weblogic domain storage reclaim policy +# +function validateWeblogicDomainStorageReclaimPolicy { + validateInputParamsSpecified weblogicDomainStorageReclaimPolicy + if [ ! -z "${weblogicDomainStorageReclaimPolicy}" ]; then + case ${weblogicDomainStorageReclaimPolicy} in + "Retain") + ;; + "Delete") + if [ "${weblogicDomainStoragePath:0:5}" != "/tmp/" ]; then + validationError "ERROR - Invalid value for weblogicDomainStorageReclaimPolicy ${weblogicDomainStorageReclaimPolicy} with weblogicDomainStoragePath ${weblogicDomainStoragePath} that is not /tmp/" + fi + ;; + "Recycle") + ;; + *) + validationError "Invalid value for weblogicDomainStorageReclaimPolicy: ${weblogicDomainStorageReclaimPolicy}. Valid values are Retain, Delete and Recycle." + ;; + esac + fi +} + +# +# Function to validate the weblogic domain storage type +# +function validateWeblogicDomainStorageType { + validateInputParamsSpecified weblogicDomainStorageType + if [ ! -z "${weblogicDomainStorageType}" ]; then + case ${weblogicDomainStorageType} in + "HOST_PATH") + ;; + "NFS") + validateInputParamsSpecified weblogicDomainStorageNFSServer + ;; + *) + validationError "Invalid value for weblogicDomainStorageType: ${weblogicDomainStorageType}. Valid values are HOST_PATH and NFS." + ;; + esac + fi +} + +# +# Function to validate the load balancer value +# +function validateLoadBalancer { + validateInputParamsSpecified loadBalancer + if [ ! -z "${loadBalancer}" ]; then + case ${loadBalancer} in + "TRAEFIK") + ;; + "APACHE") + ;; + "VOYAGER") + ;; + "NONE") + ;; + *) + validationError "Invalid value for loadBalancer: ${loadBalancer}. Valid values are APACHE, TRAEFIK, VOYAGER and NONE." + ;; + esac + fi +} + +# +# Function to validate a kubernetes secret exists +# $1 - the name of the secret +# $2 - namespace +function validateSecretExists { + echo "Checking to see if the secret ${1} exists in namespace ${2}" + local SECRET=`kubectl get secret ${1} -n ${2} | grep ${1} | wc | awk ' { print $1; }'` + if [ "${SECRET}" != "1" ]; then + validationError "The secret ${1} was not found in namespace ${2}" + fi +} + +# +# Function to validate the domain secret +# +function validateDomainSecret { + # Verify the secret exists + validateSecretExists ${weblogicCredentialsSecretName} ${namespace} + failIfValidationErrors + + # Verify the secret contains a username + SECRET=`kubectl get secret ${weblogicCredentialsSecretName} -n ${namespace} -o jsonpath='{.data}' | tr -d '"' | grep username: | wc | awk ' { print $1; }'` + if [ "${SECRET}" != "1" ]; then + validationError "The domain secret ${weblogicCredentialsSecretName} in namespace ${namespace} does contain a username" + fi + + # Verify the secret contains a password + SECRET=`kubectl get secret ${weblogicCredentialsSecretName} -n ${namespace} -o jsonpath='{.data}' | tr -d '"'| grep password: | wc | awk ' { print $1; }'` + if [ "${SECRET}" != "1" ]; then + validationError "The domain secret ${weblogicCredentialsSecretName} in namespace ${namespace} does contain a password" + fi + failIfValidationErrors +} + +# +# function to validate if we will be using wdt or wlst to create the domain +# +function validateDomainFilesDir { + useWdt=true + if [ -z "${createDomainFilesDir}" ] || [ "${createDomainFilesDir}" == "wlst" ]; then + useWdt=false + fi +} + +# +# Function to validate the common input parameters +# +function validateCommonInputs { + sample_name=${1:-"other"} + + # Parse the common inputs file + parseCommonInputs + + validateInputParamsSpecified \ + adminServerName \ + domainUID \ + clusterName \ + managedServerNameBase \ + namespace \ + includeServerOutInPodLog \ + version + + validateIntegerInputParamsSpecified \ + adminPort \ + initialManagedServerReplicas \ + managedServerPort \ + t3ChannelPort \ + adminNodePort + + if [ ! "${sample_name}" == "fmw-domain-home-in-image" ]; then + validateIntegerInputParamsSpecified configuredManagedServerCount + fi + + validateBooleanInputParamsSpecified \ + productionModeEnabled \ + exposeAdminT3Channel \ + exposeAdminNodePort \ + includeServerOutInPodLog + + export requiredInputsVersion="create-weblogic-sample-domain-inputs-v1" + validateVersion + + validateDomainUid + validateNamespace + validateAdminServerName + validateManagedServerNameBase + validateClusterName + validateWeblogicCredentialsSecretName + validateServerStartPolicy + validateWeblogicImagePullPolicy + validateWeblogicImagePullSecretName + validateFmwDomainType + validateDomainFilesDir + # Below three validate methods are used for MII integration testing + validateWdtDomainType + validateWdtModelFile + validateWdtModelPropertiesFile + + failIfValidationErrors +} + +# +# Function to validate the domain's persistent volume claim has been created +# +function validateDomainPVC { + # Check if the persistent volume claim is already available + checkPvcExists ${persistentVolumeClaimName} ${namespace} + if [ "${PVC_EXISTS}" = "false" ]; then + validationError "The domain persistent volume claim ${persistentVolumeClaimName} does not exist in namespace ${namespace}" + fi + failIfValidationErrors +} + +# +# Function to validate the WDT model file exists +# used for MII integration testing +# +function validateWdtModelFile { + # Check if the model file exists + if [ ! -z $wdtModelFile ]; then + if [ ! -f $wdtModelFile ]; then + validationError "The WDT model file ${wdtModelFile} does not exist" + fi + fi + failIfValidationErrors +} + +# +# Function to validate the WDT model property file exists +# used for MII integration testing +# +function validateWdtModelPropertiesFile { + # Check if the model property file exists + if [ ! -z $wdtModelPropertiesFile ]; then + if [ ! -f $wdtModelPropertiesFile ]; then + validationError "The WDT model property file ${wdtModelPropertiesFile} does not exist" + fi + fi + failIfValidationErrors +} + +# Function to validate the wdtDomainType +# used for MII integration testing +function validateWdtDomainType { + if [ ! -z ${wdtDomainType} ]; then + case ${wdtDomainType} in + "WLS") + ;; + "JRF") + ;; + "RestrictedJRF") + ;; + *) + validationError "Invalid value for wdtDomainType: ${wdtDomainType}. Valid values are WLS or JRF or restrictedJRF." + ;; + esac + else + # Set the default + wdtDomainType="WLS" + fi + failIfValidationErrors +} + diff --git a/OracleWebCenterPortal/kubernetes/common/wdt-and-wit-utility.sh b/OracleWebCenterPortal/kubernetes/common/wdt-and-wit-utility.sh new file mode 100644 index 000000000..aa9cc691c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/common/wdt-and-wit-utility.sh @@ -0,0 +1,439 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description: +# +# This script contains functions for installing WebLogic Deploy Tool (WDT) and +# WebLogic Image Tool (WIT), and for running WDT. +# +# +# Usage: +# +# Export customized values for the input shell environment variables as needed +# before calling this script. +# +# Outputs: +# +# WDT install: WDT_DIR/weblogic-deploy/... +# +# Copy of wdt model: WDT_DIR/$(basename WDT_MODEL_FILE) +# Copy of wdt vars: WDT_DIR/$(basename WDT_VAR_FILE) +# +# WDT logs: WDT_DIR/weblogic-deploy/logs/... +# WDT stdout: WDT_DIR/createDomain.sh.out +# +# WebLogic domain home: DOMAIN_HOME_DIR +# default: /shared/domains/ +# +# Input environment variables: +# +# ORACLE_HOME Oracle home with a WebLogic install. +# default: /u01/oracle +# +# DOMAIN_HOME_DIR Target location for generated domain. +# +# WDT_MODEL_FILE Full path to WDT model file. +# default: the directory that contains this script +# plus "/wdt_model.yaml" +# +# WDT_VAR_FILE Full path to WDT variable file (java properties format). +# default: the directory that contains this script +# plus "/create-domain-inputs.yaml" +# +# WDT_DIR Target location to install and run WDT, and to keep a copy of +# $WDT_MODEL_FILE and $WDT_MODEL_VARS. Also the location +# of WDT log files. +# default: /shared/wdt +# +# WDT_VERSION WDT version to download. +# default: LATEST +# +# WDT_INSTALL_ZIP_FILE Filename of WDT install zip. +# default: weblogic-deploy.zip +# +# WDT_INSTALL_ZIP_URL URL for downloading WDT install zip +# default: https://github.com/oracle/weblogic-deploy-tooling/releases/latest/download/$WDT_INSTALL_ZIP_FILE +# +# WIT_DIR Target location to install WIT +# default: /shared/imagetool +# +# WIT_VERSION WIT version to download. +# default: LATEST +# +# WIT_INSTALL_ZIP_FILE Filename of WIT install zip. +# default: imagetool.zip +# +# WIT_INSTALL_ZIP_URL URL for downloading WIT install zip +# default: https://github.com/oracle/weblogic-image-tool/releases/latest/download/$WIT_INSTALL_ZIP_FILE +# + + +# Initialize globals + +export ORACLE_HOME=${ORACLE_HOME:-/u01/oracle} + +SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )" +WDT_MODEL_FILE=${WDT_MODEL_FILE:-"$SCRIPTPATH/wdt_model.yaml"} +WDT_VAR_FILE=${WDT_VAR_FILE:-"$SCRIPTPATH/create-domain-inputs.yaml"} + +WDT_DIR=${WDT_DIR:-/shared/wdt} +WDT_VERSION=${WDT_VERSION:-LATEST} + +WIT_DIR=${WIT_DIR:-/shared/imagetool} +WIT_VERSION=${WIT_VERSION:-LATEST} + +DOMAIN_TYPE="${DOMAIN_TYPE:-WLS}" + +function download { + local fileUrl="${1}" + + local curl_res=1 + max=20 + count=0 + while [ $curl_res -ne 0 -a $count -lt $max ] ; do + sleep 1 + count=`expr $count + 1` + for proxy in "${https_proxy}" "${https_proxy2}"; do + echo @@ "Info: Downloading $fileUrl with https_proxy=\"$proxy\"" + https_proxy="${proxy}" \ + curl --silent --show-error --connect-timeout 10 -O -L $fileUrl + curl_res=$? + [ $curl_res -eq 0 ] && break + done + done + if [ $curl_res -ne 0 ]; then + echo @@ "Error: Download failed." + return 1 + fi +} + +function run_wdt { + # + # Run WDT using WDT_VAR_FILE, WDT_MODEL_FILE, and ORACLE_HOME. + # Output: + # - result domain will be in DOMAIN_HOME_DIR + # - logging output is in $WDT_DIR/createDomain.sh.out and $WDT_DIR/weblogic-deploy/logs + # - WDT_VAR_FILE & WDT_MODEL_FILE will be copied to WDT_DIR. + # + + local action="${1}" + + # Input files and directories. + + local inputs_orig="$WDT_VAR_FILE" + local model_orig="$WDT_MODEL_FILE" + local oracle_home="$ORACLE_HOME" + local domain_type="$DOMAIN_TYPE" + local wdt_bin_dir="$WDT_DIR/weblogic-deploy/bin" + local wdt_createDomain_script="$wdt_bin_dir/createDomain.sh" + + if [ ${action} = "create" ]; then + local wdt_domain_script="$wdt_bin_dir/createDomain.sh" + else + local wdt_domain_script="$wdt_bin_dir/updateDomain.sh" + fi + + local domain_home_dir="$DOMAIN_HOME_DIR" + if [ -z "${domain_home_dir}" ]; then + local domain_dir="/shared/domains" + local domain_uid=`egrep 'domainUID' $inputs_orig | awk '{print $2}'` + local domain_home_dir=$domain_dir/$domain_uid + fi + + mkdir -p $domain_home_dir + + # Output files and directories. + + local inputs_final=$WDT_DIR/$(basename "$inputs_orig") + local model_final=$WDT_DIR/$(basename "$model_orig") + if [ ${action} = "create" ]; then + local out_file=$WDT_DIR/createDomain.sh.out + else + local out_file=$WDT_DIR/updateDomain.sh.out + fi + local wdt_log_dir="$WDT_DIR/weblogic-deploy/logs" + + echo @@ "Info: About to run WDT ${wdt_domain_script}" + + for directory in wdt_bin_dir SCRIPTPATH WDT_DIR oracle_home; do + if [ ! -d "${!directory}" ]; then + echo @@ "Error: Could not find ${directory} directory ${!directory}." + return 1 + fi + done + + for fil in inputs_orig model_orig wdt_createDomain_script; do + if [ ! -f "${!fil}" ]; then + echo @@ "Error: Could not find ${fil} file ${!fil}." + return 1 + fi + done + + cp $model_orig $model_final || return 1 + cp $inputs_orig $inputs_final || return 1 + + local save_dir=`pwd` + cd $WDT_DIR || return 1 + + cmd=" + $wdt_domain_script + -oracle_home $oracle_home + -domain_type $domain_type + -domain_home $domain_home_dir + -model_file $model_final + -variable_file $inputs_final + " + + echo @@ "Info: About to run the following WDT command:" + echo "${cmd}" + echo @@ "Info: WDT output will be in $out_file and $wdt_log_dir" + eval $cmd > $out_file 2>&1 + local wdt_res=$? + + cd $save_dir + + if [ $wdt_res -ne 0 ]; then + if [ ${action} = "create" ]; then + cat $WDT_DIR/createDomain.sh.out + echo @@ "Info: WDT createDomain.sh output is in $out_file and $wdt_log_dir" + echo @@ "Error: WDT createDomain.sh failed." + return 1 + else + cat $WDT_DIR/updateDomain.sh.out + echo @@ "Info: WDT updateDomain.sh output is in $out_file and $wdt_log_dir" + echo @@ "Error: WDT updateDomain.sh failed." + return 1 + fi + fi + + cd $WDT_DIR || return 1 + + cmd=" + $wdt_bin_dir/extractDomainResource.sh + -oracle_home $oracle_home + -domain_resource_file domain${action}.yaml + -domain_home $domain_home_dir + -model_file $model_final + -variable_file $inputs_final + " + echo @@ "Info: About to run the following WDT command:" + echo "${cmd}" + echo @@ "Info: WDT output will be in extract${action}.out and $wdt_log_dir" + eval $cmd > extract${action}.out 2>&1 + local wdt_res=$? + + cd $save_dir + + if [ $wdt_res -ne 0 ]; then + cat $WDT_DIR/extract${action}.out + echo @@ "Info: WDT extractDomainResource output is in extract${action}.out and $wdt_log_dir" + echo @@ "Error: WDT createDomain.sh failed." + return 1 + fi + + if [ ${action} = "create" ]; then + # chmod -R g+w $domain_home_dir || return 1 + echo @@ "Info: WDT createDomain.sh succeeded." + else + echo @@ "Info: WDT updateDomain.sh succeeded." + fi + + return 0 +} + +function setup_wdt_shared_dir { + mkdir -p $WDT_DIR || return 1 +} + +# +# Install Weblogic Server Deploy Tooling to ${WDT_DIR} +# +function install_wdt { + + WDT_INSTALL_ZIP_FILE="${WDT_INSTALL_ZIP_FILE:-weblogic-deploy.zip}" + + if [ "$WDT_VERSION" == "LATEST" ]; then + WDT_INSTALL_ZIP_URL=${WDT_INSTALL_ZIP_URL:-"https://github.com/oracle/weblogic-deploy-tooling/releases/latest/download/$WDT_INSTALL_ZIP_FILE"} + else + WDT_INSTALL_ZIP_URL=${WDT_INSTALL_ZIP_URL:-"https://github.com/oracle/weblogic-deploy-tooling/releases/download/release-$WDT_VERSION/$WDT_INSTALL_ZIP_FILE"} + fi + + local save_dir=`pwd` + cd $WDT_DIR || return 1 + + echo @@ "Info: Downloading $WDT_INSTALL_ZIP_URL " + download $WDT_INSTALL_ZIP_URL || return 1 + + if [ ! -f $WDT_INSTALL_ZIP_FILE ]; then + cd $save_dir + echo @@ "Error: Download failed or $WDT_INSTALL_ZIP_FILE not found." + return 1 + fi + + echo @@ "Info: Archive downloaded to $WDT_DIR/$WDT_INSTALL_ZIP_FILE, about to unzip via 'jar xf'." + + jar xf $WDT_INSTALL_ZIP_FILE + local jar_res=$? + + cd $save_dir + + if [ $jar_res -ne 0 ]; then + echo @@ "Error: Install failed while unzipping $WDT_DIR/$WDT_INSTALL_ZIP_FILE" + return $jar_res + fi + + if [ ! -d "$WDT_DIR/weblogic-deploy/bin" ]; then + echo @@ "Error: Install failed: directory '$WDT_DIR/weblogic-deploy/bin' not found." + return 1 + fi + + chmod 775 $WDT_DIR/weblogic-deploy/bin/* || return 1 + + echo @@ "Info: Install succeeded, wdt install is in the $WDT_DIR/weblogic-deploy directory." + return 0 +} + +# +# Install WebLogic Image Tool to ${WIT_DIR}. Used by install_wit_if_needed. +# Do not call this function directory. +# +function install_wit { + + WIT_INSTALL_ZIP_FILE="${WIT_INSTALL_ZIP_FILE:-imagetool.zip}" + + if [ "$WIT_VERSION" == "LATEST" ]; then + WIT_INSTALL_ZIP_URL=${WDT_INSTALL_ZIP_URL:-"https://github.com/oracle/weblogic-image-tool/releases/latest/download/$WIT_INSTALL_ZIP_FILE"} + else + WIT_INSTALL_ZIP_URL=${WIT_INSTALL_ZIP_URL:-"https://github.com/oracle/weblogic-image-tool/releases/download/release-$WIT_VERSION/$WIT_INSTALL_ZIP_FILE"} + fi + + + + local save_dir=`pwd` + + echo @@ "imagetool.sh not found in ${imagetoolBinDir}. Installing imagetool..." + + echo @@ "Info: Downloading $WIT_INSTALL_ZIP_URL " + download $WIT_INSTALL_ZIP_URL || return 1 + + if [ ! -f $WIT_INSTALL_ZIP_FILE ]; then + cd $save_dir + echo @@ "Error: Download failed or $WIT_INSTALL_ZIP_FILE not found." + return 1 + fi + echo @@ "Info: Archive downloaded to $WIT_DIR/$WIT_INSTALL_ZIP_FILE, about to unzip via 'jar xf'." + + jar xf $WIT_INSTALL_ZIP_FILE + local jar_res=$? + + cd $save_dir + + if [ $jar_res -ne 0 ]; then + echo @@ "Error: Install failed while unzipping $WIT_DIR/$WIT_INSTALL_ZIP_FILE" + return $jar_res + fi + + if [ ! -d "$WIT_DIR/imagetool/bin" ]; then + echo @@ "Error: Install failed: directory '$WIT_DIR/imagetool/bin' not found." + return 1 + fi + + chmod 775 $WIT_DIR/imagetool/bin/* || return 1 +} + +# +# Checks whether WebLogic Image Tool is already installed under ${WIT_DIR}, and install +# it if not. +# +function install_wit_if_needed { + + local save_dir=`pwd` + + mkdir -p $WIT_DIR || return 1 + cd $WIT_DIR || return 1 + + imagetoolBinDir=$WIT_DIR/imagetool/bin + if [ -f $imagetoolBinDir/imagetool.sh ]; then + echo @@ "Info: imagetool.sh already exist in ${imagetoolBinDir}. Skipping WIT installation." + else + install_wit + fi + + export WLSIMG_CACHEDIR="$WIT_DIR/imagetool-cache" + + # Check existing imageTool cache entry for WDT: + # - if there is already an entry, and the WDT installer file specified in the cache entry exists, skip WDT installation + # - if file in cache entry doesn't exist, delete cache entry, install WDT, and add WDT installer to cache + # - if entry does not exist, install WDT, and add WDT installer to cache + if [ "$WDT_VERSION" == "LATEST" ]; then + wdtCacheVersion="latest" + else + wdtCacheVersion=$WDT_VERSION + fi + + local listItems=$( ${imagetoolBinDir}/imagetool.sh cache listItems | grep "wdt_${wdtCacheVersion}" ) + + if [ ! -z "$listItems" ]; then + local wdt_file_path_in_cache=$(echo $listItems | sed 's/.*=\(.*\)/\1/') + if [ -f "$wdt_file_path_in_cache" ]; then + skip_wdt_install=true + else + echo @@ "Info: imageTool cache contains an entry for WDT zip at $wdt_file_path_in_cache which does not exist. Removing from cache entry." + ${imagetoolBinDir}/imagetool.sh cache deleteEntry \ + --key wdt_${wdtCacheVersion} + fi + fi + + if [ -z "$skip_wdt_install" ]; then + echo @@ "Info: imageTool cache does not contain a valid entry for wdt_${wdtCacheVersion}. Installing WDT" + setup_wdt_shared_dir || return 1 + install_wdt || return 1 + ${imagetoolBinDir}/imagetool.sh cache addInstaller \ + --type wdt \ + --version $WDT_VERSION \ + --path $WDT_DIR/$WDT_INSTALL_ZIP_FILE || return 1 + else + echo @@ "Info: imageTool cache already contains entry ${listItems}. Skipping WDT installation." + fi + + cd $save_dir + + echo @@ "Info: Install succeeded, imagetool install is in the $WIT_DIR/imagetool directory." + return 0 +} + +function encrypt_model { + # + # run encryptModel.sh from WDT to encrypt model and properties files + # + local domainOutputDirFullPath=${1} # full path to directory where the model, encrypt file, and domain properties files are + local model_file=${2} # path to file containing encryption key relative to ${domainOutputDirFullPath} + local encrypt_key_file=${3} # path to file containing encryption key relative to ${domainOutputDirFullPath} + local domain_properties_file=${4} # path to domain properties file relative to ${domainOutputDirFullPath} + local oracle_home="$ORACLE_HOME" + + echo @@ "Info: encrypt passwords in the variables file at ${domainOutputDirFullPath}/${domain_properties_file} using encryption key from create-domain.sh argument written to file: ${encrypt_key_file}" + + cmd=" + cat /shared/${encrypt_key_file} /shared/${encrypt_key_file} | + /wdt/bin/encryptModel.sh \ + -oracle_home ${oracle_home} \ + -model_file /shared/${model_file} \ + -variable_file /shared/${domain_properties_file} + " + echo $cmd > ${domainOutputDirFullPath}/cmd.sh + chmod 755 ${domainOutputDirFullPath}/cmd.sh + echo @@ "Info: Encrypt Model: About to run the following command in container with image ${domainHomeImageBase}:" + cat ${domainOutputDirFullPath}/cmd.sh + + chmod 766 ${domainOutputDirFullPath}/${domain_properties_file} + docker run -it --rm -v ${domainOutputDirFullPath}:/shared -v ${WDT_DIR}/weblogic-deploy:/wdt ${domainHomeImageBase} /bin/bash -c /shared/cmd.sh || return 1 + + # clean up the generated files + rm ${domainOutputDirFullPath}/cmd.sh + + echo @@ "Info: encrypt_model Completed" +} + + diff --git a/OracleWebCenterPortal/kubernetes/create-kubernetes-secrets/create-azure-storage-credentials-secret.sh b/OracleWebCenterPortal/kubernetes/create-kubernetes-secrets/create-azure-storage-credentials-secret.sh new file mode 100644 index 000000000..8e6d3d947 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-kubernetes-secrets/create-azure-storage-credentials-secret.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description +# This sample script creates a Kubernetes secret for Azure Storage to use Azure file share on AKS. +# +# The following pre-requisites must be handled prior to running this script: +# * The kubernetes namespace must already be created +# + +script="${BASH_SOURCE[0]}" + +# +# Function to exit and print an error message +# $1 - text of message +function fail { + echo [ERROR] $* + exit 1 +} + +# Try to execute kubectl to see whether kubectl is available +function validateKubectlAvailable { + if ! [ -x "$(command -v kubectl)" ]; then + fail "kubectl is not installed" + fi +} + +function usage { + echo usage: ${script} -c storageAccountName -k storageAccountKey [-s secretName] [-n namespace] [-h] + echo " -a storage account name, must be specified." + echo " -k storage account key, must be specified." + echo " -s secret name, optional. Use azure-secret if not specified." + echo " -n namespace, optional. Use the default namespace if not specified." + echo " -h Help" + exit $1 +} + +# +# Parse the command line options +# +secretName=azure-secret +namespace=default +while getopts "ha:k:s:n:" opt; do + case $opt in + a) storageAccountName="${OPTARG}" + ;; + k) storageAccountKey="${OPTARG}" + ;; + s) secretName="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${storageAccountName} ]; then + echo "${script}: -e must be specified." + missingRequiredOption="true" +fi + +if [ -z ${storageAccountKey} ]; then + echo "${script}: -p must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +# check and see if the secret already exists +result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${result:=Error}" != "0" ]; then + fail "The secret ${secretName} already exists in namespace ${namespace}." +fi + +# create the secret +kubectl -n $namespace create secret generic $secretName \ + --from-literal=azurestorageaccountname=$storageAccountName \ + --from-literal=azurestorageaccountkey=$storageAccountKey + +# Verify the secret exists +SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${SECRET}" != "1" ]; then + fail "The secret ${secretName} was not found in namespace ${namespace}" +fi + +echo "The secret ${secretName} has been successfully created in the ${namespace} namespace." diff --git a/OracleWebCenterPortal/kubernetes/create-kubernetes-secrets/create-docker-credentials-secret.sh b/OracleWebCenterPortal/kubernetes/create-kubernetes-secrets/create-docker-credentials-secret.sh new file mode 100644 index 000000000..48f113b93 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-kubernetes-secrets/create-docker-credentials-secret.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description +# This sample script creates a Kubernetes secret for container registry credentials for use with the WLS Operator on AKS. +# +# The following pre-requisites must be handled prior to running this script: +# * The kubernetes namespace must already be created +# + +script="${BASH_SOURCE[0]}" + +# +# Function to exit and print an error message +# $1 - text of message +function fail { + echo [ERROR] $* + exit 1 +} + +# Try to execute kubectl to see whether kubectl is available +function validateKubectlAvailable { + if ! [ -x "$(command -v kubectl)" ]; then + fail "kubectl is not installed" + fi +} + +function usage { + echo usage: ${script} -e email -p password -u username [-s secretName] [-d dockerServer] [-n namespace] [-h] + echo " -e email, must be specified." + echo " -p password, must be specified." + echo " -u username, must be specified." + echo " -s secret name, optional, Use regcred if not specified." + echo " -d docker server, optional, Use docker.io if not specified." + echo " -n namespace, optional. Use the default namespace if not specified" + echo " -h Help" + exit $1 +} + +# +# Parse the command line options +# +secretName=regcred +namespace=default +dockerServer=container-registry.oracle.com +while getopts "he:p:u:n:d:s:d:" opt; do + case $opt in + e) email="${OPTARG}" + ;; + p) password="${OPTARG}" + ;; + u) username="${OPTARG}" + ;; + s) secretName="${OPTARG}" + ;; + d) dockerServer="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${email} ]; then + echo "${script}: -e must be specified." + missingRequiredOption="true" +fi + +if [ -z ${password} ]; then + echo "${script}: -p must be specified." + missingRequiredOption="true" +fi + +if [ -z ${username} ]; then + echo "${script}: -u must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +# check and see if the secret already exists +result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${result:=Error}" != "0" ]; then + fail "The secret ${secretName} already exists in namespace ${namespace}." +fi + +# create the secret +kubectl -n $namespace create secret docker-registry $secretName \ + --docker-email=$email \ + --docker-password=$password \ + --docker-server=$dockerServer \ + --docker-username=$username + +# Verify the secret exists +SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${SECRET}" != "1" ]; then + fail "The secret ${secretName} was not found in namespace ${namespace}" +fi + +echo "The secret ${secretName} has been successfully created in the ${namespace} namespace." diff --git a/OracleWebCenterPortal/kubernetes/create-oracle-db-service/README.md b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/README.md new file mode 100644 index 000000000..042f8fe11 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/README.md @@ -0,0 +1,76 @@ +# Managing Oracle Database Service for OracleWebCenterPortal + +The sample scripts in this directory demonstrate how to: +* Start an Oracle Database (DB) service in a Kubernetes cluster. +* Stop an Oracle DB service in a Kubernetes cluster. + +## Start an Oracle Database service in a Kubernetes cluster + +Use this script to create an Oracle Database service in a Kubernetes Namespace with the default credentials, in the Oracle Database Slim image. + +The script assumes that either the image, `container-registry.oracle.com/database/enterprise:12.2.0.1-slim`, is available in the Docker repository, or an `ImagePullSecret` is created for `container-registry.oracle.com`. To create a secret for accessing `container-registry.oracle.com`, see the script `create-image-pull-secret.sh`. + +``` + +$ ./start-db-service.sh -h +usage: ./start-db-service.sh -p -i -s -n [-h] + -i Oracle DB Image (optional) + (default: container-registry.oracle.com/database/enterprise:12.2.0.1-slim) + -p DB Service NodePort (optional) + (default: 30011, set to 'none' to deploy service without a NodePort) + -s DB Image PullSecret (optional) + (default: docker-store) + -n Configurable Kubernetes NameSpace for Oracle DB Service (optional)" + (default: default) + -h Help + +$ ./start-db-service.sh +NodePort[30011] ImagePullSecret[docker-store] Image[container-registry.oracle.com/database/enterprise:12.2.0.1-slim] +deployment.extensions/oracle-db created +service/oracle-db created +[oracle-db-54667dfd5f-76sxf] already initialized .. +Checking Pod READY column for State [1/1] +Pod [oracle-db-54667dfd5f-76sxf] Status is Ready Iter [1/60] +NAME READY STATUS RESTARTS AGE +oracle-db-54667dfd5f-76sxf 1/1 Running 0 8s +NAME READY STATUS RESTARTS AGE +oracle-db-54667dfd5f-76sxf 1/1 Running 0 8s +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +kubernetes ClusterIP 10.96.0.1 443/TCP 27d +oracle-db NodePort 10.99.58.137 1521:30011/TCP 9s +Oracle DB service is RUNNING with NodePort [30011] + +``` + +For creating a OracleWebCenterPortal domain, you can use the database connection string, `oracle-db.default.svc.cluster.local:1521/devpdb.k8s`,as `rcuDatabaseURL` parameter in the `domain.input.yaml` file. + +Note: oracle-db.default.svc.cluster.local:1521/devpdb.k8s can be used as rcuDatabaseURL if the Oracle DB Service is started in `default` NameSpace. For custom NameSpace the URL need to be modified accrodingly e.g. oracle-db.[namespace].svc.cluster.local:1521/devpdb.k8s + +You can access the database through the NodePort outside of the Kubernetes cluster, using the URL `:30011/devpdb.k8s`. + +**Note**: To create a OracleWebCenterPortal domain image, the domain-in-image model needs a public database URL as an `rcuDatabaseURL` parameter. + +## Stop an Oracle Database service in a Kubernetes cluster + +Use this script to stop the Oracle Database service you created using the `start-db-service.sh` script. + +``` +$ ./stop-db-service.sh -h +usage: stop-db-service.sh -n namespace [-h] + -n Kubernetes NameSpace for Oracle DB Service to be Stopped (optional) + (default: default) + -h Help + +Note: Here the NameSpace refers to the NameSpace used in start-db-service.sh + +$ ./stop-db-service.sh +deployment.extensions "oracle-db" deleted +service "oracle-db" deleted +Checking Status for Pod [oracle-db-756f9b99fd-gvv46] in namesapce [default] +Pod [oracle-db-756f9b99fd-gvv46] Status [Terminating] +Pod [oracle-db-756f9b99fd-gvv46] Status [Terminating] +Pod [oracle-db-756f9b99fd-gvv46] Status [Terminating] +Error from server (NotFound): pods "oracle-db-756f9b99fd-gvv46" not found +Pod [oracle-db-756f9b99fd-gvv46] removed from nameSpace [default] +``` + diff --git a/OracleWebCenterPortal/kubernetes/create-oracle-db-service/common/checkDbState.sh b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/common/checkDbState.sh new file mode 100644 index 000000000..9ce5aa3d3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/common/checkDbState.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +logfile="/home/oracle/setup/log/setupDB.log" +max=30 +counter=0 +while [ $counter -le ${max} ] +do + grep "Done ! The database is ready for use ." $logfile + [[ $? == 0 ]] && break; + ((counter++)) + echo "[$counter/${max}] Retrying for Oracle Database Availability..." + sleep 10 +done + +if [ $counter -gt ${max} ]; then + echo "[ERRORR] Oracle DB Service is not ready after [${max}] iterations ..." + exit -1 +fi + diff --git a/OracleWebCenterPortal/kubernetes/create-oracle-db-service/common/oracle.db.yaml b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/common/oracle.db.yaml new file mode 100644 index 000000000..4185471f3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/common/oracle.db.yaml @@ -0,0 +1,78 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: v1 +kind: Service +metadata: + name: oracle-db + namespace: default +spec: + ports: + - name: tns + port: 1521 + protocol: TCP + targetPort: 1521 + nodePort: 30011 + selector: + app.kubernetes.io/instance: dev + app.kubernetes.io/name: oracle-db + sessionAffinity: None + type: NodePort +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: oracle-db + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/instance: dev + app.kubernetes.io/name: oracle-db + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app.kubernetes.io/instance: dev + app.kubernetes.io/name: oracle-db + spec: + containers: + - env: + - name: DB_SID + value: devcdb + - name: DB_PDB + value: devpdb + - name: DB_DOMAIN + value: k8s + - name: DB_BUNDLE + value: basic + image: container-registry.oracle.com/database/enterprise:12.2.0.1-slim + imagePullPolicy: IfNotPresent + name: oracle-db + ports: + - containerPort: 1521 + name: tns + protocol: TCP + resources: + limits: + cpu: "2" + memory: "6Gi" + ephemeral-storage: "8Gi" + requests: + cpu: 500m + ephemeral-storage: "6Gi" + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 30 + imagePullSecrets: + - name: docker-store + diff --git a/OracleWebCenterPortal/kubernetes/create-oracle-db-service/create-image-pull-secret.sh b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/create-image-pull-secret.sh new file mode 100644 index 000000000..3c7db8bc5 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/create-image-pull-secret.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Create ImagePullSecret to pull Oracle DB and OracleWebCenterPortal Image + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" + +function usage { + echo "usage: ${script} -u -p -e -s [-h]" + echo " -u Oracle Container Registry User Name (needed)" + echo " -p Oracle Container Registry Password (needed)" + echo " -e email (needed)" + echo " -s Generated Secret (optional) " + echo " (default: docker-store) " + echo " -h Help" + exit $1 +} + +while getopts ":u:p:s:e:" opt; do + case $opt in + u) username="${OPTARG}" + ;; + p) password="${OPTARG}" + ;; + e) email="${OPTARG}" + ;; + s) secert="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${username} ]; then + echo "${script}: -u must be specified." + usage 1 +fi + +if [ -z ${password} ]; then + echo "${script}: -p must be specified." + usage 1 +fi + +if [ -e ${email} ]; then + echo "${script}: -p must be specified." + usage 1 +fi + +if [ -z ${secret} ]; then + secret="docker-store" +fi + +kubectl delete secret/${secret} --ignore-not-found +echo "Creating ImagePullSecret on container-registry.oracle.com" +kubectl create secret docker-registry ${secret} --docker-server=container-registry.oracle.com --docker-username=${username} --docker-password=${password} --docker-email=${email} + diff --git a/OracleWebCenterPortal/kubernetes/create-oracle-db-service/start-db-service.sh b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/start-db-service.sh new file mode 100644 index 000000000..9a522d4eb --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/start-db-service.sh @@ -0,0 +1,113 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Bring up Oracle DB Instance in [default] NameSpace with a NodePort Service + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/../common/utility.sh + +function usage { + echo "usage: ${script} -p -i -s -n [-h]" + echo " -i Oracle DB Image (optional)" + echo " (default: container-registry.oracle.com/database/enterprise:12.2.0.1-slim)" + echo " -p DB Service NodePort (optional)" + echo " (default: 30011, set to 'none' to deploy service without a NodePort)" + echo " -s DB Image PullSecret (optional)" + echo " (default: docker-store) " + echo " -n Configurable Kubernetes NameSpace for Oracle DB Service (optional)" + echo " (default: default) " + echo " -h Help" + exit $1 +} + +while getopts ":h:p:s:i:n:" opt; do + case $opt in + p) nodeport="${OPTARG}" + ;; + s) pullsecret="${OPTARG}" + ;; + i) dbimage="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${nodeport} ]; then + nodeport=30011 +fi + +if [ -z ${pullsecret} ]; then + pullsecret="docker-store" +fi + +if [ -z ${namespace} ]; then + namespace="default" +fi + +echo "Checking Status for NameSpace [$namespace]" +domns=`kubectl get ns ${namespace} | grep ${namespace} | awk '{print $1}'` +if [ -z ${domns} ]; then + echo "Adding NameSpace[$namespace] to Kubernetes Cluster" + kubectl create namespace ${namespace} + sleep 5 +else + echo "Skipping the NameSpace[$namespace] Creation ..." +fi + +if [ -z ${dbimage} ]; then + dbimage="container-registry.oracle.com/database/enterprise:12.2.0.1-slim" +fi + +echo "NodePort[$nodeport] ImagePullSecret[$pullsecret] Image[${dbimage}] NameSpace[${namespace}]" + +# Modify ImagePullSecret and DatabaseImage based on input +sed -i -e '$d' ${scriptDir}/common/oracle.db.yaml +echo ' - name: docker-store' >> ${scriptDir}/common/oracle.db.yaml +sed -i -e "s?name: docker-store?name: ${pullsecret}?g" ${scriptDir}/common/oracle.db.yaml +sed -i -e "s?image:.*?image: ${dbimage}?g" ${scriptDir}/common/oracle.db.yaml +sed -i -e "s?namespace:.*?namespace: ${namespace}?g" ${scriptDir}/common/oracle.db.yaml + +# Modify the NodePort based on input +if [ "${nodeport}" = "none" ]; then + sed -i -e "s? nodePort:? #nodePort:?g" ${scriptDir}/common/oracle.db.yaml + sed -i -e "s? type:.*NodePort? #type: NodePort?g" ${scriptDir}/common/oracle.db.yaml +else + sed -i -e "s?[#]*nodePort:.*?nodePort: ${nodeport}?g" ${scriptDir}/common/oracle.db.yaml + sed -i -e "s?[#]*type:.*NodePort?type: NodePort?g" ${scriptDir}/common/oracle.db.yaml # default type is ClusterIP +fi + +kubectl delete service oracle-db -n ${namespace} --ignore-not-found +kubectl apply -f ${scriptDir}/common/oracle.db.yaml + +dbpod=`kubectl get po -n ${namespace} | grep oracle-db | cut -f1 -d " " ` + +checkPod ${dbpod} ${namespace} +checkPodState ${dbpod} ${namespace} "1/1" +checkService oracle-db ${namespace} + +kubectl get po -n ${namespace} +kubectl get service -n ${namespace} + +kubectl cp ${scriptDir}/common/checkDbState.sh -n ${namespace} ${dbpod}:/home/oracle/ +kubectl exec -it ${dbpod} -n ${namespace} /bin/bash /home/oracle/checkDbState.sh +if [ $? != 0 ]; then + echo "######################"; + echo "[ERROR] Could not create Oracle DB Service, check the pod log for pod ${dbpod} in namespace ${namespace}"; + echo "######################"; + exit -3; +fi + +if [ ! "${nodeport}" = "none" ]; then + echo "Oracle DB Service is RUNNING with NodePort [${nodeport}]" +else + echo "Oracle DB Service is RUNNING and does not specify a public NodePort" +fi +echo "Oracle DB Service URL [oracle-db.${namespace}.svc.cluster.local:1521/devpdb.k8s]" + diff --git a/OracleWebCenterPortal/kubernetes/create-oracle-db-service/stop-db-service.sh b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/stop-db-service.sh new file mode 100644 index 000000000..7ab14928c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-oracle-db-service/stop-db-service.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Drop the DB Service created by start-db-service.sh + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/../common/utility.sh + +function usage { + echo "usage: ${script} -n namespace [-h]" + echo " -n Kubernetes NameSpace for Oracle DB Service to be Stopped (optional)" + echo " (default: default) " + echo " -h Help" + exit $1 +} + +while getopts ":h:n:" opt; do + case $opt in + n) namespace="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + + +if [ -z ${namespace} ]; then + namespace=default +fi + + +dbpod=`kubectl get po -n ${namespace} | grep oracle-db | cut -f1 -d " " ` +kubectl delete -f ${scriptDir}/common/oracle.db.yaml --ignore-not-found + +if [ -z ${dbpod} ]; then + echo "Couldn't find oracle-db pod in [${namespace}] namesapce" +else + checkPodDelete ${dbpod} ${namespace} + kubectl delete svc/oracle-db -n ${namespace} --ignore-not-found +fi + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-credentials/README.md b/OracleWebCenterPortal/kubernetes/create-rcu-credentials/README.md new file mode 100644 index 000000000..962f331c3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-credentials/README.md @@ -0,0 +1,56 @@ +# Creating RCU credentials for a OracleWebCenterPortal domain + +This sample demonstrates how to create a Kubernetes secret containing the +RCU credentials for a OracleWebCenterPortal domain. The operator expects this secret to be +named following the pattern `domainUID-rcu-credentials`, where `domainUID` +is the unique identifier of the domain. It must be in the same namespace +that the domain will run in. + +To use the sample, run the command: + +``` +$ ./create-rcu-credentials.sh \ + -u username \ + -p password \ + -a sys_username \ + -q sys_password \ + -d domainUID \ + -n namespace \ + -s secretName +``` + +The parameters are as follows: + +``` + -u username for schema owner (regular user), must be specified. + -p password for schema owner (regular user), must be specified. + -a username for SYSDBA user, must be specified. + -q password for SYSDBA user, must be specified. + -d domainUID, optional. The default value is wcp-domain. If specified, the secret will be labeled with the domainUID unless the given value is an empty string. + -n namespace, optional. Use the wcpns namespace if not specified. + -s secretName, optional. If not specified, the secret name will be determined based on the domainUID value. +``` + +This creates a `generic` secret containing the user name and password as literal values. + +You can check the secret with the `kubectl describe secret` command. An example is shown below, +including the output: + +``` +$ kubectl -n wcpns describe secret wcp-domain-rcu-credentials -o yaml +Name: wcp-domain-rcu-credentials +Namespace: wcpns +Labels: weblogic.domainName=wcp-domain + weblogic.domainUID=wcp-domain +Annotations: + +Type: Opaque + +Data +==== +password: 12 bytes +sys_password: 12 bytes +sys_username: 3 bytes +username: 4 bytes +``` + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-credentials/create-rcu-credentials.sh b/OracleWebCenterPortal/kubernetes/create-rcu-credentials/create-rcu-credentials.sh new file mode 100644 index 000000000..f1b492bbd --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-credentials/create-rcu-credentials.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description +# This sample script creates a Kubernetes secret for RCU credentials. +# +# The following pre-requisites must be handled prior to running this script: +# * The kubernetes namespace must already be created +# +# Secret name determination +# 1) secretName - if specified +# 2) wcp-domain-rcu-credentials - if secretName and domainUID are both not specified. This is the default out-of-the-box. +# 3) -rcu-credentials - if secretName is not specified, and domainUID is specified. +# 4) rcu-credentials - if secretName is not specified, and domainUID is specified as "". +# +# The generated secret will be labeled with +# weblogic.domainUID=$domainUID +# and +# weblogic.domainName=$domainUID +# Where the $domainUID is the value of the -d command line option, unless the value supplied is an empty String "" +# + +script="${BASH_SOURCE[0]}" + +# +# Function to exit and print an error message +# $1 - text of message +function fail { + echo [ERROR] $* + exit 1 +} + +# Try to execute kubectl to see whether kubectl is available +function validateKubectlAvailable { + if ! [ -x "$(command -v kubectl)" ]; then + fail "kubectl is not installed" + fi +} + +function usage { + echo usage: ${script} -u username -p password -a sysuser -q syspassword [-d domainUID] [-n namespace] [-s secretName] [-h] + echo " -u username for schema owner (regular user), must be specified." + echo " -p password for schema owner (regular user), must be specified." + echo " -a username for SYSDBA user, must be specified." + echo " -q password for SYSDBA user, must be specified." + echo " -d domainUID, optional. The default value is wcp-domain. If specified, the secret will be labeled with the domainUID unless the given value is an empty string." + echo " -n namespace, optional. Use the wcpns namespace if not specified" + echo " -s secretName, optional. If not specified, the secret name will be determined based on the domainUID value" + echo " -h Help" + exit $1 +} + +# +# Parse the command line options +# +domainUID=wcp-domain +namespace=wcpns +while getopts "hu:p:n:d:s:q:a:" opt; do + case $opt in + u) username="${OPTARG}" + ;; + p) password="${OPTARG}" + ;; + a) sys_username="${OPTARG}" + ;; + q) sys_password="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + d) domainUID="${OPTARG}" + ;; + s) secretName="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z $secretName ]; then + if [ -z $domainUID ]; then + secretName=rcu-credentials + else + secretName=$domainUID-rcu-credentials + fi +fi + +if [ -z ${username} ]; then + echo "${script}: -u must be specified." + missingRequiredOption="true" +fi + +if [ -z ${password} ]; then + echo "${script}: -p must be specified." + missingRequiredOption="true" +fi + +if [ -z ${sys_username} ]; then + echo "${script}: -s must be specified." + missingRequiredOption="true" +fi + +if [ -z ${sys_password} ]; then + echo "${script}: -q must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +# check and see if the secret already exists +result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${result:=Error}" != "0" ]; then + fail "The secret ${secretName} already exists in namespace ${namespace}." +fi + +# create the secret +kubectl -n $namespace create secret generic $secretName \ + --from-literal=username=$username \ + --from-literal=password=$password \ + --from-literal=sys_username=$sys_username \ + --from-literal=sys_password=$sys_password + +# label the secret with domainUID if needed +if [ ! -z $domainUID ]; then + kubectl label secret ${secretName} -n $namespace weblogic.domainUID=$domainUID weblogic.domainName=$domainUID +fi + +# Verify the secret exists +SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${SECRET}" != "1" ]; then + fail "The secret ${secretName} was not found in namespace ${namespace}" +fi + +echo "The secret ${secretName} has been successfully created in the ${namespace} namespace." + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/README.md b/OracleWebCenterPortal/kubernetes/create-rcu-schema/README.md new file mode 100644 index 000000000..38b0068fa --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/README.md @@ -0,0 +1,219 @@ +# Managing RCU schema for a OracleWebCenterPortal domain + +The sample scripts in this directory demonstrate how to: +* Create an RCU schema in the Oracle DB that will be used by a OracleWebCenterPortal domain. +* Delete the RCU schema in the Oracle DB used by a OracleWebCenterPortal domain. + +## Start an Oracle Database service in a Kubernetes cluster + +Use the script ``samples/scripts/create-oracle-db-service/start-db-service.sh`` + +For creating a OracleWebCenterPortal domain, you can use the Database connection string, `oracle-db.default.svc.cluster.local:1521/devpdb.k8s`, as an `rcuDatabaseURL` parameter in the `domain.input.yaml` file. + +You can access the Database through the NodePort outside of the Kubernetes cluster, using the URL `:30011/devpdb.k8s`. + +**Note**: To create a OracleWebCenterPortal domain image, the domain-in-image model needs a public Database URL as an `rcuDatabaseURL` parameter. + + +## Create the RCU schema in the Oracle Database + +This script generates the RCU schema based `schemaPrefix` and `dburl`. + +The script assumes that either the image, `oracle/wcportal:12.2.1.4`, is available in the nodes or an `ImagePullSecret` is created to pull the image. To create a secret, see the script `create-image-pull-secret.sh`. + +``` +$ ./create-rcu-schema.sh -h +usage: ./create-rcu-schema.sh -s -t -d -i -u -p -n -q -r -o -c [-h] + -s RCU Schema Prefix (required) + -t RCU Schema Type (optional) + (supported values: wcp,wcpp) + -d RCU Oracle Database URL (optional) + (default: oracle-db.default.svc.cluster.local:1521/devpdb.k8s) + -p OracleWebCenterPortal ImagePullSecret (optional) + (default: none) + -i OracleWebCenterPortal Image (optional) + (default: oracle/wcportal:12.2.1.4) + -u OracleWebCenterPortal ImagePullPolicy (optional) + (default: IfNotPresent) + -n Namespace for RCU pod (optional) + (default: default) + -q password for database SYSDBA user. (optional) + (default: Oradoc_db1) + -r password for all schema owner (regular user). (optional) + (default: Oradoc_db1) + -o Output directory for the generated YAML file. (optional) + (default: rcuoutput) + -c Comma-separated variables in the format variablename=value. (optional). + (default: none) + -h Help + +$ ./create-rcu-schema.sh -s domain1 +ImagePullSecret[none] Image[oracle/wcportal:12.2.1.4] dburl[oracle-db.default.svc.cluster.local:1521/devpdb.k8s] rcuType[wcp] customVariables[none] +pod/rcu created +[rcu] already initialized .. +Checking Pod READY column for State [1/1] +Pod [rcu] Status is Ready Iter [1/60] +NAME READY STATUS RESTARTS AGE +rcu 1/1 Running 0 6s +NAME READY STATUS RESTARTS AGE +rcu 1/1 Running 0 11s +CLASSPATH=/u01/jdk/lib/tools.jar:/u01/oracle/wlserver/modules/features/wlst.wls.classpath.jar: + +PATH=/u01/oracle/wlserver/server/bin:/u01/oracle/wlserver/../oracle_common/modules/thirdparty/org.apache.ant/1.10.5.0.0/apache-ant-1.10.5/bin:/u01/jdk/jre/bin:/u01/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/u01/jdk/bin:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:/u01/oracle:/u01/oracle/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin + +Your environment has been set. +Check if the DB Service is ready to accept request +DB Connection String [oracle-db.default.svc.cluster.local:1521/devpdb.k8s], schemaPrefix [wcp-domain] rcuType [wcp] + +**** Success!!! **** + +You can connect to the database in your app using: + + java.util.Properties props = new java.util.Properties(); + props.put("user", "sys as sysdba"); + props.put("password", "Oradoc_db1"); + java.sql.Driver d = + Class.forName("oracle.jdbc.OracleDriver").newInstance(); + java.sql.Connection conn = + Driver.connect("sys as sysdba", props); +Creating RCU Schema for OracleWebCenterPortal Domain ... +Extra RCU Schema Component Choosen[] + +Processing command line .... + +Repository Creation Utility - Checking Prerequisites +Checking Component Prerequisites +Repository Creation Utility - Creating Tablespaces +Validating and Creating Tablespaces +Create tablespaces in the repository database +Repository Creation Utility - Create +Repository Create in progress. +Executing pre create operations + Percent Complete: 20 + Percent Complete: 20 + ..... + Percent Complete: 96 + Percent Complete: 100 + ..... +Executing post create operations + +Repository Creation Utility: Create - Completion Summary + +Database details: +----------------------------- +Host Name : oracle-db.default.svc.cluster.local +Port : 1521 +Service Name : DEVPDB.K8S +Connected As : sys +Prefix for (prefixable) Schema Owners : DOMAIN1 +RCU Logfile : /tmp/RCU2020-05-01_14-35_1160633335/logs/rcu.log + +Component schemas created: +----------------------------- +Component Status Logfile + +Common Infrastructure Services Success /tmp/RCU2020-05-01_14-35_1160633335/logs/stb.log +Oracle Platform Security Services Success /tmp/RCU2020-05-01_14-35_1160633335/logs/opss.log +Audit Services Success /tmp/RCU2020-05-01_14-35_1160633335/logs/iau.log +Audit Services Append Success /tmp/RCU2020-05-01_14-35_1160633335/logs/iau_append.log +Audit Services Viewer Success /tmp/RCU2020-05-01_14-35_1160633335/logs/iau_viewer.log +Metadata Services Success /tmp/RCU2020-05-01_14-35_1160633335/logs/mds.log +WebLogic Services Success /tmp/RCU2020-05-01_14-35_1160633335/logs/wls.log + +Repository Creation Utility - Create : Operation Completed +[INFO] Modify the domain.input.yaml to use [oracle-db.default.svc.cluster.local:1521/devpdb.k8s] as rcuDatabaseURL and [domain1] as rcuSchemaPrefix +``` + +## Drop the RCU schema from the Oracle Database + +Use this script to drop the RCU schema based `schemaPrefix` and `dburl`. + +``` +$ ./drop-rcu-schema.sh -h +usage: ./drop-rcu-schema.sh -s -d -n -q -r [-h] + -s RCU Schema Prefix (required) + -t RCU Schema Type (optional) + (supported values: wcp,wcpp) + -d Oracle Database URL (optional) + (default: oracle-db.default.svc.cluster.local:1521/devpdb.k8s) + -n Namespace where RCU pod is deployed (optional) + (default: default) + -q password for database SYSDBA user. (optional) + (default: Oradoc_db1) + -r password for all schema owner (regular user). (optional) + (default: Oradoc_db1) + -c Comma-separated variables in the format variablename=value. (optional). + (default: none) + -h Help + +$ ./drop-rcu-schema.sh -s domain1 +CLASSPATH=/u01/jdk/lib/tools.jar:/u01/oracle/wlserver/modules/features/wlst.wls.classpath.jar: + +PATH=/u01/oracle/wlserver/server/bin:/u01/oracle/wlserver/../oracle_common/modules/thirdparty/org.apache.ant/1.10.5.0.0/apache-ant-1.10.5/bin:/u01/jdk/jre/bin:/u01/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/u01/jdk/bin:/u01/oracle/oracle_common/common/bin:/u01/oracle/wlserver/common/bin:/u01/oracle:/u01/oracle/wlserver/../oracle_common/modules/org.apache.maven_3.2.5/bin + +Your environment has been set. +Check if the DB Service is ready to accept request +DB Connection String [oracle-db.default.svc.cluster.local:1521/devpdb.k8s] schemaPrefix [domain1] rcuType[wcp] + +**** Success!!! **** + +You can connect to the database in your app using: + + java.util.Properties props = new java.util.Properties(); + props.put("user", "sys as sysdba"); + props.put("password", "Oradoc_db1"); + java.sql.Driver d = + Class.forName("oracle.jdbc.OracleDriver").newInstance(); + java.sql.Connection conn = + Driver.connect("sys as sysdba", props); +Dropping RCU Schema for OracleWebCenterPortal Domain ... +Extra RCU Schema Component(s) Choosen[] + +Processing command line .... +Repository Creation Utility - Checking Prerequisites +Checking Global Prerequisites +Repository Creation Utility - Checking Prerequisites +Checking Component Prerequisites +Repository Creation Utility - Drop +Repository Drop in progress. + Percent Complete: 2 + Percent Complete: 14 + ..... + Percent Complete: 99 + Percent Complete: 100 + ..... + +Repository Creation Utility: Drop - Completion Summary + +Database details: +----------------------------- +Host Name : oracle-db.default.svc.cluster.local +Port : 1521 +Service Name : DEVPDB.K8S +Connected As : sys +Prefix for (prefixable) Schema Owners : DOMAIN1 +RCU Logfile : /tmp/RCU2020-05-01_14-42_651700358/logs/rcu.log + +Component schemas dropped: +----------------------------- +Component Status Logfile + +Common Infrastructure Services Success /tmp/RCU2020-05-01_14-42_651700358/logs/stb.log +Oracle Platform Security Services Success /tmp/RCU2020-05-01_14-42_651700358/logs/opss.log +Audit Services Success /tmp/RCU2020-05-01_14-42_651700358/logs/iau.log +Audit Services Append Success /tmp/RCU2020-05-01_14-42_651700358/logs/iau_append.log +Audit Services Viewer Success /tmp/RCU2020-05-01_14-42_651700358/logs/iau_viewer.log +Metadata Services Success /tmp/RCU2020-05-01_14-42_651700358/logs/mds.log +WebLogic Services Success /tmp/RCU2020-05-01_14-42_651700358/logs/wls.log + +Repository Creation Utility - Drop : Operation Completed +pod "rcu" deleted +Checking Status for Pod [rcu] in namesapce [default] +Error from server (NotFound): pods "rcu" not found +Pod [rcu] removed from nameSpace [default] +``` + +## Stop an Oracle Database service in a Kubernetes cluster + +Use the script ``samples/scripts/create-oracle-db-service/stop-db-service.sh`` + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/createRepository.sh b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/createRepository.sh new file mode 100644 index 000000000..61da67e55 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/createRepository.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +. /u01/oracle/wlserver/server/bin/setWLSEnv.sh + +echo "Check if the DB Service is ready to accept request " +connectString=${1:-oracle-db.default.svc.cluster.local:1521/devpdb.k8s} +schemaPrefix=${2:-wcp-domain} +rcuType=${3:-wcp} +sysPassword=${4:-Oradoc_db1} +customVariables=${5:-none} + +echo "DB Connection String [$connectString], schemaPrefix [${schemaPrefix}] rcuType [${rcuType}] customVariables [${customVariables}]" + +max=100 +counter=0 +while [ $counter -le ${max} ] +do + java utils.dbping ORACLE_THIN "sys as sysdba" ${sysPassword} ${connectString} > dbping.err 2>&1 + [[ $? == 0 ]] && break; + ((counter++)) + echo "[$counter/${max}] Retrying the DB Connection ..." + sleep 10 +done + +if [ $counter -gt ${max} ]; then + echo "Error output from 'java utils.dbping ORACLE_THIN \"sys as sysdba\" SYSPASSWORD ${connectString}' from '$(pwd)/dbping.err':" + cat dbping.err + echo "[ERROR] Oracle DB Service is not ready after [${max}] iterations ..." + exit -1 +else + java utils.dbping ORACLE_THIN "sys as sysdba" ${sysPassword} ${connectString} +fi + +if [ $customVariables != "none" ]; then + extVariables="-variables $customVariables" +else + extVariables="" +fi +case $rcuType in + +wcp) + extComponents="-component WEBCENTER -component ACTIVITIES" + echo "Creating RCU Schema for OracleWebCenterPortal Domain ..." + ;; +wcpp) + extComponents="-component WEBCENTER -component PORTLET -component ACTIVITIES" + echo "Creating RCU Schema for OracleWebCenterPortal Domain ..." + ;; + * ) + echo "[ERROR] Unknown RCU Schema Type [$rcuType]" + echo "Supported values: wcp,wcpp" + exit -1 + ;; +esac + +echo "Extra RCU Schema Component Choosen[${extComponents}]" +echo "Extra RCU Schema Variable Choosen[${extVariables}]" + +#Debug +#export DISPLAY=0.0 +#/u01/oracle/oracle_common/bin/rcu -listComponents + +/u01/oracle/oracle_common/bin/rcu -silent -createRepository \ + -databaseType ORACLE -connectString ${connectString} \ + -dbUser sys -dbRole sysdba -useSamePasswordForAllSchemaUsers true \ + -selectDependentsForComponents true \ + -schemaPrefix ${schemaPrefix} ${extComponents} ${extVariables} \ + -component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER \ + -component OPSS -component WLS -component STB < /u01/oracle/pwd.txt + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/dropRepository.sh b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/dropRepository.sh new file mode 100644 index 000000000..52b6b618c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/dropRepository.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +. /u01/oracle/wlserver/server/bin/setWLSEnv.sh + +echo "Check if the DB Service is ready to accept request " +connectString=${1:-oracle-db.default.svc.cluster.local:1521/devpdb.k8s} +schemaPrefix=${2:-wcp-domain} +rcuType=${3:-wcp} +sysPassword=${4:-Oradoc_db1} +customVariables=${5:-none} + +echo "DB Connection String [$connectString] schemaPrefix [${schemaPrefix}] rcuType[${rcuType}] customVariables[${customVariables}]" + +max=20 +counter=0 +while [ $counter -le ${max} ] +do + java utils.dbping ORACLE_THIN "sys as sysdba" ${sysPassword} ${connectString} > dbping.err 2>&1 + [[ $? == 0 ]] && break; + ((counter++)) + echo "[$counter/${max}] Retrying the DB Connection ..." + sleep 10 +done + +if [ $counter -gt ${max} ]; then + echo "[ERROR] Oracle DB Service is not ready after [${max}] iterations ..." + exit -1 +else + java utils.dbping ORACLE_THIN "sys as sysdba" ${sysPassword} ${connectString} +fi + +if [ $customVariables != "none" ]; then + extVariables="-variables $customVariables" +else + extVariables="" +fi + +case $rcuType in +wcp) + extComponents="-component WEBCENTER -component ACTIVITIES" + echo "Dropping RCU Schema for OracleWebCenterPortal Domain ..." + ;; +wcpp) + extComponents="-component WEBCENTER -component PORTLET -component ACTIVITIES" + echo "Dropping RCU Schema for OracleWebCenterPortal Domain ..." + ;; + * ) + echo "[ERROR] Unknown RCU Schema Type [$rcuType]" + echo "Supported values: wcp,wcpp" + exit -1 + ;; +esac + +echo "Extra RCU Schema Component(s) Choosen[${extComponents}]" +echo "Extra RCU Schema Variable(s) Choosen[${extVariables}]" + +/u01/oracle/oracle_common/bin/rcu -silent -dropRepository \ + -databaseType ORACLE -connectString ${connectString} \ + -dbUser sys -dbRole sysdba \ + -selectDependentsForComponents true \ + -schemaPrefix ${schemaPrefix} ${extComponents} ${extVariables} \ + -component MDS -component IAU -component IAU_APPEND -component IAU_VIEWER \ + -component OPSS -component WLS -component STB < /u01/oracle/pwd.txt + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/rcu.yaml b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/rcu.yaml new file mode 100644 index 000000000..e292646b9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/rcu.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: v1 +kind: Pod +metadata: + labels: + run: rcu + name: rcu + namespace: default +spec: + containers: + - args: + - sleep + - infinity + image: oracle/wcportal:12.2.1.4 + imagePullPolicy: IfNotPresent + name: rcu + imagePullSecrets: + - name: docker-store diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/template/rcu.yaml.template b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/template/rcu.yaml.template new file mode 100644 index 000000000..b4463793c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/common/template/rcu.yaml.template @@ -0,0 +1,22 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# This is a template for RCU Pod +# +apiVersion: v1 +kind: Pod +metadata: + labels: + run: rcu + name: rcu + namespace: %NAMESPACE% +spec: + containers: + - args: + - sleep + - infinity + image: oracle/wcportal:12.2.1.4 + imagePullPolicy: %WEBLOGIC_IMAGE_PULL_POLICY% + name: rcu + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%imagePullSecrets: + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%- name: %WEBLOGIC_IMAGE_PULL_SECRET_NAME% diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/create-image-pull-secret.sh b/OracleWebCenterPortal/kubernetes/create-rcu-schema/create-image-pull-secret.sh new file mode 100644 index 000000000..abf2dcbf9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/create-image-pull-secret.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Create ImagePullSecret to pull Oracle DB and OracleWebCenterPortal Image + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" + +function usage { + echo "usage: ${script} -u -p -e -s [-h]" + echo " -u Oracle Container Registry User Name (needed)" + echo " -p Oracle Container Registry Password (needed)" + echo " -e email (needed)" + echo " -s Generated Secret (optional) " + echo " (default: docker-store) " + echo " -h Help" + exit $1 +} + +while getopts ":u:p:s:e:" opt; do + case $opt in + u) username="${OPTARG}" + ;; + p) password="${OPTARG}" + ;; + e) email="${OPTARG}" + ;; + s) secert="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${username} ]; then + echo "${script}: -u must be specified." + usage 1 +fi + +if [ -z ${password} ]; then + echo "${script}: -p must be specified." + usage 1 +fi + +if [ -e ${email} ]; then + echo "${script}: -p must be specified." + usage 1 +fi + +if [ -z ${secret} ]; then + secret="docker-store" +fi + +kubectl delete secret/${secret} --ignore-not-found +echo "Creating ImagePullSecret on container-registry.oracle.com" +kubectl create secret docker-registry ${secret} --docker-server=container-registry.oracle.com --docker-username=${username} --docker-password=${password} --docker-email=${email} diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/create-rcu-schema.sh b/OracleWebCenterPortal/kubernetes/create-rcu-schema/create-rcu-schema.sh new file mode 100644 index 000000000..e7ec8023e --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/create-rcu-schema.sh @@ -0,0 +1,204 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Configure RCU schema based on schemaPreifix and rcuDatabaseURL + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/../common/utility.sh + +function usage { + echo "usage: ${script} -s -t -d -i -u -p -n -q -r -o -c [-l] [-h] " + echo " -s RCU Schema Prefix (required)" + echo " -t RCU Schema Type (optional)" + echo " (supported values: wcp,wcpp)" + echo " -d RCU Oracle Database URL (optional) " + echo " (default: oracle-db.default.svc.cluster.local:1521/devpdb.k8s) " + echo " -p OracleWebCenterPortal ImagePullSecret (optional) " + echo " (default: none) " + echo " -i OracleWebCenterPortal Image (optional) " + echo " (default: oracle/wcportal:12.2.1.4) " + echo " -u OracleWebCenterPortal ImagePullPolicy (optional) " + echo " (default: IfNotPresent) " + echo " -n Namespace for RCU pod (optional)" + echo " (default: default)" + echo " -q password for database SYSDBA user. (optional)" + echo " (default: Oradoc_db1)" + echo " -r password for all schema owner (regular user). (optional)" + echo " (default: Oradoc_db1)" + echo " -o Output directory for the generated YAML file. (optional)" + echo " (default: rcuoutput)" + echo " -c Comma-separated custom variables in the format variablename=value. (optional)." + echo " (default: none)" + echo " -l Timeout limit in seconds. (optional)." + echo " (default: 300)" + echo " -h Help" + exit $1 +} + +# Checks if all container(s) in a pod are running state based on READY column using given timeout limit +# NAME READY STATUS RESTARTS AGE +# domain1-adminserver 1/1 Running 0 4m +function checkPodStateUsingCustomTimeout(){ + + status="NotReady" + count=1 + + pod=$1 + ns=$2 + state=${3:-1/1} + timeoutLimit=${4:-300} + max=`expr ${timeoutLimit} / 5` + + echo "Checking Pod READY column for State [$state]" + pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'` + if [ -z ${pname} ]; then + echo "No such pod [$pod] exists in NameSpace [$ns] " + exit -1 + fi + + rcode=`kubectl get po ${pname} -n ${ns} | grep -w ${pod} | awk '{print $2}'` + [[ ${rcode} -eq "${state}" ]] && status="Ready" + + while [ ${status} != "Ready" -a $count -le $max ] ; do + sleep 5 + rcode=`kubectl get po/$pod -n ${ns} | grep -v NAME | awk '{print $2}'` + [[ ${rcode} -eq "1/1" ]] && status="Ready" + echo "Pod [$1] Status is ${status} Iter [$count/$max]" + count=`expr $count + 1` + done + if [ $count -gt $max ] ; then + echo "[ERROR] Unable to start the Pod [$pod] after 300s "; + exit 1 + fi + + pname=`kubectl get po -n ${ns} | grep -w ${pod} | awk '{print $1}'` + kubectl -n ${ns} get po ${pname} +} + +timeout=300 + +while getopts ":h:s:d:p:i:t:n:q:r:o:u:c:l:" opt; do + case $opt in + s) schemaPrefix="${OPTARG}" + ;; + t) rcuType="${OPTARG}" + ;; + d) dburl="${OPTARG}" + ;; + p) pullsecret="${OPTARG}" + ;; + i) fmwimage="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + q) sysPassword="${OPTARG}" + ;; + r) schemaPassword="${OPTARG}" + ;; + o) rcuOutputDir="${OPTARG}" + ;; + u) imagePullPolicy="${OPTARG}" + ;; + c) customVariables="${OPTARG}" + ;; + l) timeout="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${schemaPrefix} ]; then + echo "${script}: -s must be specified." + usage 1 +fi + +if [ -z ${dburl} ]; then + dburl="oracle-db.default.svc.cluster.local:1521/devpdb.k8s" +fi + +if [ -z ${rcuType} ]; then + rcuType="wcp" +fi + +if [ -z ${pullsecret} ]; then + pullsecret="none" + pullsecretPrefix="#" +fi + +if [ -z ${fmwimage} ]; then + fmwimage="oracle/wcportal:12.2.1.4" +fi + +if [ -z ${imagePullPolicy} ]; then + imagePullPolicy="IfNotPresent" +fi + +if [ -z ${namespace} ]; then + namespace="default" +fi + +if [ -z ${sysPassword} ]; then + sysPassword="Oradoc_db1" +fi + +if [ -z ${schemaPassword} ]; then + schemaPassword="Oradoc_db1" +fi + +if [ -z ${rcuOutputDir} ]; then + rcuOutputDir="rcuoutput" +fi + +if [ -z ${customVariables} ]; then + customVariables="none" +fi + +if [ -z ${timeout} ]; then + timeout=300 +fi + +echo "ImagePullSecret[$pullsecret] Image[${fmwimage}] dburl[${dburl}] rcuType[${rcuType}] customVariables[${customVariables}]" + +mkdir -p ${rcuOutputDir} +rcuYaml=${rcuOutputDir}/rcu.yaml +rm -f ${rcuYaml} +rcuYamlTemp=${scriptDir}/common/template/rcu.yaml.template +cp $rcuYamlTemp $rcuYaml + +# Modify the ImagePullSecret based on input +sed -i -e "s:%NAMESPACE%:${namespace}:g" $rcuYaml +sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" $rcuYaml +sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${pullsecret}:g" $rcuYaml +sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${pullsecretPrefix}:g" $rcuYaml +sed -i -e "s?image:.*?image: ${fmwimage}?g" $rcuYaml +kubectl apply -f $rcuYaml + +# Make sure the rcu deployment Pod is RUNNING +checkPod rcu $namespace +checkPodStateUsingCustomTimeout rcu $namespace "1/1" ${timeout} +sleep 5 +kubectl get po/rcu -n $namespace + +# Generate the default password files for rcu command +echo "$sysPassword" > pwd.txt +echo "$schemaPassword" >> pwd.txt + +kubectl exec -n $namespace -i rcu -- bash -c 'cat > /u01/oracle/createRepository.sh' < ${scriptDir}/common/createRepository.sh +kubectl exec -n $namespace -i rcu -- bash -c 'cat > /u01/oracle/pwd.txt' < pwd.txt +rm -rf createRepository.sh pwd.txt + +kubectl exec -n $namespace -i rcu /bin/bash /u01/oracle/createRepository.sh ${dburl} ${schemaPrefix} ${rcuType} ${sysPassword} ${customVariables} +if [ $? != 0 ]; then + echo "######################"; + echo "[ERROR] Could not create the RCU Repository"; + echo "######################"; + exit -3; +fi + +echo "[INFO] Modify the domain.input.yaml to use [$dburl] as rcuDatabaseURL and [${schemaPrefix}] as rcuSchemaPrefix " + diff --git a/OracleWebCenterPortal/kubernetes/create-rcu-schema/drop-rcu-schema.sh b/OracleWebCenterPortal/kubernetes/create-rcu-schema/drop-rcu-schema.sh new file mode 100644 index 000000000..11f8e55fb --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-rcu-schema/drop-rcu-schema.sh @@ -0,0 +1,108 @@ +#!/bin/bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Drop the RCU schema based on schemaPreifix and Database URL + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/../common/utility.sh + +function usage { + echo "usage: ${script} -s -d -n -q -r -c [-h]" + echo " -s RCU Schema Prefix (required)" + echo " -t RCU Schema Type (optional)" + echo " (supported values: wcp,wcpp) " + echo " -d Oracle Database URL (optional)" + echo " (default: oracle-db.default.svc.cluster.local:1521/devpdb.k8s) " + echo " -n Namespace where RCU pod is deployed (optional)" + echo " (default: default) " + echo " -q password for database SYSDBA user. (optional)" + echo " (default: Oradoc_db1)" + echo " -r password for all schema owner (regular user). (optional)" + echo " (default: Oradoc_db1)" + echo " -c Comma-separated custom variables in the format variablename=value. (optional)." + echo " (default: none)" + echo " -h Help" + exit $1 +} + +while getopts ":h:s:d:t:n:q:r:c:" opt; do + case $opt in + s) schemaPrefix="${OPTARG}" + ;; + t) rcuType="${OPTARG}" + ;; + d) dburl="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + q) sysPassword="${OPTARG}" + ;; + r) schemaPassword="${OPTARG}" + ;; + c) customVariables="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${schemaPrefix} ]; then + echo "${script}: -s must be specified." + usage 1 +fi + +if [ -z ${dburl} ]; then + dburl="oracle-db.default.svc.cluster.local:1521/devpdb.k8s" +fi + +if [ -z ${rcuType} ]; then + rcuType="wcp" +fi + +if [ -z ${namespace} ]; then + namespace="default" +fi + +if [ -z ${sysPassword} ]; then + sysPassword="Oradoc_db1" +fi + +if [ -z ${schemaPassword} ]; then + schemaPassword="Oradoc_db1" +fi + +if [ -z ${customVariables} ]; then + customVariables="none" +fi + +rcupod=`kubectl get po -n ${namespace} | grep rcu | cut -f1 -d " " ` +if [ -z ${rcupod} ]; then + echo "RCU deployment pod not found in [$namespace] Namespace" + exit -2 +fi + +#fmwimage=`kubectl get pod/rcu -o jsonpath="{..image}"` +echo "DB Connection String [$dbUrl], schemaPrefix [${schemaPrefix}] rcuType [${rcuType}] schemaProfileType [${customVariables}]" + +echo "${sysPassword}" > pwd.txt +echo "${schemaPassword}" >> pwd.txt + +kubectl exec -n $namespace -i rcu -- bash -c 'cat > /u01/oracle/dropRepository.sh' < ${scriptDir}/common/dropRepository.sh +kubectl exec -n $namespace -i rcu -- bash -c 'cat > /u01/oracle/pwd.txt' < pwd.txt +rm -rf dropRepository.sh pwd.txt + +kubectl exec -n $namespace -i rcu /bin/bash /u01/oracle/dropRepository.sh ${dburl} ${schemaPrefix} ${rcuType} ${sysPassword} ${customVariables} +if [ $? != 0 ]; then + echo "######################"; + echo "[ERROR] Could not drop the RCU Repository based on dburl[${dburl}] schemaPrefix[${schemaPrefix}] "; + echo "######################"; + exit -3; +fi + +kubectl delete pod rcu -n ${namespace} +checkPodDelete rcu ${namespace} + diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/common/createWebCenterPortalDomain.py b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/common/createWebCenterPortalDomain.py index 95db06a61..cdd701993 100755 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/common/createWebCenterPortalDomain.py +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/common/createWebCenterPortalDomain.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. +# Copyright (c) 2021, 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. import os @@ -17,7 +17,7 @@ class WCPortal12214Provisioner: } MANAGED_SERVERS = [] - + ADDL_MANAGED_SERVERS = [] JRF_12214_TEMPLATES = { 'baseTemplate' : '@@ORACLE_HOME@@/wlserver/common/templates/wls/wls.jar', 'extensionTemplates' : [ @@ -37,7 +37,13 @@ class WCPortal12214Provisioner: ], 'serverGroupsToTarget' : [ 'SPACES-MGD-SVRS', 'AS-MGD-SVRS' ] } - + WCPortlet_12214_TEMPLATES = { + 'extensionTemplates' : [ + '@@ORACLE_HOME@@/wcportal/common/templates/wls/oracle.portlet_producer_apps_template.jar', + '@@ORACLE_HOME@@/wcportal/common/templates/wls/oracle.ootb_producers_template.jar' + ], + 'serverGroupsToTarget' : [ 'PRODUCER_APPS-MGD-SVRS' ] + } def __init__(self, oracleHome, javaHome, domainParentDir, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName): self.oracleHome = self.validateDirectory(oracleHome) self.javaHome = self.validateDirectory(javaHome) @@ -45,7 +51,7 @@ def __init__(self, oracleHome, javaHome, domainParentDir, adminListenPort, admin return def createWCPortalDomain(self, domainName, user, password, db, dbPrefix, dbPassword, adminListenPort, adminName, - managedNameBase, managedServerPort, prodMode, managedCount, clusterName, sslEnabled, adminServerSSLPort, managedServerSSLPort, + managedNameBase, managedServerPort, prodMode, managedCount, clusterName, sslEnabled, adminServerSSLPort, managedServerSSLPort, configurePortletServer, portletClusterName, portletServerNameBase, portletServerPort, portletServerSSLPort, exposeAdminT3Channel=None, t3ChannelPublicAddress=None, t3ChannelPort=None): print '=================================================================' @@ -55,16 +61,16 @@ def createWCPortalDomain(self, domainName, user, password, db, dbPrefix, dbPassw print 'Creating Base Domain...' domainHome = self.createBaseDomain(domainName, user, password, adminListenPort, adminServerSSLPort, adminName, managedNameBase, - managedServerPort, managedServerSSLPort, prodMode, managedCount, clusterName, sslEnabled) + managedServerPort, managedServerSSLPort, configurePortletServer, portletClusterName, portletServerNameBase, portletServerPort, portletServerSSLPort, prodMode, managedCount, clusterName, sslEnabled) print 'Extending Domain...' - self.extendDomain(domainHome, db, dbPrefix, dbPassword, exposeAdminT3Channel, t3ChannelPublicAddress, + self.extendDomain(domainHome, db, dbPrefix, dbPassword, configurePortletServer, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) print 'Domain Creation is done...' def createBaseDomain(self, domainName, user, password, adminListenPort, adminServerSSLPort, adminName, - managedNameBase, managedServerPort, managedServerSSLPort, prodMode, managedCount, clusterName ,sslEnabled): + managedNameBase, managedServerPort, managedServerSSLPort, configurePortletServer, portletClusterName, portletServerNameBase, portletServerPort, portletServerSSLPort, prodMode, managedCount, clusterName ,sslEnabled): baseTemplate = self.replaceTokens(self.JRF_12214_TEMPLATES['baseTemplate']) readTemplate(baseTemplate) @@ -81,6 +87,8 @@ def createBaseDomain(self, domainName, user, password, adminListenPort, adminSer ms_count = int(managedCount) ms_sslport = int(managedServerSSLPort) admin_sslport = int(adminServerSSLPort) + portlet_port = int(portletServerPort) + portlet_ssl_port = int(portletServerSSLPort) # Create Admin Server # ======================= print 'Creating Admin Server...' @@ -110,13 +118,19 @@ def createBaseDomain(self, domainName, user, password, adminListenPort, adminSer # ====================== print 'Creating cluster...' cd('/') - cl=create(clusterName, 'Cluster') + cl = create(clusterName, 'Cluster') - # Create managed serversi + # Create managed servers self.MANAGED_SERVERS = self.createManagedServers(ms_count, managedNameBase, ms_port, ms_sslport, clusterName, self.MANAGED_SERVERS, sslEnabled) print 'Managed servers created...' - - # Create Node Manager + if (configurePortletServer == 'true'): + print 'Creating Portlet cluster...' + cd('/') + cl = create(portletClusterName, 'Cluster') + # Create portlet managed server + self.ADDL_MANAGED_SERVERS = self.createManagedServers(ms_count, portletServerNameBase, portlet_port, portlet_ssl_port, portletClusterName, self.ADDL_MANAGED_SERVERS, sslEnabled) + print 'Managed servers created...' + # Create Node Manager # ======================= print 'Creating Node Manager...' for machine in self.MACHINES: @@ -138,7 +152,7 @@ def createBaseDomain(self, domainName, user, password, adminListenPort, adminSer print 'Base domain created at ' + domainHome return domainHome - def extendDomain(self, domainHome, db, dbPrefix, dbPassword, exposeAdminT3Channel, t3ChannelPublicAddress, + def extendDomain(self, domainHome, db, dbPrefix, dbPassword, configurePortletServer, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort): print 'Extending domain at ' + domainHome print 'Database ' + db @@ -156,20 +170,14 @@ def extendDomain(self, domainHome, db, dbPrefix, dbPassword, exposeAdminT3Channe print 'Applying WCPortal templates...' for extensionTemplate in self.WCPortal_12214_TEMPLATES['extensionTemplates']: addTemplate(self.replaceTokens(extensionTemplate)) - - print 'Extension Templates added...' - cd('/') delete('WC_Portal', 'Server') print 'WC_Portal Managed server deleted...' - self.configureJDBCTemplates(db, dbPrefix, dbPassword) - print 'Targeting Server Groups...' serverGroupsToTarget = list(self.JRF_12214_TEMPLATES['serverGroupsToTarget']) serverGroupsToTarget.extend(self.WCPortal_12214_TEMPLATES['serverGroupsToTarget']) self.targetWCPServers(serverGroupsToTarget) - print 'Targeting Cluster ...' cd('/') @@ -181,6 +189,30 @@ def extendDomain(self, domainHome, db, dbPrefix, dbPassword, exposeAdminT3Channe cd('/CoherenceClusterSystemResource/defaultCoherenceCluster') set('Target', clusterName) + if (configurePortletServer == 'true'): + print 'Applying WCPortlet templates...' + + for extensionTemplate in self.WCPortlet_12214_TEMPLATES['extensionTemplates']: + addTemplate(self.replaceTokens(extensionTemplate)) + print 'WCPortlet Templates added...' + cd('/') + delete('WC_Portlet', 'Server') + print 'WC_Portlet Managed server deleted...' + print 'Targeting Server Groups...' + serverGroupsToTarget = list(self.JRF_12214_TEMPLATES['serverGroupsToTarget']) + serverGroupsToTarget.extend(self.WCPortlet_12214_TEMPLATES['serverGroupsToTarget']) + self.targetWCPortletServers(serverGroupsToTarget) + print 'Targeting Cluster ...' + cd('/') + print "Set CoherenceClusterSystemResource to defaultCoherenceCluster for cluster:" + portletClusterName + cd('/Cluster/' + portletClusterName) + set('CoherenceClusterSystemResource', 'defaultCoherenceCluster') + print "Set WLS clusters as target of defaultCoherenceCluster:" + portletClusterName + cd('/CoherenceClusterSystemResource/defaultCoherenceCluster') + set('Target', portletClusterName) + + print 'Configuring JDBC templates' + self.configureJDBCTemplates(db, dbPrefix, dbPassword) print 'Preparing to update domain...' updateDomain() print 'Domain updated successfully' @@ -225,6 +257,14 @@ def targetWCPServers(self, serverGroupsToTarget): set('CoherenceClusterSystemResource', 'defaultCoherenceCluster') return + def targetWCPortletServers(self, serverGroupsToTarget): + for managedName in self.ADDL_MANAGED_SERVERS: + setServerGroups(managedName, serverGroupsToTarget) + print "Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:" + managedName + cd('/Servers/' + managedName) + set('CoherenceClusterSystemResource', 'defaultCoherenceCluster') + return + def configureJDBCTemplates(self, db, dbPrefix, dbPassword): print 'Configuring the Service Table DataSource...' fmwDb = 'jdbc:oracle:thin:@' + db @@ -379,6 +419,12 @@ def usage(): elif sys.argv[i] == '-managedServerSSLPort': managedServerSSLPort = sys.argv[i + 1] i += 2 + elif sys.argv[i] == '-portletServerPort': + portletServerPort = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-portletServerSSLPort': + portletServerSSLPort = sys.argv[i + 1] + i += 2 elif sys.argv[i] == '-prodMode': prodMode = sys.argv[i + 1] i += 2 @@ -400,6 +446,15 @@ def usage(): elif sys.argv[i] == '-sslEnabled': sslEnabled = sys.argv[i + 1] i += 2 + elif sys.argv[i] == '-portletServerNameBase': + portletServerNameBase = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-portletClusterName': + portletClusterName = sys.argv[i + 1] + i += 2 + elif sys.argv[i] == '-configurePortletServer': + configurePortletServer = sys.argv[i + 1] + i += 2 else: print 'Unexpected argument switch at position ' + str(i) + ': ' + str(sys.argv[i]) usage() @@ -408,4 +463,4 @@ def usage(): provisioner = WCPortal12214Provisioner(oracleHome, javaHome, domainParentDir, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, clusterName) provisioner.createWCPortalDomain(domainName, domainUser, domainPassword, rcuDb, rcuSchemaPrefix, rcuSchemaPassword, adminListenPort, adminName, managedNameBase, managedServerPort, prodMode, managedCount, - clusterName, sslEnabled, adminServerSSLPort, managedServerSSLPort, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) + clusterName, sslEnabled, adminServerSSLPort, managedServerSSLPort, configurePortletServer, portletClusterName, portletServerNameBase ,portletServerPort, portletServerSSLPort, exposeAdminT3Channel, t3ChannelPublicAddress, t3ChannelPort) diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-inputs.yaml b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-inputs.yaml index ca3fbbdbb..36d5c49b8 100755 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-inputs.yaml +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-inputs.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. +# Copyright (c) 2021, 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. # The version of this inputs file. Do not modify. @@ -7,6 +7,9 @@ version: create-weblogic-sample-domain-inputs-v1 # SSL is disabled by default. Select true to enable SSL. sslEnabled: false +# Include portlet server cluster +configurePortletServer: false + # Port number for admin server adminPort: 7001 @@ -44,8 +47,19 @@ managedServerNameBase: wcpserver managedServerPort: 8888 # SSL Port number for each managed server -managedServerSSLPort: 8889 +managedServerSSLPort: 8788 + +# Portlet cluster name +portletClusterName: wcportlet-cluster + +# Base String to generate portlet server name +portletServerNameBase: wcportletserver +# Port number for each managed server +portletServerPort: 8889 + +# SSL Port number for each managed server +portletServerSSLPort: 8789 # WebCenter Portal Docker image. # To build WebCenter Portal images refer https://oracle.github.io/fmw-kubernetes/wcportal-domains/installguide/prepare-your-environment/#build-oracle-webcenter-portal-image # Update the image according to WebCenter Portal Release version @@ -68,7 +82,7 @@ productionModeEnabled: true # Name of the Kubernetes secret for the Admin Server's username and password # The name must be lowercase. # If not specified, the value is derived from the domainUID as -weblogic-credentials -weblogicCredentialsSecretName: wcpinfra-domain-credentials +weblogicCredentialsSecretName: wcp-domain-domain-credentials # Whether to include server .out to the pod's stdout. # The default is true. @@ -178,7 +192,7 @@ rcuSchemaPrefix: WCP1 rcuDatabaseURL: dbhostname:dbport/servicename # The kubernetes secret containing the database credentials -rcuCredentialsSecret: wcpinfra-rcu-credentials +rcuCredentialsSecret: wcp-domain-rcu-credentials # Provide LoadBalancer Hostname loadBalancerHostName: mycompany.mydomain.com diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-job-template.yaml b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-job-template.yaml index a7960ef08..8cfa93ea9 100755 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-job-template.yaml +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain-job-template.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. +# Copyright (c) 2021, 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. apiVersion: batch/v1 kind: Job @@ -81,6 +81,16 @@ spec: value: "%ADMIN_SERVER_SSL_PORT%" - name: MANAGED_SERVER_SSL_PORT value: "%MANAGED_SERVER_SSL_PORT%" + - name: CONFIGURE_PORTLET_SERVER + value: "%CONFIGURE_PORTLET_SERVER%" + - name: PORTLET_SERVER_PORT + value: "%PORTLET_SERVER_PORT%" + - name: PORTLET_SERVER_SSL_PORT + value: "%PORTLET_SERVER_SSL_PORT%" + - name: PORTLET_CLUSTER_NAME + value: "%PORTLET_CLUSTER_NAME%" + - name: PORTLET_SERVER_NAME_BASE + value: "%PORTLET_SERVER_NAME_BASE%" volumes: - name: create-wcp-infra-sample-domain-job-cm-volume configMap: diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain.sh b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain.sh index ebbd5cca5..ecb8eb143 100755 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain.sh +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/create-domain.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2021, Oracle and/or its affiliates. +# Copyright (c) 2021, 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. # # Description @@ -23,6 +23,8 @@ script="${BASH_SOURCE[0]}" scriptDir="$( cd "$( dirname "${script}" )" && pwd )" source ${scriptDir}/../../common/utility.sh source ${scriptDir}/../../common/validate.sh +# source WCP specific utility scripts +source ${scriptDir}/../utils/utility.sh function usage { echo usage: ${script} -o dir -i file [-e] [-v] [-t timeout] [-h] @@ -126,7 +128,7 @@ function initialize { validationError "The template file ${deleteJobInput} for deleting a WebLogic domain was not found" fi - dcrInput="${scriptDir}/../../common/jrf-domain-template.yaml" + dcrInput="${scriptDir}/../utils/wcp-domain-template.yaml" if [ ! -f ${dcrInput} ]; then validationError "The template file ${dcrInput} for creating the domain resource was not found" fi @@ -196,7 +198,13 @@ function createDomainHome { CONTAINER_NAME="create-wcp-infra-sample-domain-job" JOB_NAME="${domainUID}-${CONTAINER_NAME}" deleteK8sObj job $JOB_NAME ${createJobOutput} - #Traefik Session Setting + # Traefik Session Setting + + if ( $configurePortletServer == "true" ) ; then + sed -n '/- clusterName:/,/# replicas: /{p}' ${dcrOutput} >> ${dcrOutput} + sed -i "0,/- clusterName: ${clusterName}/s//- clusterName: ${portletClusterName}/" ${dcrOutput} + fi + if [ -z "$loadBalancerType" ] then echo "\$loadBalancerType is empty" @@ -289,4 +297,4 @@ function printSummary { } # Perform the sequence of steps to create a domain -createDomain false +createDomain_WCP false diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/wlst/create-domain-script.sh b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/wlst/create-domain-script.sh index ce12c4e0d..1a7222605 100755 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/wlst/create-domain-script.sh +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/domain-home-on-pv/wlst/create-domain-script.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2021 Oracle and/or its affiliates. +# Copyright (c) 2021, 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. export DOMAIN_HOME=${DOMAIN_HOME_DIR} @@ -32,4 +32,9 @@ wlst.sh -skipWLSModuleScanning \ -sslEnabled ${SSL_ENABLED} \ -adminServerSSLPort ${ADMIN_SERVER_SSL_PORT} \ -managedServerSSLPort ${MANAGED_SERVER_SSL_PORT} \ + -configurePortletServer ${CONFIGURE_PORTLET_SERVER}\ + -portletServerPort ${PORTLET_SERVER_PORT}\ + -portletServerSSLPort ${PORTLET_SERVER_SSL_PORT}\ + -portletServerNameBase ${PORTLET_SERVER_NAME_BASE}\ + -portletClusterName ${PORTLET_CLUSTER_NAME}\ -t3ChannelPort ${T3_CHANNEL_PORT} diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/utility.sh b/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/utility.sh new file mode 100644 index 000000000..61fa27436 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/utility.sh @@ -0,0 +1,390 @@ +#!/usr/bin/env bash +# Copyright (c) 2022, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# Function to generate the properties and yaml files for creating a domain +# +function createFiles_WCP { + + update=false + if [ "$#" == 1 ]; then + echo Trying to update the domain + update=true + fi + + # Make sure the output directory has a copy of the inputs file. + # The user can either pre-create the output directory, put the inputs + # file there, and create the domain from it, or the user can put the + # inputs file some place else and let this script create the output directory + # (if needed) and copy the inputs file there. + echo createFiles - valuesInputFile is ${valuesInputFile} + copyInputsFileToOutputDirectory ${valuesInputFile} "${domainOutputDir}/create-domain-inputs.yaml" + + if [ "${domainHomeInImage}" == "true" ]; then + if [ -z "${domainHomeImageBase}" ]; then + fail "Please specify domainHomeImageBase in your input YAML" + fi + else + if [ -z "${image}" ]; then + fail "Please specify image in your input YAML" + fi + fi + + dcrOutput="${domainOutputDir}/domain.yaml" + + domainName=${domainUID} + + enabledPrefix="" # uncomment the feature + disabledPrefix="# " # comment out the feature + + exposeAnyChannelPrefix="${disabledPrefix}" + if [ "${exposeAdminT3Channel}" = true ]; then + exposeAdminT3ChannelPrefix="${enabledPrefix}" + exposeAnyChannelPrefix="${enabledPrefix}" + # set t3PublicAddress if not set + if [ -z "${t3PublicAddress}" ]; then + getKubernetesClusterIP + t3PublicAddress="${K8S_IP}" + fi + else + exposeAdminT3ChannelPrefix="${disabledPrefix}" + fi + + if [ "${exposeAdminNodePort}" = true ]; then + exposeAdminNodePortPrefix="${enabledPrefix}" + exposeAnyChannelPrefix="${enabledPrefix}" + else + exposeAdminNodePortPrefix="${disabledPrefix}" + fi + + if [ "${istioEnabled}" == "true" ]; then + istioPrefix="${enabledPrefix}" + else + istioPrefix="${disabledPrefix}" + fi + + # The FromModel, MII (model-in-image), and WDT_DOMAIN_TYPE updates in this script + # must remain even though they are not referenced by a sample. They're used by the + # Operator integration test code. If you're interested in MII, + # see './kubernetes/samples/scripts/create-weblogic-domain/model-in-image'. + + # MII settings are used for model-in-image integration testing + if [ "${domainHomeSourceType}" == "FromModel" ]; then + miiPrefix="${enabledPrefix}" + else + miiPrefix="${disabledPrefix}" + fi + + # MII settings are used for model-in-image integration testing + if [ -z "${miiConfigMap}" ]; then + miiConfigMapPrefix="${disabledPrefix}" + else + miiConfigMapPrefix="${enabledPrefix}" + fi + + # For some parameters, use the default value if not defined. + if [ -z "${domainPVMountPath}" ]; then + domainPVMountPath="/shared" + fi + + if [ -z "${logHome}" ]; then + logHome="${domainPVMountPath}/logs/${domainUID}" + fi + + if [ -z "${httpAccessLogInLogHome}" ]; then + httpAccessLogInLogHome="true" + fi + + if [ -z "${dataHome}" ]; then + dataHome="" + fi + + if [ -z "${persistentVolumeClaimName}" ]; then + persistentVolumeClaimName="${domainUID}-weblogic-sample-pvc" + fi + + if [ -z "${weblogicCredentialsSecretName}" ]; then + weblogicCredentialsSecretName="${domainUID}-weblogic-credentials" + fi + + if [ "${domainHomeInImage}" == "true" ]; then + domainPropertiesOutput="${domainOutputDir}/domain.properties" + domainHome="${domainHome:-/u01/oracle/user_projects/domains/${domainName}}" + + # Generate the properties file that will be used when creating the weblogic domain + echo Generating ${domainPropertiesOutput} from ${domainPropertiesInput} + + cp ${domainPropertiesInput} ${domainPropertiesOutput} + sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${domainPropertiesOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_PORT%:${adminPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_SERVER_SSL_PORT%:${adminServerSSLPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_SERVER_NAME%:${adminServerName}:g" ${domainPropertiesOutput} + sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%MANAGED_SERVER_SSL_PORT%:${managedServerSSLPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%MANAGED_SERVER_NAME_BASE%:${managedServerNameBase}:g" ${domainPropertiesOutput} + sed -i -e "s:%CONFIGURED_MANAGED_SERVER_COUNT%:${configuredManagedServerCount}:g" ${domainPropertiesOutput} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${domainPropertiesOutput} + sed -i -e "s:%SSL_ENABLED%:${sslEnabled}:g" ${domainPropertiesOutput} + sed -i -e "s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled}:g" ${domainPropertiesOutput} + sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${domainPropertiesOutput} + sed -i -e "s;%JAVA_OPTIONS%;${javaOptions};g" ${domainPropertiesOutput} + sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${domainPropertiesOutput} + sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${domainPropertiesOutput} + sed -i -e "s:%EXPOSE_T3_CHANNEL%:${exposeAdminT3Channel}:g" ${domainPropertiesOutput} + sed -i -e "s:%FMW_DOMAIN_TYPE%:${fmwDomainType}:g" ${domainPropertiesOutput} + sed -i -e "s:%WDT_DOMAIN_TYPE%:${wdtDomainType}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_USER_NAME%:${username}:g" ${domainPropertiesOutput} + sed -i -e "s:%ADMIN_USER_PASS%:${password}:g" ${domainPropertiesOutput} + sed -i -e "s:%RCU_SCHEMA_PREFIX%:${rcuSchemaPrefix}:g" ${domainPropertiesOutput} + sed -i -e "s:%RCU_SCHEMA_PASSWORD%:${rcuSchemaPassword}:g" ${domainPropertiesOutput} + sed -i -e "s|%RCU_DB_CONN_STRING%|${rcuDatabaseURL}|g" ${domainPropertiesOutput} + + if [ -z "${image}" ]; then + # calculate the internal name to tag the generated image + defaultImageName="domain-home-in-image" + baseTag=${domainHomeImageBase#*:} + defaultImageName=${defaultImageName}:${baseTag:-"latest"} + sed -i -e "s|%IMAGE_NAME%|${defaultImageName}|g" ${domainPropertiesOutput} + export BUILD_IMAGE_TAG=${defaultImageName} + else + sed -i -e "s|%IMAGE_NAME%|${image}|g" ${domainPropertiesOutput} + export BUILD_IMAGE_TAG=${image} + fi + else + # we're in the domain in PV case + + wdtVersion="${WDT_VERSION:-${wdtVersion}}" + httpsProxy="${https_proxy}" + + createJobOutput="${domainOutputDir}/create-domain-job.yaml" + deleteJobOutput="${domainOutputDir}/delete-domain-job.yaml" + + if [ -z "${domainHome}" ]; then + domainHome="${domainPVMountPath}/domains/${domainUID}" + fi + + # Use the default value if not defined. + if [ -z "${createDomainScriptsMountPath}" ]; then + createDomainScriptsMountPath="/u01/weblogic" + fi + + if [ "${update}" == "true" ]; then + createDomainScriptName="update-domain-job.sh" + elif [ -z "${createDomainScriptName}" ]; then + createDomainScriptName="create-domain-job.sh" + fi + echo createDomainScriptName is ${createDomainScriptName} + + # Must escape the ':' value in image for sed to properly parse and replace + image=$(echo ${image} | sed -e "s/\:/\\\:/g") + + # Generate the yaml to create the kubernetes job that will create the weblogic domain + echo Generating ${createJobOutput} + + cp ${createJobInput} ${createJobOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${createJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${createJobOutput} + sed -i -e "s:%SSL_ENABLED%:${sslEnabled}:g" ${createJobOutput} + sed -i -e "s:%PRODUCTION_MODE_ENABLED%:${productionModeEnabled}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_SERVER_NAME%:${adminServerName}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_SERVER_NAME_SVC%:${adminServerNameSVC}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_PORT%:${adminPort}:g" ${createJobOutput} + sed -i -e "s:%ADMIN_SERVER_SSL_PORT%:${adminServerSSLPort}:g" ${createJobOutput} + sed -i -e "s:%CONFIGURED_MANAGED_SERVER_COUNT%:${configuredManagedServerCount}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_NAME_BASE%:${managedServerNameBase}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_NAME_BASE_SVC%:${managedServerNameBaseSVC}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_PORT%:${managedServerPort}:g" ${createJobOutput} + sed -i -e "s:%MANAGED_SERVER_SSL_PORT%:${managedServerSSLPort}:g" ${createJobOutput} + sed -i -e "s:%T3_CHANNEL_PORT%:${t3ChannelPort}:g" ${createJobOutput} + sed -i -e "s:%T3_PUBLIC_ADDRESS%:${t3PublicAddress}:g" ${createJobOutput} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${createJobOutput} + sed -i -e "s:%CLUSTER_TYPE%:${clusterType}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${createJobOutput} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${createJobOutput} + sed -i -e "s:%CREATE_DOMAIN_SCRIPT_DIR%:${createDomainScriptsMountPath}:g" ${createJobOutput} + sed -i -e "s:%CREATE_DOMAIN_SCRIPT%:${createDomainScriptName}:g" ${createJobOutput} + # extra entries for FMW Infra domains + sed -i -e "s:%RCU_CREDENTIALS_SECRET_NAME%:${rcuCredentialsSecret}:g" ${createJobOutput} + sed -i -e "s:%CUSTOM_RCUPREFIX%:${rcuSchemaPrefix}:g" ${createJobOutput} + sed -i -e "s|%CUSTOM_CONNECTION_STRING%|${rcuDatabaseURL}|g" ${createJobOutput} + sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3Channel}:g" ${createJobOutput} + sed -i -e "s:%FRONTEND_HOST%:${frontEndHost}:g" ${createJobOutput} + sed -i -e "s:%FRONTEND_PORT%:${frontEndPort}:g" ${createJobOutput} + # entries for Istio + sed -i -e "s:%ISTIO_PREFIX%:${istioPrefix}:g" ${createJobOutput} + sed -i -e "s:%ISTIO_ENABLED%:${istioEnabled}:g" ${createJobOutput} + sed -i -e "s:%ISTIO_READINESS_PORT%:${istioReadinessPort}:g" ${createJobOutput} + sed -i -e "s:%WDT_VERSION%:${wdtVersion}:g" ${createJobOutput} + sed -i -e "s|%DOMAIN_TYPE%|${domain_type}|g" ${createJobOutput} + sed -i -e "s|%PROXY_VAL%|${httpsProxy}|g" ${createJobOutput} + sed -i -e "s:%CONFIGURE_PORTLET_SERVER%:${configurePortletServer}:g" ${createJobOutput} + sed -i -e "s:%PORTLET_SERVER_PORT%:${portletServerPort}:g" ${createJobOutput} + sed -i -e "s:%PORTLET_SERVER_SSL_PORT%:${portletServerSSLPort}:g" ${createJobOutput} + sed -i -e "s:%PORTLET_CLUSTER_NAME%:${portletClusterName}:g" ${createJobOutput} + sed -i -e "s:%PORTLET_SERVER_NAME_BASE%:${portletServerNameBase}:g" ${createJobOutput} + + # Generate the yaml to create the kubernetes job that will delete the weblogic domain_home folder + echo Generating ${deleteJobOutput} + + cp ${deleteJobInput} ${deleteJobOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${deleteJobOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_NAME%:${domainName}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${deleteJobOutput} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${deleteJobOutput} + fi + + if [ "${domainHomeSourceType}" == "FromModel" ]; then + echo domainHomeSourceType is FromModel + # leave domainHomeSourceType to FromModel + if [ "${logHomeOnPV}" == "true" ]; then + logHomeOnPVPrefix="${enabledPrefix}" + else + logHomeOnPVPrefix="${disabledPrefix}" + fi + elif [ "${domainHomeInImage}" == "true" ]; then + domainHomeSourceType="Image" + if [ "${logHomeOnPV}" == "true" ]; then + logHomeOnPVPrefix="${enabledPrefix}" + else + logHomeOnPVPrefix="${disabledPrefix}" + fi + else + domainHomeSourceType="PersistentVolume" + logHomeOnPVPrefix="${enabledPrefix}" + logHomeOnPV=true + fi + + # Generate the yaml file for creating the domain resource + # We want to use wdt's extractDomainResource.sh to get the domain resource + # for domain on pv use case. For others, generate domain resource here + + if [ "${domainHomeSourceType}" != "PersistentVolume" ] || [ "${wdtDomainType}" != "WLS" ] || + [ "${useWdt}" != true ]; then + echo Generating ${dcrOutput} + + cp ${dcrInput} ${dcrOutput} + sed -i -e "s:%DOMAIN_UID%:${domainUID}:g" ${dcrOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${dcrOutput} + sed -i -e "s:%DOMAIN_HOME%:${domainHome}:g" ${dcrOutput} + sed -i -e "s:%DOMAIN_HOME_SOURCE_TYPE%:${domainHomeSourceType}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_POLICY%:${imagePullPolicy}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%:${imagePullSecretPrefix}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_IMAGE_PULL_SECRET_NAME%:${imagePullSecretName}:g" ${dcrOutput} + sed -i -e "s:%WEBLOGIC_CREDENTIALS_SECRET_NAME%:${weblogicCredentialsSecretName}:g" ${dcrOutput} + sed -i -e "s:%INCLUDE_SERVER_OUT_IN_POD_LOG%:${includeServerOutInPodLog}:g" ${dcrOutput} + sed -i -e "s:%LOG_HOME_ON_PV_PREFIX%:${logHomeOnPVPrefix}:g" ${dcrOutput} + sed -i -e "s:%LOG_HOME_ENABLED%:${logHomeOnPV}:g" ${dcrOutput} + sed -i -e "s:%LOG_HOME%:${logHome}:g" ${dcrOutput} + sed -i -e "s:%HTTP_ACCESS_LOG_IN_LOG_HOME%:${httpAccessLogInLogHome}:g" ${dcrOutput} + sed -i -e "s:%DATA_HOME%:${dataHome}:g" ${dcrOutput} + sed -i -e "s:%SERVER_START_POLICY%:${serverStartPolicy}:g" ${dcrOutput} + sed -i -e "s;%JAVA_OPTIONS%;${javaOptions};g" ${dcrOutput} + sed -i -e "s:%DOMAIN_PVC_NAME%:${persistentVolumeClaimName}:g" ${dcrOutput} + sed -i -e "s:%DOMAIN_ROOT_DIR%:${domainPVMountPath}:g" ${dcrOutput} + + if [ "${istioEnabled}" == "true" ]; then + exposeAdminNodePortPrefix="${disabledPrefix}" + fi + + sed -i -e "s:%EXPOSE_T3_CHANNEL_PREFIX%:${exposeAdminT3ChannelPrefix}:g" ${dcrOutput} + sed -i -e "s:%EXPOSE_ANY_CHANNEL_PREFIX%:${exposeAnyChannelPrefix}:g" ${dcrOutput} + sed -i -e "s:%EXPOSE_ADMIN_PORT_PREFIX%:${exposeAdminNodePortPrefix}:g" ${dcrOutput} + sed -i -e "s:%ADMIN_NODE_PORT%:${adminNodePort}:g" ${dcrOutput} + sed -i -e "s:%CLUSTER_NAME%:${clusterName}:g" ${dcrOutput} + sed -i -e "s:%INITIAL_MANAGED_SERVER_REPLICAS%:${initialManagedServerReplicas}:g" ${dcrOutput} + sed -i -e "s:%ISTIO_PREFIX%:${istioPrefix}:g" ${dcrOutput} + sed -i -e "s:%ISTIO_ENABLED%:${istioEnabled}:g" ${dcrOutput} + sed -i -e "s:%ISTIO_READINESS_PORT%:${istioReadinessPort}:g" ${dcrOutput} + # MII settings are used for model-in-image integration testing + sed -i -e "s:%MII_PREFIX%:${miiPrefix}:g" ${dcrOutput} + sed -i -e "s:%MII_CONFIG_MAP_PREFIX%:${miiConfigMapPrefix}:g" ${dcrOutput} + sed -i -e "s:%MII_CONFIG_MAP%:${miiConfigMap}:g" ${dcrOutput} + sed -i -e "s:%WDT_DOMAIN_TYPE%:${wdtDomainType}:g" ${dcrOutput} + + buildServerPodResources + if [ -z "${serverPodResources}" ]; then + sed -i -e "/%OPTIONAL_SERVERPOD_RESOURCES%/d" ${dcrOutput} + else + if [[ $(uname) -eq "Darwin" ]]; then + serverPodResources=$(echo "${serverPodResources}" | sed -e 's/\\n/%NEWLINE%/g') + sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${dcrOutput} + sed -i -e $'s|%NEWLINE%|\\\n|g' ${dcrOutput} + else + sed -i -e "s:%OPTIONAL_SERVERPOD_RESOURCES%:${serverPodResources}:g" ${dcrOutput} + fi + fi + + if [ "${domainHomeInImage}" == "true" ]; then + + # now we know which image to use, update the domain yaml file + if [ -z $image ]; then + sed -i -e "s|%WEBLOGIC_IMAGE%|${defaultImageName}|g" ${dcrOutput} + else + sed -i -e "s|%WEBLOGIC_IMAGE%|${image}|g" ${dcrOutput} + fi + else + sed -i -e "s:%WEBLOGIC_IMAGE%:${image}:g" ${dcrOutput} + fi + fi + + # Remove any "...yaml-e" and "...properties-e" files left over from running sed + rm -f ${domainOutputDir}/*.yaml-e + rm -f ${domainOutputDir}/*.properties-e + +} + +# +# Function to create a domain +# $1 - boolean value indicating the location of the domain home +# true means domain home in image +# false means domain home on PV +# +function createDomain_WCP { + if [ "$#" != 1 ]; then + fail "The function must be called with domainHomeInImage parameter." + fi + + domainHomeInImage="${1}" + if [ "true" != "${domainHomeInImage}" ] && [ "false" != "${domainHomeInImage}" ]; then + fail "The value of domainHomeInImage must be true or false: ${domainHomeInImage}" + fi + + # Setup the environment for running this script and perform initial validation checks + initialize + + # Generate files for creating the domain + createFiles_WCP + + # Check that the domain secret exists and contains the required elements + validateDomainSecret + + # Validate the domain's persistent volume claim + if [ "${doValidation}" == true ] && [ "${domainHomeInImage}" == false -o "${logHomeOnPV}" == true ]; then + validateDomainPVC + fi + + # Create the WebLogic domain home + createDomainHome + + if [ "${executeIt}" = true ]; then + createDomainResource + fi + + # Print a summary + printSummary +} diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/wcp-domain-template.yaml b/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/wcp-domain-template.yaml new file mode 100644 index 000000000..7988e8f53 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/wcp-domain-template.yaml @@ -0,0 +1,123 @@ +# Copyright (c) 2022, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# This is an example of how to define a Domain resource. +# +apiVersion: "weblogic.oracle/v8" +kind: Domain +metadata: + name: %DOMAIN_UID% + namespace: %NAMESPACE% + labels: + weblogic.domainUID: %DOMAIN_UID% +spec: + # The WebLogic Domain Home + domainHome: %DOMAIN_HOME% + + # The domain home source type + # Set to PersistentVolume for domain-in-pv, Image for domain-in-image, or FromModel for model-in-image + domainHomeSourceType: %DOMAIN_HOME_SOURCE_TYPE% + + # The WebLogic Server image that the Operator uses to start the domain + image: "%WEBLOGIC_IMAGE%" + + # imagePullPolicy defaults to "Always" if image version is :latest + imagePullPolicy: "%WEBLOGIC_IMAGE_PULL_POLICY%" + + # Identify which Secret contains the credentials for pulling an image + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%imagePullSecrets: + %WEBLOGIC_IMAGE_PULL_SECRET_PREFIX%- name: %WEBLOGIC_IMAGE_PULL_SECRET_NAME% + + # Identify which Secret contains the WebLogic Admin credentials (note that there is an example of + # how to create that Secret at the end of this file) + webLogicCredentialsSecret: + name: %WEBLOGIC_CREDENTIALS_SECRET_NAME% + + # Whether to include the server out file into the pod's stdout, default is true + includeServerOutInPodLog: %INCLUDE_SERVER_OUT_IN_POD_LOG% + + # Whether to enable log home + %LOG_HOME_ON_PV_PREFIX%logHomeEnabled: %LOG_HOME_ENABLED% + + # Whether to write HTTP access log file to log home + %LOG_HOME_ON_PV_PREFIX%httpAccessLogInLogHome: %HTTP_ACCESS_LOG_IN_LOG_HOME% + + # The in-pod location for domain log, server logs, server out, introspector out, and Node Manager log files + %LOG_HOME_ON_PV_PREFIX%logHome: %LOG_HOME% + # An (optional) in-pod location for data storage of default and custom file stores. + # If not specified or the value is either not set or empty (e.g. dataHome: "") then the + # data storage directories are determined from the WebLogic domain home configuration. + dataHome: "%DATA_HOME%" + + # serverStartPolicy legal values are "NEVER", "IF_NEEDED", or "ADMIN_ONLY" + # This determines which WebLogic Servers the Operator will start up when it discovers this Domain + # - "NEVER" will not start any server in the domain + # - "ADMIN_ONLY" will start up only the administration server (no managed servers will be started) + # - "IF_NEEDED" will start all non-clustered servers, including the administration server and clustered servers up to the replica count + serverStartPolicy: "%SERVER_START_POLICY%" + + serverPod: + # an (optional) list of environment variable to be set on the servers + env: + - name: JAVA_OPTIONS + value: "%JAVA_OPTIONS%" + - name: USER_MEM_ARGS + value: "-Djava.security.egd=file:/dev/./urandom -Xms256m -Xmx1024m " + %OPTIONAL_SERVERPOD_RESOURCES% + %LOG_HOME_ON_PV_PREFIX%volumes: + %LOG_HOME_ON_PV_PREFIX%- name: weblogic-domain-storage-volume + %LOG_HOME_ON_PV_PREFIX% persistentVolumeClaim: + %LOG_HOME_ON_PV_PREFIX% claimName: %DOMAIN_PVC_NAME% + %LOG_HOME_ON_PV_PREFIX%volumeMounts: + %LOG_HOME_ON_PV_PREFIX%- mountPath: %DOMAIN_ROOT_DIR% + %LOG_HOME_ON_PV_PREFIX% name: weblogic-domain-storage-volume + + # adminServer is used to configure the desired behavior for starting the administration server. + adminServer: + # serverStartState legal values are "RUNNING" or "ADMIN" + # "RUNNING" means the listed server will be started up to "RUNNING" mode + # "ADMIN" means the listed server will be start up to "ADMIN" mode + serverStartState: "RUNNING" + %EXPOSE_ANY_CHANNEL_PREFIX%adminService: + %EXPOSE_ANY_CHANNEL_PREFIX% channels: + # The Admin Server's NodePort + %EXPOSE_ADMIN_PORT_PREFIX% - channelName: default + %EXPOSE_ADMIN_PORT_PREFIX% nodePort: %ADMIN_NODE_PORT% + # Uncomment to export the T3Channel as a service + %EXPOSE_T3_CHANNEL_PREFIX% - channelName: T3Channel + serverPod: + # an (optional) list of environment variable to be set on the admin servers + env: + - name: USER_MEM_ARGS + value: "-Djava.security.egd=file:/dev/./urandom -Xms512m -Xmx1024m " + + # clusters is used to configure the desired behavior for starting member servers of a cluster. + # If you use this entry, then the rules will be applied to ALL servers that are members of the named clusters. + clusters: + - clusterName: %CLUSTER_NAME% + serverStartState: "RUNNING" + serverPod: + # Instructs Kubernetes scheduler to prefer nodes for new cluster members where there are not + # already members of the same cluster. + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: "weblogic.clusterName" + operator: In + values: + - $(CLUSTER_NAME) + topologyKey: "kubernetes.io/hostname" + replicas: %INITIAL_MANAGED_SERVER_REPLICAS% + # The number of managed servers to start for unlisted clusters + # replicas: 1 + + # Istio + %ISTIO_PREFIX%configuration: + %ISTIO_PREFIX% istio: + %ISTIO_PREFIX% enabled: %ISTIO_ENABLED% + %ISTIO_PREFIX% readinessPort: %ISTIO_READINESS_PORT% + diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/config_ms.yml b/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/config_ms.yml deleted file mode 100755 index a6e1f113e..000000000 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/config_ms.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -metricsNameSnakeCase: true -restPort: 8888 -queries: -- key: name - keyName: location - prefix: wls_server_ - applicationRuntimes: - key: name - keyName: app - componentRuntimes: - prefix: wls_webapp_config_ - type: WebAppComponentRuntime - key: name - values: [deploymentState, contextRoot, sourceInfo, openSessionsHighCount, openSessionsCurrentCount, sessionsOpenedTotalCount, sessionCookieMaxAgeSecs, sessionInvalidationIntervalSecs, sessionTimeoutSecs, singleThreadedServletPoolSize, sessionIDLength, servletReloadCheckSecs, jSPPageCheckSecs] - servlets: - prefix: wls_servlet_ - key: servletName - -- JVMRuntime: - prefix: wls_jvm_ - key: name - -- executeQueueRuntimes: - prefix: wls_socketmuxer_ - key: name - values: [pendingRequestCurrentCount] - -- workManagerRuntimes: - prefix: wls_workmanager_ - key: name - values: [stuckThreadCount, pendingRequests, completedRequests] - -- threadPoolRuntime: - prefix: wls_threadpool_ - key: name - values: [executeThreadTotalCount, queueLength, stuckThreadCount, hoggingThreadCount] - -- JMSRuntime: - key: name - keyName: jmsruntime - prefix: wls_jmsruntime_ - JMSServers: - prefix: wls_jms_ - key: name - keyName: jmsserver - destinations: - prefix: wls_jms_dest_ - key: name - keyName: destination - -- persistentStoreRuntimes: - prefix: wls_persistentstore_ - key: name -- JDBCServiceRuntime: - JDBCDataSourceRuntimeMBeans: - prefix: wls_datasource_ - key: name -- JTARuntime: - prefix: wls_jta_ - key: name diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/get1.1.0.sh b/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/get1.1.0.sh deleted file mode 100755 index 5dccd1a71..000000000 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/get1.1.0.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -curl -L -O https://github.com/oracle/weblogic-monitoring-exporter/releases/download/v1.1.0/wls-exporter.war - -echo "-------------------wls-exporter-ms start-------------------" -tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) -mkdir -p $tmp_dir/WEB-INF -echo "created $tmp_dir" - -cp config/config_ms.yml $tmp_dir/config.yml -cp config/weblogic.xml $tmp_dir/WEB-INF/weblogic.xml -echo "Copying completed" - -warDir=$PWD -pushd $tmp_dir - -cp $warDir/wls-exporter.war $warDir/wls-exporter-ms.war -echo "in temp dir" -zip $warDir/wls-exporter-ms.war WEB-INF/weblogic.xml -zip $warDir/wls-exporter-ms.war config.yml -echo "wls-exporter-ms.war is ready" -echo "-------------------wls-exporter-ms end-------------------" - -echo "-------------------wls-exporter-as start-------------------" -cp $warDir/config/config_as.yml $tmp_dir/config.yml -echo "Copying completed" -cp $warDir/wls-exporter.war $warDir/wls-exporter-as.war -echo "in temp dir" -zip $warDir/wls-exporter-as.war WEB-INF/weblogic.xml -zip $warDir/wls-exporter-as.war config.yml -echo "wls-exporter-as.war is ready" -echo "-------------------wls-exporter-as end-------------------" -echo "zip completed" -popd -rm -rf $tmp_dir -rm $warDir/wls-exporter.war diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-credentials/README.md b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-credentials/README.md new file mode 100644 index 000000000..adfa4c097 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-credentials/README.md @@ -0,0 +1,50 @@ +# Creating credentials for a WebLogic domain + +This sample demonstrates how to create a Kubernetes secret containing the +credentials for a WebLogic domain. The operator expects this secret to be +named following the pattern `domainUID-weblogic-credentials`, where `domainUID` +is the unique identifier of the domain. It must be in the same namespace +that the domain will run in. + +To use the sample, run the command: + +``` +$ ./create-weblogic-credentials.sh -u username -p password -d domainUID -n namespace -s secretName +``` + +The parameters are as follows: + +``` + -u user name, must be specified. + -p password, must be specified. + -d domainUID, optional. The default value is wcp-domain. If specified, the secret will be labeled with the domainUID unless the given value is an empty string. + -n namespace, optional. Use the wcpns namespace if not specified. + -s secretName, optional. If not specified, the secret name will be determined based on the domainUID value. +``` + +This creates a `generic` secret containing the user name and password as literal values. + +You can check the secret with the `kubectl get secret` command. An example is shown below, +including the output: + +``` +$ kubectl -n wcpns get secret wcp-domain-weblogic-credentials -o yaml +apiVersion: v1 +data: + password: d2VsY29tZTE= + username: d2VibG9naWM= +kind: Secret +metadata: + creationTimestamp: 2018-12-12T20:25:20Z + labels: + weblogic.domainName: wcp-domain + weblogic.domainUID: wcp-domain + name: wcp-domain-weblogic-credentials + namespace: wcpns + resourceVersion: "5680" + selfLink: /api/v1/namespaces/wcpns/secrets/wcp-domain-weblogic-credentials + uid: 0c2b3510-fe4c-11e8-994d-00001700101d +type: Opaque + +``` + diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-credentials/create-weblogic-credentials.sh b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-credentials/create-weblogic-credentials.sh new file mode 100644 index 000000000..8780639a5 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-credentials/create-weblogic-credentials.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description +# This sample script creates a Kubernetes secret for WebLogic domain admin credentials. +# +# The following pre-requisites must be handled prior to running this script: +# * The kubernetes namespace must already be created +# +# Secret name determination +# 1) secretName - if specified +# 2) wcp-domain-weblogic-credentials - if secretName and domainUID are both not specified. This is the default out-of-the-box. +# 3) -weblogic-credentials - if secretName is not specified, and domainUID is specified. +# 4) weblogic-credentials - if secretName is not specified, and domainUID is specified as "". +# +# The generated secret will be labeled with +# weblogic.domainUID=$domainUID +# and +# weblogic.domainName=$domainUID +# Where the $domainUID is the value of the -d command line option, unless the value supplied is an empty String "" +# + +script="${BASH_SOURCE[0]}" + +# +# Function to exit and print an error message +# $1 - text of message +function fail { + echo [ERROR] $* + exit 1 +} + +# Try to execute kubectl to see whether kubectl is available +function validateKubectlAvailable { + if ! [ -x "$(command -v kubectl)" ]; then + fail "kubectl is not installed" + fi +} + +function usage { + echo usage: ${script} -u username -p password [-d domainUID] [-n namespace] [-s secretName] [-h] + echo " -u username, must be specified." + echo " -p password, must be specified." + echo " -d domainUID, optional. The default value is wcp-domain. If specified, the secret will be labeled with the domainUID unless the given value is an empty string." + echo " -n namespace, optional. Use the wcpns namespace if not specified" + echo " -s secretName, optional. If not specified, the secret name will be determined based on the domainUID value" + echo " -h Help" + exit $1 +} + +# +# Parse the command line options +# +domainUID=wcp-domain +namespace=wcpns +while getopts "hu:p:n:d:s:" opt; do + case $opt in + u) username="${OPTARG}" + ;; + p) password="${OPTARG}" + ;; + n) namespace="${OPTARG}" + ;; + d) domainUID="${OPTARG}" + ;; + s) secretName="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z $secretName ]; then + if [ -z $domainUID ]; then + secretName=weblogic-credentials + else + secretName=$domainUID-weblogic-credentials + fi +fi + +if [ -z ${username} ]; then + echo "${script}: -u must be specified." + missingRequiredOption="true" +fi + +if [ -z ${password} ]; then + echo "${script}: -p must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +# check and see if the secret already exists +result=`kubectl get secret ${secretName} -n ${namespace} --ignore-not-found=true | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${result:=Error}" != "0" ]; then + fail "The secret ${secretName} already exists in namespace ${namespace}." +fi + +# create the secret +kubectl -n $namespace create secret generic $secretName \ + --from-literal=username=$username \ + --from-literal=password=$password + +# label the secret with domainUID if needed +if [ ! -z $domainUID ]; then + kubectl label secret ${secretName} -n $namespace weblogic.domainUID=$domainUID weblogic.domainName=$domainUID +fi + +# Verify the secret exists +SECRET=`kubectl get secret ${secretName} -n ${namespace} | grep ${secretName} | wc | awk ' { print $1; }'` +if [ "${SECRET}" != "1" ]; then + fail "The secret ${secretName} was not found in namespace ${namespace}" +fi + +echo "The secret ${secretName} has been successfully created in the ${namespace} namespace." + diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/README.md b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/README.md new file mode 100644 index 000000000..1947691b3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/README.md @@ -0,0 +1,222 @@ +# Sample persistent volume and persistent volume claim + +The sample scripts demonstrate the creation of a Kubernetes persistent volume (PV) and persistent volume claim (PVC), which can then be used in a domain resource as a persistent storage for the WebLogic domain home or log files. + +A PV and PVC can be shared by multiple WebLogic domains or dedicated to a particular domain. + +## Prerequisites + +Please read the [Persistent Volumes](../../../../site/persistent-volumes.md) guide before proceeding. + +## Using the scripts to create a PV and PVC + +Prior to running the `create-pv-pvc.sh` script, make a copy of the `create-pv-pvc-inputs.yaml` file, and uncomment and explicitly configure the `weblogicDomainStoragePath` property in the inputs file. + +Run the create script, pointing it at your inputs file and an output directory: + +``` +$ ./create-pv-pvc.sh \ + -i create-pv-pvc-inputs.yaml \ + -o /path/to/output-directory +``` + +The `create-pv-pvc.sh` script will create a subdirectory `pv-pvcs` under the given `/path/to/output-directory` directory. By default, the script generates two YAML files, namely `weblogic-sample-pv.yaml` and `weblogic-sample-pvc.yaml`, in the `/path/to/output-directory/pv-pvcs`. These two YAML files can be used to create the Kubernetes resources using the `kubectl create -f` command. + +``` +$ kubectl create -f wcp-domain-domain-pv.yaml +$ kubectl create -f wcp-domain-domain-pvc.yaml + +``` + +As a convenience, the script can optionally create the PV and PVC resources using the `-e` option. + +The usage of the create script is as follows: + +``` +$ sh create-pv-pvc.sh -h +usage: create-pv-pvc.sh -i file -o dir [-e] [-h] + -i Parameter inputs file, must be specified. + -o Output directory for the generated yaml files, must be specified. + -e Also create the Kubernetes objects using the generated yaml files + -h Help +``` + +If you copy the sample scripts to a different location, make sure that you copy everything in the `/kubernetes/samples/scripts` directory together into the target directory, maintaining the original directory hierarchy. + +## Configuration parameters + +The PV and PVC creation inputs can be customized by editing the `create-pv-pvc-inputs.yaml` file. + +| Parameter | Definition | Default | +| --- | --- | --- | +| `domainUID` | ID of the domain resource to which the generated PV and PVC will be dedicated. Leave it empty if the PV and PVC are going to be shared by multiple domains. | no default | +| `namespace` | Kubernetes namespace to create the PVC. | `default` | +| `baseName` | Base name of the PV and PVC. The generated PV and PVC will be `-pv` and `-pvc` respectively. | `weblogic-sample` | +| `weblogicDomainStoragePath` | Physical path of the storage for the PV. When `weblogicDomainStorageType` is set to `HOST_PATH`, this value should be set the to path to the domain storage on the Kubernetes host. When `weblogicDomainStorageType` is set to NFS, then `weblogicDomainStorageNFSServer` should be set to the IP address or name of the DNS server, and this value should be set to the exported path on that server. Note that the path where the domain is mounted in the WebLogic containers is not affected by this setting, that is determined when you create your domain. | no default | +| `weblogicDomainStorageReclaimPolicy` | Kubernetes PVC policy for the persistent storage. The valid values are: `Retain`, `Delete`, and `Recycle`. | `Retain` | +| `weblogicDomainStorageSize` | Total storage allocated for the PVC. | `10Gi` | +| `weblogicDomainStorageType` | Type of storage. Legal values are `NFS` and `HOST_PATH`. If using `NFS`, `weblogicDomainStorageNFSServer` must be specified. | `HOST_PATH` | +| `weblogicDomainStorageNFSServer`| Name or IP address of the NFS server. This setting only applies if `weblogicDomainStorateType` is `NFS`. | no default | + +## Shared versus dedicated PVC + +By default, the `domainUID` is left empty in the inputs file, which means the generated PV and PVC will not be associated with a particular domain, but can be shared by multiple domain resources in the same Kubernetes namespaces as the PV and PVC. + +For the use cases where dedicated PV and PVC are desired for a particular domain, the `domainUID` needs to be set in the `create-pv-pvc-inputs.yaml` file. The presence of a non-empty `domainUID` in the inputs file will cause the generated PV and PVC to be associated with the specified `domainUID`. The association includes that the names of the generated YAML files and the Kubernetes PV and PVC objects are decorated with the `domainUID`, and the PV and PVC objects are also labeled with the `domainUID`. + +## Verify the results + +The create script will verify that the PV and PVC were created, and will report a failure if there was any error. However, it may be desirable to manually verify the PV and PVC, even if just to gain familiarity with the various Kubernetes objects that were created by the script. + +### Generated YAML files with the default inputs + +The content of the generated `wcp-domain-domain-pvc.yaml`: + +``` +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: wcp-domain-domain-pvc + namespace: default + + storageClassName: wcp-domain-domain-storage-class + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi +``` + +The content of the generated `wcp-domain-domain-pv.yaml`: +``` +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: v1 +kind: PersistentVolume +metadata: + name: wcp-domain-domain-pv + # labels: + # weblogic.domainUID: +spec: + storageClassName: wcp-domain-domain-storage-class + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + # Valid values are Retain, Delete or Recycle + persistentVolumeReclaimPolicy: Retain + hostPath: + # nfs: + # server: %SAMPLE_STORAGE_NFS_SERVER% + path: "/scratch/k8s_dir" + +``` + +### Generated YAML files for dedicated PV and PVC + +The content of the generated `wcp-domain-domain-pvc.yaml` when `domainUID` is set to `domain1`: + +``` +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: wcp-domain-domain-pvc + namespace: default + labels: + weblogic.domainUID: wcp-domain +spec: + storageClassName: wcp-domain-domain-storage-class + accessModes: + - ReadWriteMany + resources: + requests: + storage: 10Gi +``` + +The content of the generated `wcp-domain-domain-pv.yaml` when `domainUID` is set to `domain1`: +``` +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: v1 +kind: PersistentVolume +metadata: + name: wcp-domain-domain-pv + labels: + weblogic.domainUID: wcp-domain +spec: + storageClassName: wcp-domain-domain-storage-class + capacity: + storage: 10Gi + accessModes: + - ReadWriteMany + # Valid values are Retain, Delete or Recycle + persistentVolumeReclaimPolicy: Retain + hostPath: + # nfs: + # server: %SAMPLE_STORAGE_NFS_SERVER% + path: "/scratch/k8s_dir" +``` + +### Verify the PV and PVC objects + +You can use this command to verify the persistent volume was created, note that the `Status` field +should have the value `Bound`, indicating the that persistent volume has been claimed: + +``` +$ kubectl describe pv wcp-domain-domain-pv +Name: wcp-domain-domain-pv +Annotations: pv.kubernetes.io/bound-by-controller=yes +StorageClass: wcp-domain-domain-storage-class +Status: Bound +Claim: default/wcp-domain-domain-pvc +Reclaim Policy: Retain +Access Modes: RWX +Capacity: 10Gi +Message: +Source: + Type: HostPath (bare host directory volume) + Path: /scratch/k8s_dir + HostPathType: +Events: + +``` + +You can use this command to verify the persistent volume claim was created: + +``` +$ kubectl describe pvc wcp-domain-domain-pvc +Name: wcp-domain-domain-pvc +Namespace: default +StorageClass: wcp-domain-domain-storage-class +Status: Bound +Volume: wcp-domain-domain-pv +Annotations: pv.kubernetes.io/bind-completed=yes + pv.kubernetes.io/bound-by-controller=yes +Finalizers: [] +Capacity: 10Gi +Access Modes: RWX +Events: + +``` + +## Troubleshooting + +* Message: `[ERROR] The weblogicDomainStoragePath parameter in kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml is missing, null or empty` +Edit the file and set the value of the field. This value must be a directory that is world writable. +Optionally, follow these steps to tighten permissions on the named directory after you run the sample the first time: + + * Become the root user. + * `ls -nd $value-of-weblogicDomainStoragePath` + * Note the values of the third and fourth field of the output. + * `chown $third-field:$fourth-field $value-of-weblogicDomainStoragePath` + * `chmod 755 $value-of-weblogicDomainStoragePath` + * Return to your normal user ID. + diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml new file mode 100644 index 000000000..d18959c27 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml @@ -0,0 +1,44 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# The version of this inputs file. Do not modify. +version: create-wcp-domain-pv-pvc-inputs-v1 + +# The base name of the pv and pvc +baseName: domain + +# Unique ID identifying a domain. +# If left empty, the generated pv can be shared by multiple domains +# This ID must not contain an underscope ("_"), and must be lowercase and unique across all domains in a Kubernetes cluster. +domainUID: wcp-domain + +# Name of the namespace for the persistent volume claim +namespace: wcpns + +# Persistent volume type for the persistent storage. +# The value must be 'HOST_PATH' or 'NFS'. +# If using 'NFS', weblogicDomainStorageNFSServer must be specified. +weblogicDomainStorageType: HOST_PATH + +# The server name or ip address of the NFS server to use for the persistent storage. +# The following line must be uncomment and customized if weblogicDomainStorateType is NFS: +#weblogicDomainStorageNFSServer: nfsServer + +# Physical path of the persistent storage. +# When weblogicDomainStorageType is set to HOST_PATH, this value should be set the to path to the +# domain storage on the Kubernetes host. +# When weblogicDomainStorageType is set to NFS, then weblogicDomainStorageNFSServer should be set +# to the IP address or name of the DNS server, and this value should be set to the exported path +# on that server. +# Note that the path where the domain is mounted in the WebLogic containers is not affected by this +# setting, that is determined when you create your domain. +# The following line must be uncomment and customized: +weblogicDomainStoragePath: /scratch/k8s_dir + +# Reclaim policy of the persistent storage +# The valid values are: 'Retain', 'Delete', and 'Recycle' +weblogicDomainStorageReclaimPolicy: Retain + +# Total storage allocated to the persistent storage. +weblogicDomainStorageSize: 10Gi + diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/create-pv-pvc.sh b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/create-pv-pvc.sh new file mode 100644 index 000000000..ba3de3459 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/create-pv-pvc.sh @@ -0,0 +1,267 @@ +#!/usr/bin/env bash +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description +# This sample script generates the Kubernetes yaml files for a persistent volume and persistent volume claim +# that can be used by a domain custom resource. +# +# The creation inputs can be customized by editing create-pv-pvc-inputs.yaml +# +# The following pre-requisites must be handled prior to running this script: +# * The Kubernetes namespace must already be created +# + +# Initialize +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/../common/utility.sh +source ${scriptDir}/../common/validate.sh + +function usage { + echo usage: ${script} -i file -o dir [-e] [-h] + echo " -i Parameter inputs file, must be specified." + echo " -o Output directory for the generated yaml files, must be specified." + echo " -e Also create the Kubernetes objects using the generated yaml files" + echo " -h Help" + exit $1 +} + +# +# Parse the command line options +# +executeIt=false +while getopts "ehi:o:" opt; do + case $opt in + i) valuesInputFile="${OPTARG}" + ;; + o) outputDir="${OPTARG}" + ;; + e) executeIt=true + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${valuesInputFile} ]; then + echo "${script}: -i must be specified." + missingRequiredOption="true" +fi + +if [ -z ${outputDir} ]; then + echo "${script}: -o must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +# +# Function to initialize and validate the output directory +# for the generated yaml files for this domain. +# +function initOutputDir { + pvOutputDir="$outputDir/pv-pvcs" + + if [ -z ${domainUID} ]; then + pvOutput="${pvOutputDir}/${baseName}-pv.yaml" + pvcOutput="${pvOutputDir}/${baseName}-pvc.yaml" + persistentVolumeName=${baseName}-pv + persistentVolumeClaimName=${baseName}-pvc + else + pvOutput="${pvOutputDir}/${domainUID}-${baseName}-pv.yaml" + pvcOutput="${pvOutputDir}/${domainUID}-${baseName}-pvc.yaml" + persistentVolumeName=${domainUID}-${baseName}-pv + persistentVolumeClaimName=${domainUID}-${baseName}-pvc + fi + removeFileIfExists ${pvOutputDir}/{valuesInputFile} + removeFileIfExists ${pvOutputDir}/{pvOutput} + removeFileIfExists ${pvOutputDir}/{pvcOutput} + removeFileIfExists ${pvOutputDir}/create-pv-pvc-inputs.yaml +} + +# +# Function to setup the environment to run the create domain job +# +function initialize { + + # Validate the required files exist + validateErrors=false + + if [ -z "${valuesInputFile}" ]; then + validationError "You must use the -i option to specify the name of the inputs parameter file (a modified copy of kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/create-pv-pvc-inputs.yaml)." + else + if [ ! -f ${valuesInputFile} ]; then + validationError "Unable to locate the input parameters file ${valuesInputFile}" + fi + fi + + if [ -z "${outputDir}" ]; then + validationError "You must use the -o option to specify the name of an existing directory to store the generated yaml files in." + fi + + domainPVInput="${scriptDir}/pv-template.yaml" + if [ ! -f ${domainPVInput} ]; then + validationError "The template file ${domainPVInput} for generating a persistent volume was not found" + fi + + domainPVCInput="${scriptDir}/pvc-template.yaml" + if [ ! -f ${domainPVCInput} ]; then + validationError "The template file ${domainPVCInput} for generating a persistent volume claim was not found" + fi + + failIfValidationErrors + + # Parse the commonn inputs file + parseCommonInputs + validateInputParamsSpecified \ + weblogicDomainStoragePath \ + weblogicDomainStorageSize \ + baseName \ + namespace \ + version + + export requiredInputsVersion="create-weblogic-sample-domain-pv-pvc-inputs-v1" + validateDomainUid + validateNamespace + validateWeblogicDomainStorageType + validateWeblogicDomainStorageReclaimPolicy + initOutputDir + failIfValidationErrors +} + + +# +# Function to generate the yaml files for creating a domain +# +function createYamlFiles { + + # Create a directory for this domain's output files + mkdir -p ${pvOutputDir} + + # Make sure the output directory has a copy of the inputs file. + # The user can either pre-create the output directory, put the inputs + # file there, and create the domain from it, or the user can put the + # inputs file some place else and let this script create the output directory + # (if needed) and copy the inputs file there. + copyInputsFileToOutputDirectory ${valuesInputFile} "${pvOutputDir}/create-pv-pvc-inputs.yaml" + + enabledPrefix="" # uncomment the feature + disabledPrefix="# " # comment out the feature + + echo Generating ${pvOutput} + + cp ${domainPVInput} ${pvOutput} + if [ "${weblogicDomainStorageType}" == "NFS" ]; then + hostPathPrefix="${disabledPrefix}" + nfsPrefix="${enabledPrefix}" + sed -i -e "s:%SAMPLE_STORAGE_NFS_SERVER%:${weblogicDomainStorageNFSServer}:g" ${pvOutput} + else + hostPathPrefix="${enabledPrefix}" + nfsPrefix="${disabledPrefix}" + fi + + sed -i -e "s:%NAMESPACE%:$namespace:g" ${pvOutput} + if [ -z ${domainUID} ]; then + domainUIDLabelPrefix="${disabledPrefix}" + separator="" + else + domainUIDLabelPrefix="${enabledPrefix}" + separator="-" + fi + sed -i -e "s:%DOMAIN_UID%:$domainUID:g" ${pvOutput} + sed -i -e "s:%SEPARATOR%:$separator:g" ${pvOutput} + sed -i -e "s:%DOMAIN_UID_LABEL_PREFIX%:${domainUIDLabelPrefix}:g" ${pvOutput} + + sed -i -e "s:%BASE_NAME%:$baseName:g" ${pvOutput} + sed -i -e "s:%SAMPLE_STORAGE_PATH%:${weblogicDomainStoragePath}:g" ${pvOutput} + sed -i -e "s:%SAMPLE_STORAGE_RECLAIM_POLICY%:${weblogicDomainStorageReclaimPolicy}:g" ${pvOutput} + sed -i -e "s:%SAMPLE_STORAGE_SIZE%:${weblogicDomainStorageSize}:g" ${pvOutput} + sed -i -e "s:%HOST_PATH_PREFIX%:${hostPathPrefix}:g" ${pvOutput} + sed -i -e "s:%NFS_PREFIX%:${nfsPrefix}:g" ${pvOutput} + + # Generate the yaml to create the persistent volume claim + echo Generating ${pvcOutput} + + cp ${domainPVCInput} ${pvcOutput} + sed -i -e "s:%NAMESPACE%:$namespace:g" ${pvcOutput} + sed -i -e "s:%BASE_NAME%:${baseName}:g" ${pvcOutput} + + sed -i -e "s:%DOMAIN_UID%:$domainUID:g" ${pvcOutput} + sed -i -e "s:%SEPARATOR%:$separator:g" ${pvcOutput} + sed -i -e "s:%DOMAIN_UID_LABEL_PREFIX%:${domainUIDLabelPrefix}:g" ${pvcOutput} + + sed -i -e "s:%SAMPLE_STORAGE_SIZE%:${weblogicDomainStorageSize}:g" ${pvcOutput} + + # Remove any "...yaml-e" files left over from running sed + rm -f ${pvOutputDir}/*.yaml-e +} + +# +# Function to create the domain's persistent volume +# +function createDomainPV { + # Check if the persistent volume is already available + checkPvExists ${persistentVolumeName} + if [ "${PV_EXISTS}" = "false" ]; then + echo Creating the persistent volume ${persistentVolumeName} + kubectl create -f ${pvOutput} + checkPvState ${persistentVolumeName} Available + fi +} + +# +# Function to create the domain's persistent volume claim +# Must be called after createDomainPV since it relies on +# createDomainPV defining persistentVolumeName +# +function createDomainPVC { + # Check if the persistent volume claim is already available + checkPvcExists ${persistentVolumeClaimName} ${namespace} + if [ "${PVC_EXISTS}" = "false" ]; then + echo Creating the persistent volume claim ${persistentVolumeClaimName} + kubectl create -f ${pvcOutput} + checkPvState ${persistentVolumeName} Bound + fi +} + +# +# Function to output to the console a summary of the work completed +# +function printSummary { + echo "The following files were generated:" + echo " ${pvOutput}" + echo " ${pvcOutput}" +} + +# +# Perform the following sequence of steps to create a domain +# + +# Setup the environment for running this script and perform initial validation checks +initialize + +# Generate the yaml files for creating the domain +createYamlFiles + +# All done if the generate only option is true +if [ "${executeIt}" = true ]; then + + # Create the domain's persistent volume + createDomainPV + + # Create the domain's persistent volume claim + createDomainPVC +fi + +# Output a job summary +printSummary + +echo +echo Completed + + diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/pv-template.yaml b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/pv-template.yaml new file mode 100644 index 000000000..49e33a22f --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/pv-template.yaml @@ -0,0 +1,21 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: v1 +kind: PersistentVolume +metadata: + name: %DOMAIN_UID%%SEPARATOR%%BASE_NAME%-pv + labels: + %DOMAIN_UID_LABEL_PREFIX%weblogic.domainUID: %DOMAIN_UID% +spec: + storageClassName: %DOMAIN_UID%%SEPARATOR%%BASE_NAME%-storage-class + capacity: + storage: %SAMPLE_STORAGE_SIZE% + accessModes: + - ReadWriteMany + # Valid values are Retain, Delete or Recycle + persistentVolumeReclaimPolicy: %SAMPLE_STORAGE_RECLAIM_POLICY% + %HOST_PATH_PREFIX%hostPath: + %NFS_PREFIX%nfs: + %NFS_PREFIX%server: %SAMPLE_STORAGE_NFS_SERVER% + path: "%SAMPLE_STORAGE_PATH%" diff --git a/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/pvc-template.yaml b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/pvc-template.yaml new file mode 100644 index 000000000..49e8d5afb --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/create-weblogic-domain-pv-pvc/pvc-template.yaml @@ -0,0 +1,17 @@ +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: %DOMAIN_UID%%SEPARATOR%%BASE_NAME%-pvc + namespace: %NAMESPACE% + labels: + %DOMAIN_UID_LABEL_PREFIX%weblogic.domainUID: %DOMAIN_UID% +spec: + storageClassName: %DOMAIN_UID%%SEPARATOR%%BASE_NAME%-storage-class + accessModes: + - ReadWriteMany + resources: + requests: + storage: %SAMPLE_STORAGE_SIZE% diff --git a/OracleWebCenterPortal/kubernetes/delete-domain/README.md b/OracleWebCenterPortal/kubernetes/delete-domain/README.md new file mode 100644 index 000000000..800c7094a --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/delete-domain/README.md @@ -0,0 +1,27 @@ +# Deleting domain resources created while executing the samples + +After running the sample, you will need to release domain resources that +can then be used for other purposes. The script in this sample demonstrates one approach to releasing +domain resources. + +## Using the script to delete domain resources + +```shell +$ ./delete-weblogic-domain-resources.sh \ + -d domain-uid[,domain-uid...] \ + [-s max-seconds] \ + [-t] +``` +The required option `-d` takes `domain-uid` values (separated + by commas and no spaces) to identify the domain resources that should be deleted. + +To limit the amount of time spent on attempting to delete domain resources, use `-s`. +The option must be followed by an integer that represents the total number of seconds +that will be spent attempting to delete resources. The default number of seconds is 120. + +The optional option `-t` shows what the script will delete without executing the deletion. + +To see the help associated with the script: +```shell +$ ./delete-weblogic-domain-resources.sh -h +``` diff --git a/OracleWebCenterPortal/kubernetes/delete-domain/delete-weblogic-domain-resources.sh b/OracleWebCenterPortal/kubernetes/delete-domain/delete-weblogic-domain-resources.sh new file mode 100644 index 000000000..fd54d1ea0 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/delete-domain/delete-weblogic-domain-resources.sh @@ -0,0 +1,283 @@ +#!/bin/bash +# Copyright (c) 2019, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Description: +# Use this script to delete all kubernetes resources associated +# with a set of given domains. Alternatively, run the script +# in a test mode to show what would be deleted without actually +# performing the deletes. +# +# Usage: +# See "function usage" below or call this script with no parameters. +# + +script="${BASH_SOURCE[0]}" + +function usage { +cat << EOF + Usage: + + $(basename $0) -d domain-uid,domain-uid,... [-s max-seconds] [-t] + $(basename $0) -h + + Perform a best-effort delete of the kubernetes resources for + the given domain(s), and retry until either max-seconds is reached + or all resources were deleted (default $default_maxwaitsecs seconds). + + The domains can be specified as a comma-separated list of + domain-uids (no spaces). The domains can be located in any + kubernetes namespace. + + Specify '-t' to run the script in a test mode which will + show kubernetes commands but not actually perform them. + + The script runs in phases: + + Phase 1: Set the serverStartPolicy of each domain to NEVER if + it's not already NEVER. This should cause each + domain's operator to initiate a controlled shutdown + of the domain. Immediately proceed to phase 2. + + Phase 2: Wait up to half of max-seconds for WebLogic + Server pods to exit normally, and then proceed + to phase 3. + + Phase 3: Periodically delete any remaining kubernetes resources + for the specified domains, including any pods + leftover from previous phases. Exit and fail if + max-seconds is exceeded and there are any leftover + kubernetes resources. + + This script exits with a zero status on success, and a + non-zero status on failure. +EOF +} + +# +# getDomainResources domain(s) outfilename +# +# Usage: +# getDomainResources domainA,domainB,... outfilename +# +# Internal helper function +# +# File output is all domain related resources for the given domain uids, one per line, +# in the form: 'kind name [-n namespace]'. For example: +# PersistentVolumeClaim domain1-pv-claim -n default +# PersistentVolume domain1-pv +# +function getDomainResources { + local domain_regex='' + LABEL_SELECTOR="weblogic.domainUID in ($1)" + IFS=',' read -ra UIDS <<< "$1" + for i in "${!UIDS[@]}"; do + if [ $i -gt 0 ]; then + domain_regex="$domain_regex|" + fi + domain_regex="$domain_regex^Domain ${UIDS[$i]} " + done + + # clean the output file + if [ -e $2 ]; then + rm $2 + fi + + # first, let's get all namespaced types with -l $LABEL_SELECTOR + NAMESPACED_TYPES="pod,job,deploy,rs,service,pvc,ingress,cm,serviceaccount,role,rolebinding,secret" + + kubectl get $NAMESPACED_TYPES \ + -l "$LABEL_SELECTOR" \ + -o=jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{" -n "}{.metadata.namespace}{"\n"}{end}' \ + --all-namespaces=true >> $2 + + # if domain crd exists, look for domains too: + kubectl get crd domains.weblogic.oracle > /dev/null 2>&1 + if [ $? -eq 0 ]; then + kubectl get domain \ + -o=jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{" -n "}{.metadata.namespace}{"\n"}{end}' \ + --all-namespaces=true | egrep "$domain_regex" >> $2 + fi + + # now, get all non-namespaced types with -l $LABEL_SELECTOR + + NOT_NAMESPACED_TYPES="pv,clusterroles,clusterrolebindings" + + kubectl get $NOT_NAMESPACED_TYPES \ + -l "$LABEL_SELECTOR" \ + -o=jsonpath='{range .items[*]}{.kind}{" "}{.metadata.name}{"\n"}{end}' \ + --all-namespaces=true >> $2 +} + +# +# deleteDomains domain(s) maxwaitsecs +# +# Usage: +# deleteDomains domainA,domainB,... maxwaitsecs +# +# Internal helper function +# This function first sets the serverStartPolicy of each Domain to NEVER +# and waits up to half of $2 for pods to 'self delete'. It then performs +# a helm delete on $1, and finally it directly deletes +# any remaining k8s resources for domain $1 (including any remaining pods) +# and retries these direct deletes up to $2 seconds. +# +# If global $test_mode is true, it shows candidate actions but doesn't +# actually perform them +# +function deleteDomains { + + if [ "$test_mode" = "true" ]; then + echo @@ Test mode! Displaying commands for deleting kubernetes resources with label weblogic.domainUID \'$1\' without actually deleting them. + else + echo @@ Deleting kubernetes resources with label weblogic.domainUID \'$1\'. + fi + + local maxwaitsecs=${2:-$default_maxwaitsecs} + local tempfile="/tmp/$(basename $0).tmp.$$" # == /tmp/[script-file-name].tmp.[pid] + local mstart=`date +%s` + local phase=1 + + while : ; do + # get all k8s resources with matching domain-uid labels and put them in $tempfile + getDomainResources $1 $tempfile + + # get a count of all k8s resources with matching domain-uid labels + local allcount=`wc -l $tempfile | awk '{ print $1 }'` + + # get a count of all WLS pods (any pod with a matching domain-uid label that doesn't have 'traefik' or 'apache' embedded in its name) + local podcount=`grep "^Pod" $tempfile | grep -v traefik | grep -v apache | wc -l | awk '{ print $1 }'` + + local mnow=`date +%s` + + echo @@ $allcount resources remaining after $((mnow - mstart)) seconds, including $podcount WebLogic Server pods. Max wait is $maxwaitsecs seconds. + + # Exit if all k8s resources deleted or max wait seconds exceeded. + + if [ $allcount -eq 0 ]; then + echo @@ Success. + rm -f $tempfile + exit 0 + elif [ $((mnow - mstart)) -gt $maxwaitsecs ]; then + echo @@ Error! Max wait of $maxwaitsecs seconds exceeded with $allcount resources remaining, including $podcount WebLogic Server pods. Giving up. Remaining resources: + cat $tempfile + rm -f $tempfile + exit $allcount + fi + + # In phase 1, set the serverStartPolicy of each domain to NEVER and then immediately + # proceed to phase 2. If there are no domains or WLS pods, we also immediately go to phase 2. + + if [ $phase -eq 1 ]; then + phase=2 + if [ $podcount -gt 0 ]; then + echo @@ "Setting serverStartPolicy to NEVER on each domain (this should cause operator(s) to initiate a controlled shutdown of the domain's pods.)" + cat $tempfile | grep "^Domain" | while read line; do + local name="`echo $line | awk '{ print $2 }'`" + local namespace="`echo $line | awk '{ print $4 }'`" + if [ "$test_mode" = "true" ]; then + echo "kubectl patch domain $name -n $namespace -p '{\"spec\":{\"serverStartPolicy\":\"NEVER\"}}' --type merge" + else + kubectl patch domain $name -n $namespace -p '{"spec":{"serverStartPolicy":"NEVER"}}' --type merge + fi + done + fi + fi + + # In phase 2, wait for the WLS pod count to go down to 0 for at most half + # of 'maxwaitsecs'. Otherwise proceed immediately to phase 3. + + if [ $phase -eq 2 ]; then + if [ $podcount -eq 0 ]; then + echo @@ All pods shutdown, about to directly delete remaining resources. + phase=3 + elif [ $((mnow - mstart)) -gt $((maxwaitsecs / 2)) ]; then + echo @@ Warning! $podcount WebLogic Server pods remaining but wait time exceeds half of max wait seconds. About to directly delete all remaining resources, including the leftover pods. + phase=3 + else + echo @@ "Waiting for operator to shutdown pods (will wait for no more than half of max wait seconds before directly deleting them)." + sleep 3 + continue + fi + fi + + # In phase 3, directly delete remaining k8s resources for the given domainUids + # (including any leftover WLS pods from previous phases). + + # for each namespace with leftover resources, try delete them + cat $tempfile | awk '{ print $4 }' | grep -v "^$" | sort -u | while read line; do + if [ "$test_mode" = "true" ]; then + echo kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR" + else + kubectl -n $line delete $NAMESPACED_TYPES -l "$LABEL_SELECTOR" + fi + done + + # if there are any non-namespaced types left, try delete them + local no_namespace_count=`grep -c -v " -n " $tempfile` + if [ ! "$no_namespace_count" = "0" ]; then + if [ "$test_mode" = "true" ]; then + echo kubectl delete $NOT_NAMESPACED_TYPES -l "$LABEL_SELECTOR" + else + kubectl delete $NOT_NAMESPACED_TYPES -l "$LABEL_SELECTOR" + fi + fi + + # Delete domains, if any + cat $tempfile | grep "^Domain " | while read line; do + if [ "$test_mode" = "true" ]; then + echo kubectl delete $line + else + kubectl delete $line + fi + done + + sleep 3 + done +} + +# main entry point + +# default when to stop retrying (override via command line) +default_maxwaitsecs=120 + +# optional test mode that lists what would be deleted without +# actually deleting (override via command line) +test_mode=false + +domains="" + +# parse command line options +while getopts ":d:s:th" opt; do + case $opt in + d) domains="${OPTARG}" + ;; + + s) maxwaitsecs="${OPTARG}" + ;; + + t) test_mode="true" + ;; + + h) usage + exit 0 + ;; + + *) usage + exit 9999 + ;; + esac +done + +if [ "$domains" = "" ]; then + usage + exit 9999 +fi + +if [ ! -x "$(command -v kubectl)" ]; then + echo "@@ Error! kubectl is not installed." + exit 9999 +fi + +deleteDomains "${domains}" "${maxwaitsecs:-$default_maxwaitsecs}" + diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/README.md b/OracleWebCenterPortal/kubernetes/domain-lifecycle/README.md new file mode 100644 index 000000000..0eeab95d5 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/README.md @@ -0,0 +1,186 @@ +### Domain life cycle sample scripts + +The operator provides sample scripts to start up or shut down a specific Managed Server or cluster in a deployed domain, or the entire deployed domain. + +**Note**: Prior to running these scripts, you must have previously created and deployed the domain. These scripts make use of [jq](https://stedolan.github.io/jq/) for processing JSON. You must have `jq 1.5 or higher` installed in order to run these scripts. See the installation options on the [jq downlod](https://stedolan.github.io/jq/download/) page. + +These scripts can be helpful when scripting the life cycle of a WebLogic Server domain. For information on how to start, stop, restart, and scale WebLogic Server instances in your domain, see [Domain Life Cycle](https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle). + +#### Scripts to start and stop a WebLogic Server +The `startServer.sh` script starts a WebLogic Server in a domain. For clustered Managed Servers, either it increases the `spec.clusters[].replicas` value for the Managed Server's cluster by `1` or updates the `spec.managedServers[].serverStartPolicy` attribute of the domain resource or both as necessary. For the Administration Server, it updates the value of the `spec.adminServer.serverStartPolicy` attribute of the domain resource. For non-clustered Managed Servers, it updates the `spec.managedServers[].serverStartPolicy` attribute of the domain resource. The script provides an option to keep the `spec.clusters[].replicas` value constant for clustered servers. See the script `usage` information by using the `-h` option. + +Use the following command to start the server either by increasing the replica count or by updating the server start policy: +``` +$ startServer.sh -d domain1 -n weblogic-domain-1 -s managed-server1 +[INFO] Updating replica count for cluster 'cluster-1' to 1. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully updated replica count for cluster 'cluster-1' to 1. +``` + +Use the following command to start the server without increasing the replica count: +``` +$ startServer.sh -d domain1 -n weblogic-domain-1 -s managed-server2 -k +[INFO] Patching start policy for 'managed-server2' to 'ALWAYS'. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully patched server 'managed-server2' with 'ALWAYS' start policy. +``` + +The `stopServer.sh` script shuts down a running WebLogic Server in a domain. For clustered Managed Servers, either it decreases the `spec.clusters[].replicas` value for the Managed Server's cluster by `1` or updates the `spec.managedServers[].serverStartPolicy` attribute of the domain resource or both as necessary. For the Administration Server, it updates the value of the `spec.adminServer.serverStartPolicy` attribute of the domain resource. For non-clustered Managed Servers, it updates the `spec.managedServers[].serverStartPolicy` attribute of the domain resource. The script provides an option to keep the `spec.clusters[].replicas` value constant for clustered servers. See the script `usage` information by using the `-h` option. + +Use the following command to stop the server either by decreasing the replica count or by updating the server start policy: +``` +$ stopServer.sh -d domain1 -n weblogic-domain-1 -s managed-server1 +[INFO] Updating replica count for cluster cluster-1 to 0. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully updated replica count for cluster 'cluster-1' to 0. +``` + +Use the following command to stop the server without decreasing the replica count: +``` +$ stopServer.sh -d domain1 -n weblogic-domain-1 -s managed-server2 -k +[INFO] Unsetting the current start policy 'ALWAYS' for 'managed-server2'. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully unset policy 'ALWAYS'. +``` + +### Scripts to start and stop a cluster + +The `startCluster.sh` script starts a cluster by patching the `spec.clusters[].serverStartPolicy` attribute of the domain resource to `IF_NEEDED`. The operator will start the WebLogic Server instance Pods that are part of the cluster after the `serverStartPolicy` attribute is updated to `IF_NEEDED`. See the script `usage` information by using the `-h` option. +``` +$ startCluster.sh -d domain1 -n weblogic-domain-1 -c cluster-1 +[INFO]Patching start policy of cluster 'cluster-1' from 'NEVER' to 'IF_NEEDED'. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully patched cluster 'cluster-1' with 'IF_NEEDED' start policy!. +``` +The `stopCluster.sh` script shuts down a cluster by patching the `spec.clusters[].serverStartPolicy` attribute of the domain resource to `NEVER`. The operator will shut down the WebLogic Server instance Pods that are part of the cluster after the `serverStartPolicy` attribute is updated to `NEVER`. See the script `usage` information by using the `-h` option. +``` +$ stopCluster.sh -d domain1 -n weblogic-domain-1 -c cluster-1 +[INFO] Patching start policy of cluster 'cluster-1' from 'IF_NEEDED' to 'NEVER'. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully patched cluster 'cluster-1' with 'NEVER' start policy! +``` +### Scripts to start and stop a domain +The `startDomain.sh` script starts a deployed domain by patching the `spec.serverStartPolicy` attribute of the domain resource to `IF_NEEDED`. The operator will start the WebLogic Server instance Pods that are part of the domain after the `spec.serverStartPolicy` attribute of the domain resource is updated to `IF_NEEDED`. See the script `usage` information by using the `-h` option. +``` +$ startDomain.sh -d domain1 -n weblogic-domain-1 +[INFO] Patching domain 'domain1' from serverStartPolicy='NEVER' to 'IF_NEEDED'. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully patched domain 'domain1' in namespace 'weblogic-domain-1' with 'IF_NEEDED' start policy! +``` + +The `stopDomain.sh` script shuts down a domain by patching the `spec.serverStartPolicy` attribute of the domain resource to `NEVER`. The operator will shut down the WebLogic Server instance Pods that are part of the domain after the `spec.serverStartPolicy` attribute is updated to `NEVER`. See the script `usage` information by using the `-h` option. +``` +$ stopDomain.sh -d domain1 -n weblogic-domain-1 +[INFO] Patching domain 'domain1' in namespace 'weblogic-domain-1' from serverStartPolicy='IF_NEEDED' to 'NEVER'. +domain.weblogic.oracle/domain1 patched +[INFO] Successfully patched domain 'domain1' in namespace 'weblogic-domain-1' with 'NEVER' start policy! +``` + +### Script to scale a WebLogic cluster + +The `scaleCluster.sh` script scales a WebLogic cluster by patching the `spec.clusters[].replicas` attribute of the domain resource to the specified value. The operator will perform the scaling operation for the WebLogic cluster based on the specified value of the `replicas` attribute after its value is updated. See the script `usage` information by using the `-h` option. +``` +$ scaleCluster.sh -d domain1 -n weblogic-domain-1 -c cluster-1 -r 3 +[2021-02-26T19:04:14.335000Z][INFO] Patching replicas for cluster 'cluster-1' to '3'. +domain.weblogic.oracle/domain1 patched +[2021-02-26T19:04:14.466000Z][INFO] Successfully patched replicas for cluster 'cluster-1'! +``` + +### Script to view the status of a WebLogic cluster + +The `clusterStatus.sh` script can be used to view the status of a WebLogic cluster in the WebLogic domain managed by the operator. The WebLogic Cluster Status contains information about the minimum, maximum, goal, current, and ready replica count for a WebLogic cluster. This script displays a table containing the status for WebLogic clusters in one or more domains across one or more namespaces. See the script `usage` information by using the `-h` option. + +Use the following command to view the status of all WebLogic clusters in all domains across all namespaces. +```shell +$ clusterStatus.sh + +WebLogic Cluster Status -n "" -d "" -c "": + +namespace domain cluster min max goal current ready +--------- ------ ------- --- --- ---- ------- ----- +ns-kvmt mii-domain1 cluster-1 1 5 5 5 5 +weblogic-domain-1 domain1 cluster-1 0 4 2 2 2 +weblogic-domain-1 domain1 cluster-2 0 4 0 0 0 +``` + +Use the following command to view the status of all WebLogic clusters in 'domain1' in 'weblogic-domain-1' namespace. +``` +$ clusterStatus.sh -d domain1 -n weblogic-domain-1 + +WebLogic Cluster Status -n "weblogic-domain-1" -d "domain1" -c "": + +namespace domain cluster min max goal current ready +--------- ------ ------- --- --- ---- ------- ----- +weblogic-domain-1 domain1 cluster-1 0 4 2 2 2 +weblogic-domain-1 domain1 cluster-2 0 4 0 0 0 +``` + +### Scripts to initiate a rolling restart of a WebLogic domain or cluster + +The `rollDomain.sh` script can be used to initiate a rolling restart of the WebLogic Server Pods in a domain managed by the operator. Similarly, the `rollCluster.sh` script can be used to initiate a rolling restart of the WebLogic Server Pods belonging to a WebLogic cluster in a domain managed by the operator. + +The `rollDomain.sh` script updates the value of the `spec.restartVersion` attribute of the domain resource. Then, the operator will do a rolling restart of the Server Pods in the WebLogic domain after the value of the `spec.restartVersion` is updated. You can provide the new value for `spec.restartVersion` as a parameter to the script or the script will automatically generate a new value to trigger the rolling restart. See the script `usage` information by using the `-h` option. + +``` +$ rollDomain.sh -d domain1 -n weblogic-domain-1 +[2021-03-24T04:01:19.733000Z][INFO] Patching restartVersion for domain 'domain1' to '1'. +domain.weblogic.oracle/domain1 patched +[2021-03-24T04:01:19.850000Z][INFO] Successfully patched restartVersion for domain 'domain1'! +``` + +Use the following command to roll the Server Pods in a WebLogic domain with a specific `restartVersion`: +``` +$ rollDomain.sh -r v1 -d domain1 -n weblogic-domain-1 +[2021-03-24T13:43:47.586000Z][INFO] Patching restartVersion for domain 'domain1' to 'v1'. +domain.weblogic.oracle/domain1 patched +[2021-03-24T13:43:47.708000Z][INFO] Successfully patched restartVersion for domain 'domain1'! +``` + +The `rollCluster.sh` script updates the value of the `spec.clusters[].restartVersion` attribute of the domain resource. Then, the operator will do a rolling restart of the WebLogic cluster Server Pods after the value of the `spec.clusters[].restartVersion` is updated. You can provide the new value of the `restartVersion` as a parameter to the script or the script will automatically generate a new value to trigger the rolling restart. See the script `usage` information by using the `-h` option. + +``` +$ rollCluster.sh -c cluster-1 -d domain1 -n weblogic-domain-1 +[2021-03-24T04:03:27.521000Z][INFO] Patching restartVersion for cluster 'cluster-1' to '2'. +domain.weblogic.oracle/domain1 patched +[2021-03-24T04:03:27.669000Z][INFO] Successfully patched restartVersion for cluster 'cluster-1'! +``` + +Use the following command to roll the WebLogic Cluster Servers with a specific `restartVersion`: +``` +$ rollCluster.sh -r v2 -c cluster-1 -d domain1 -n weblogic-domain-1 +[2021-03-24T13:46:16.833000Z][INFO] Patching restartVersion for cluster 'cluster-1' to 'v2'. +domain.weblogic.oracle/domain1 patched +[2021-03-24T13:46:16.975000Z][INFO] Successfully patched restartVersion for cluster 'cluster-1'! +``` + +### Scripts to restart a WebLogic Server in a domain +The `restartServer.sh` script can be used to restart a WebLogic Server in a domain. This script restarts the Server by deleting the Server Pod for the WebLogic Server instance. +``` +$ restartServer.sh -s managed-server1 -d domain1 -n weblogic-domain-1 +[2021-03-24T22:20:22.498000Z][INFO] Initiating restart of 'managed-server1' by deleting server pod 'domain1-managed-server1'. +[2021-03-24T22:20:37.614000Z][INFO] Server restart succeeded ! +``` + +### Scripts to explicitly initiate introspection of a WebLogic domain + +The `introspectDomain.sh` script can be used to rerun a WebLogic domain's introspect job by explicitly initiating the introspection. This script updates the value of the `spec.introspectVersion` attribute of the domain resource. The resulting behavior depends on your domain home source type and other factors, see [Initiating introspection](https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/domain-lifecycle/introspection/#initiating-introspection) for details. You can provide the new value of the `introspectVersion` as a parameter to the script or the script will automatically generate a new value to trigger the introspection. See the script `usage` information by using the `-h` option. + +Use the following command to rerun a domain's introspect job with the `introspectVersion` value generated by the script. +``` +$ introspectDomain.sh -d domain1 -n weblogic-domain-1 +[2021-03-24T21:37:55.989000Z][INFO] Patching introspectVersion for domain 'domain1' to '1'. +domain.weblogic.oracle/domain1 patched +[2021-03-24T21:37:56.110000Z][INFO] Successfully patched introspectVersion for domain 'domain1'! +``` + +Use the following command to rerun a domain's introspect job with a specific `introspectVersion` value. +``` +$ introspectDomain.sh -i v1 -d domain1 -n weblogic-domain-1 +[2021-03-24T21:38:34.369000Z][INFO] Patching introspectVersion for domain 'domain1' to 'v1'. +domain.weblogic.oracle/domain1 patched +[2021-03-24T21:38:34.488000Z][INFO] Successfully patched introspectVersion for domain 'domain1'! +``` + +### Watching the Pods after executing life cycle scripts + +After executing the lifecycle scripts described above for a domain or a cluster or a Server, you can manually run the `kubectl -n MYNS get pods --watch=true --show-labels` command to watch the effect of running the scripts and monitor the status and labels of various Pods. You will need to do 'Ctrl-C' to stop watching the Pods and exit. diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/clusterStatus.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/clusterStatus.sh new file mode 100644 index 000000000..8bfeb45f3 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/clusterStatus.sh @@ -0,0 +1,130 @@ +# !/bin/sh +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +set -eu +set -o pipefail + +function usage() { +cat< ${kubernetesCli} patch domain ${domainUid} \ + -n ${domainNamespace} --type=merge --patch \"${patchJson}\"" + fi + ${kubernetesCli} patch domain ${domainUid} -n ${domainNamespace} --type=merge --patch "${patchJson}" +} + +# timestamp +# purpose: echo timestamp in the form yyyy-mm-ddThh:mm:ss.nnnnnnZ +# example: 2018-10-01T14:00:00.000001Z +function timestamp() { + local timestamp="`date --utc '+%Y-%m-%dT%H:%M:%S.%NZ' 2>&1`" + if [ ! "${timestamp/illegal/xyz}" = "${timestamp}" ]; then + # old shell versions don't support %N or --utc + timestamp="`date -u '+%Y-%m-%dT%H:%M:%S.000000Z' 2>&1`" + fi + echo "${timestamp}" +} + +# +# Function to note that a validate error has occurred +# +function validationError { + printError $* + validateErrors=true +} + +# +# Function to cause the script to fail if there were any validation errors +# +function failIfValidationErrors { + if [ "$validateErrors" = true ]; then + printError 'The errors listed above must be resolved before the script can continue. Please see usage information below.' + usage 1 + fi +} + +# +# Function to lowercase a value and make it a legal DNS1123 name +# $1 - value to convert to DNS legal name +# $2 - return value containing DNS legal name. +function toDNS1123Legal { + local name=$1 + local __result=$2 + local val=`echo "${name}" | tr "[:upper:]" "[:lower:]"` + val=${val//"_"/"-"} + eval $__result="'$val'" +} + diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/introspectDomain.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/introspectDomain.sh new file mode 100644 index 000000000..120eccec7 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/introspectDomain.sh @@ -0,0 +1,105 @@ +# !/bin/sh +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; + +function usage() { + + cat << EOF + + This script initiates introspection of a WebLogic domain by updating + the value of 'spec.introspectVersion' attribute of the domain resource. + + Usage: + + $(basename $0) [-n mynamespace] [-d mydomainuid] [-i introspectVersion] [-m kubecli] + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -i : Introspect version. If this parameter is not provided, + then the script will generate the 'introspectVersion' by + incrementing the existing value. If the 'spec.introspectVersion' + doesn't exist or its value is non-numeric, then the script + will set the 'spec.introspectVersion' value to '1'. + + -m : Kubernetes command line interface. Default is 'kubectl' + if KUBERNETES_CLI env variable is not set. Otherwise + the default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false +patchJson="" +introspectVersion="" + +while getopts "vc:n:m:d:i:h" opt; do + case $opt in + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + i) introspectVersion="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +set -eu + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +# if the introspectVersion is not provided, generate the value of introspectVersion +if [ -z "${introspectVersion}" ]; then + generateDomainIntrospectVersion "${domainJson}" introspectVersion +fi + +printInfo "Patching introspectVersion for domain '${domainUid}' to '${introspectVersion}'." +createPatchJsonToUpdateDomainIntrospectVersion "${introspectVersion}" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched introspectVersion for domain '${domainUid}'!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/restartServer.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/restartServer.sh new file mode 100644 index 000000000..0c7405aba --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/restartServer.sh @@ -0,0 +1,106 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; +set -eu + +function usage() { + + cat << EOF + + This script restarts a running WebLogic server in a domain by deleting the server pod. + + Usage: + + $(basename $0) -s myserver [-n mynamespace] [-d mydomainuid] [-m kubecli] + + -s : The WebLogic server name (not the pod name). + This parameter is required. + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -m : Kubernetes command line interface. Default is 'kubectl' + if KUBERNETES_CLI env variable is not set. Otherwise the + default is the value of KUBERNETES_CLI env variable. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +serverName="" +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +podName="" +legalDNSPodName="" + +while getopts "s:m:n:d:h" opt; do + case $opt in + s) serverName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + # Validate that server name parameter is specified. + if [ -z "${serverName}" ]; then + validationError "Please specify the server name using '-s' parameter e.g. '-s managed-server1'." + fi + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +# Validate that specified server is either part of a cluster or is an independent managed server +validateServerAndFindCluster "${domainUid}" "${domainNamespace}" "${serverName}" isValidServer clusterName isAdminServer +if [ "${isValidServer}" != 'true' ]; then + printError "Server ${serverName} is not part of any cluster and it's not an independent managed server. Please make sure that server name specified is correct." + exit 1 +fi + +podName=${domainUid}-${serverName} +toDNS1123Legal ${podName} legalDNSPodName +printInfo "Initiating restart of '${serverName}' by deleting server pod '${legalDNSPodName}'." +result=$(${kubernetesCli} -n ${domainNamespace} delete pod ${legalDNSPodName} --ignore-not-found) +if [ -z "${result}" ]; then + printError "Server '${serverName}' is not running." +else + printInfo "Server restart succeeded !" +fi diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/rollCluster.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/rollCluster.sh new file mode 100644 index 000000000..858e41706 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/rollCluster.sh @@ -0,0 +1,123 @@ +# !/bin/sh +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; + +function usage() { + + cat << EOF + + This script initiates a rolling restart of the WebLogic cluster server pods in a domain by updating + the value of the 'spec.clusters[].restartVersion' attribute of the domain resource. + + Usage: + + $(basename $0) -c mycluster [-n mynamespace] [-d mydomainuid] [-r restartVersion] [-m kubecli] + + -c : Cluster name (required parameter). + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -r : Restart version. If this parameter is not provided, + then the script will generate the 'restartVersion' + value of the cluster by incrementing the existing + value. If the 'restartVersion' value doesn't exist + for the cluster then it will use the incremented value of + domain 'restartVersion'. If the domain 'restartVersion' also + doesn't exist or effective value is non-numeric, then + the script will set the 'restartVersion' value to '1'. + + -m : Kubernetes command line interface. Default is 'kubectl' + if KUBERNETES_CLI env variable is not set. Otherwise + the default is the value of the KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false +patchJson="" +restartVersion="" + +while getopts "vc:n:m:d:r:h" opt; do + case $opt in + c) clusterName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + r) restartVersion="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +set -eu + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + if [ -z "${clusterName}" ]; then + validationError "Please specify cluster name using '-c' parameter e.g. '-c cluster-1'." + fi + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +isValidCluster="" +validateClusterName "${domainUid}" "${domainNamespace}" "${clusterName}" isValidCluster +if [ "${isValidCluster}" != 'true' ]; then + printError "cluster ${clusterName} is not part of domain ${domainUid} in namespace ${domainNamespace}. Please make sure that cluster name is correct." + exit 1 +fi + +# if the restartVersion is not provided, generate the value of restartVersion +if [ -z "${restartVersion}" ]; then + generateClusterRestartVersion "${domainJson}" "${clusterName}" restartVersion +fi + +printInfo "Patching restartVersion for cluster '${clusterName}' to '${restartVersion}'." +createPatchJsonToUpdateClusterRestartVersion "${domainJson}" "${clusterName}" "${restartVersion}" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched restartVersion for cluster '${clusterName}'!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/rollDomain.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/rollDomain.sh new file mode 100644 index 000000000..4c821d8c8 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/rollDomain.sh @@ -0,0 +1,105 @@ +# !/bin/sh +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; + +function usage() { + + cat << EOF + + This script initiates a rolling restart of pods in a WebLogic domain by updating + the value of the 'spec.restartVersion' attribute of the domain resource. + + Usage: + + $(basename $0) [-n mynamespace] [-d mydomainuid] [-r restartVersion] [-m kubecli] + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -r : Restart version. If this parameter is not provided, + then the script will generate the 'restartVersion' by + incrementing the existing value. If the 'spec.restartVersion' + doesn't exist or its value is non-numeric, then the script + will set the 'spec.restartVersion' value to '1'. + + -m : Kubernetes command line interface. Default is 'kubectl' + if KUBERNETES_CLI env variable is not set. Otherwise + the default is the value of the KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false +patchJson="" +restartVersion="" + +while getopts "vc:n:m:d:r:h" opt; do + case $opt in + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + r) restartVersion="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +set -eu + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +# if the restartVersion is not provided, generate the value of restartVersion +if [ -z "${restartVersion}" ]; then + generateDomainRestartVersion "${domainJson}" restartVersion +fi + +printInfo "Patching restartVersion for domain '${domainUid}' to '${restartVersion}'." +createPatchJsonToUpdateDomainRestartVersion "${restartVersion}" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched restartVersion for domain '${domainUid}'!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/scaleCluster.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/scaleCluster.sh new file mode 100644 index 000000000..947dd871c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/scaleCluster.sh @@ -0,0 +1,122 @@ +# !/bin/sh +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; + +function usage() { + + cat << EOF + + This script scales a WebLogic cluster in a domain by patching the + 'spec.clusters[].replicas' attribute of the domain + resource. This change will cause the operator to perform a scaling + operation for the WebLogic cluster based on the value of replica count. + + Usage: + + $(basename $0) -c mycluster -r replicas [-n mynamespace] [-d mydomainuid] [-m kubecli] + + -c : Cluster name parameter is required. + + -r : Replica count, parameter is required. + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false +patchJson="" +replicas="" + +while getopts "vc:n:m:d:r:h" opt; do + case $opt in + c) clusterName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + r) replicas="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +set -eu + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + if [ -z "${clusterName}" ]; then + validationError "Please specify cluster name using '-c' parameter e.g. '-c cluster-1'." + fi + + if [ -z "${replicas}" ]; then + validationError "Please specify replica count using '-r' parameter e.g. '-r 3'." + fi + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +isValidCluster="" +validateClusterName "${domainUid}" "${domainNamespace}" "${clusterName}" isValidCluster +if [ "${isValidCluster}" != 'true' ]; then + printError "cluster ${clusterName} is not part of domain ${domainUid} in namespace ${domainNamespace}. Please make sure that cluster name is correct." + exit 1 +fi + +isReplicasInAllowedRange "${domainJson}" "${clusterName}" "${replicas}" replicasInAllowedRange range +if [ "${replicasInAllowedRange}" == 'false' ]; then + printError "Replicas value is not in the allowed range of ${range}. Exiting." + exit 1 +fi + +printInfo "Patching replicas for cluster '${clusterName}' to '${replicas}'." +createPatchJsonToUpdateReplicas "${domainJson}" "${clusterName}" "${replicas}" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched replicas for cluster '${clusterName}'!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/startCluster.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/startCluster.sh new file mode 100644 index 000000000..5c8bf034c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/startCluster.sh @@ -0,0 +1,129 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; + +function usage() { + + cat << EOF + + This script starts a WebLogic cluster in a domain by patching + 'spec.clusters[].serverStartPolicy' attribute of the domain + resource to 'IF_NEEDED'. This change will cause the operator to initiate + startup of cluster's WebLogic server instance pods if the pods are not + already running and the spec.replicas or + 'spec.clusters[].serverStartPolicy' is set higher than zero. + + Usage: + + $(basename $0) -c mycluster [-n mynamespace] [-d mydomainuid] [-m kubecli] + + -c : Cluster name (required parameter). + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +set -eu + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false +patchJson="" + +while getopts "vc:n:m:d:h" opt; do + case $opt in + c) clusterName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + if [ -z "${clusterName}" ]; then + validationError "Please specify cluster name using '-c' parameter e.g. '-c cluster-1'." + fi + + failIfValidationErrors + +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +isValidCluster="" +validateClusterName "${domainUid}" "${domainNamespace}" "${clusterName}" isValidCluster +if [ "${isValidCluster}" != 'true' ]; then + printError "cluster ${clusterName} is not part of domain ${domainUid} in namespace ${domainNamespace}. Please make sure that cluster name is correct." + exit 1 +fi + +getDomainPolicy "${domainJson}" domainStartPolicy +# Fail if effective start policy of domain is NEVER or ADMIN_ONLY +if [[ "${domainStartPolicy}" == 'NEVER' || "${domainStartPolicy}" == 'ADMIN_ONLY' ]]; then + printError "Cannot start cluster '${clusterName}', the domain is configured with a 'spec.serverStartPolicy' attribute on the domain resource of 'NEVER' or 'ADMIN_ONLY'." + exit 1 +fi + +# Get server start policy for this cluster +getClusterPolicy "${domainJson}" "${clusterName}" startPolicy +if [ -z "${startPolicy}" ]; then + startPolicy=${domainStartPolicy} +fi + +if [ "${startPolicy}" == 'IF_NEEDED' ]; then + printInfo "No changes needed, exiting. The cluster '${clusterName}' is already started or starting. The effective value of 'spec.clusters[?(clusterName=\"${clusterName}\"].serverStartPolicy' attribute on the domain resource is 'IF_NEEDED'." + exit 0 +fi + +# Set policy value to IF_NEEDED +printInfo "Patching start policy of cluster '${clusterName}' from '${startPolicy}' to 'IF_NEEDED'." +createPatchJsonToUpdateClusterPolicy "${domainJson}" "${clusterName}" "IF_NEEDED" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched cluster '${clusterName}' with 'IF_NEEDED' start policy!." diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/startDomain.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/startDomain.sh new file mode 100644 index 000000000..fea9cbbe5 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/startDomain.sh @@ -0,0 +1,97 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh + +function usage() { + + cat << EOF + + This script starts a deployed WebLogic domain by patching 'spec.serverStartPolicy' + attribute of the domain resource to 'IF_NEEDED'. This change will cause the operator + to initiate startup of domain's WebLogic server instance pods if the pods are not + already running. + + Usage: + + $(basename $0) [-n mynamespace] [-d mydomainuid] [-m kubecli] + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false + +while getopts "vn:d:m:h" opt; do + case $opt in + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + + +set -eu +set -o pipefail + +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) + +if [ -z "${domainJson}" ]; then + printError "Domain resource for domain '${domainUid}' not found in namespace '${domainNamespace}'. Exiting." + exit 1 +fi + +getDomainPolicy "${domainJson}" serverStartPolicy + +if [ "${serverStartPolicy}" == 'IF_NEEDED' ]; then + printInfo "No changes needed, exiting. The domain '${domainUid}' is already started or starting. The effective value of 'spec.serverStartPolicy' attribute on the domain resource is 'IF_NEEDED'." + exit 0 +fi + +printInfo "Patching domain '${domainUid}' from serverStartPolicy='${serverStartPolicy}' to 'IF_NEEDED'." + +createPatchJsonToUpdateDomainPolicy "IF_NEEDED" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched domain '${domainUid}' in namespace '${domainNamespace}' with 'IF_NEEDED' start policy!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/startServer.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/startServer.sh new file mode 100644 index 000000000..37b120d71 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/startServer.sh @@ -0,0 +1,242 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +# This script starts a WebLogic managed server in a domain. +# Internal code notes :- +# - If server start policy is ALWAYS or policy is IF_NEEDED and the server is selected +# to start based on the replica count, it means that server is already started or is +# in the process of starting. In this case, script exits without making any changes. +# +# - If start policy of servers parent cluster or domain is 'NEVER', script +# fails as server can't be started. +# +# - If server is part of a cluster and keep_replica_constant option is false (the default) +# and the effective start policy of the server is IF_NEEDED and increasing replica count +# will naturally start the server, the script increases the replica count. +# +# - If server is part of a cluster and keep_replica_constant option is false (the default) +# and unsetting policy and increasing the replica count will start this server, script +# unsets the policy and increases replica count. For e.g. if replica count is 1 and +# start policy of server2 is NEVER, unsetting policy and increasing replica count will +# start server2. +# +# - If option to keep replica count constant ('-k') is selected and unsetting start policy +# will naturally start the server, script will unset the policy. For e.g. if replica count +# is 2 and start policy of server2 is NEVER, unsetting policy will start server2. +# +# - If above conditions are not true, it implies that either start policy is NEVER or policy +# is IF_NEEDED but server is not next in the order to start. In this case, script sets start +# policy to ALWAYS. For e.g. replica count is 3 and server10 needs to start. The script also +# increments the replica count by default. If option to keep replica count constant ('-k') +# is selected, it only sets the start policy to ALWAYS. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; +set -eu + +function usage() { + + cat << EOF + + This script starts a WebLogic server in a domain. For the managed servers, it either + increases the value of 'spec.clusters[].replicas' by '1' or updates the + 'spec.managedServers[].serverStartPolicy' attribute of the domain + resource or both as necessary for starting the server. For the administration server, it + updates the value of 'spec.adminServer.serverStartPolicy' attribute of the domain resource. + The 'spec.clusters[].replicas' value can be kept constant by using '-k' option. + Please see README.md for more details. + + Usage: + + $(basename $0) -s myserver [-n mynamespace] [-d mydomainuid] [-k] [-m kubecli] [-v] + + -s : The WebLogic server name (not the pod name). + This parameter is required. + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -k : Keep replica count constant for the clustered servers. The default behavior + is to increment the replica count for the clustered servers. This parameter + is ignored for the administration and non-clustered managed servers. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +serverName="" +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +keepReplicaConstant=false +verboseMode=false +withReplicas="CONSTANT" +withPolicy="CONSTANT" +managedServerPolicy="" +effectivePolicy="" +isValidServer="" +patchJson="" +serverStarted="" +startsByPolicyUnset="" +startsByReplicaIncreaseAndPolicyUnset="" +isAdminServer=false + +while getopts "vkd:n:m:s:h" opt; do + case $opt in + s) serverName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + k) keepReplicaConstant=true; + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + # Validate the required files exist + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + # Validate that server name parameter is specified. + if [ -z "${serverName}" ]; then + validationError "Please specify a server name using '-s' parameter e.g. '-s managed-server1'." + fi + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +# Validate that specified server is either part of a cluster or is an independent managed server +validateServerAndFindCluster "${domainUid}" "${domainNamespace}" "${serverName}" isValidServer clusterName isAdminServer +if [ "${isValidServer}" != 'true' ]; then + printError "Server ${serverName} is not part of any cluster and it's not an independent managed server. Please make sure that server name specified is correct." + exit 1 +fi + +getClusterPolicy "${domainJson}" "${clusterName}" clusterPolicy +if [ "${clusterPolicy}" == 'NEVER' ]; then + printError "Cannot start server '${serverName}', the server's parent cluster '.spec.clusters[?(clusterName=\"${clusterName}\"].serverStartPolicy' in the domain resource is set to 'NEVER'." + exit 1 +fi + +getDomainPolicy "${domainJson}" domainPolicy +if [ "${domainPolicy}" == 'NEVER' ] || [[ "${domainPolicy}" == 'ADMIN_ONLY' && "${isAdminServer}" != 'true' ]]; then + printError "Cannot start server '${serverName}', the .spec.serverStartPolicy in the domain resource is set to 'NEVER' or 'ADMIN_ONLY'." + exit 1 +fi + +getEffectivePolicy "${domainJson}" "${serverName}" "${clusterName}" effectivePolicy +if [ "${isAdminServer}" == 'true' ]; then + getEffectiveAdminPolicy "${domainJson}" effectivePolicy + if [[ "${effectivePolicy}" == "IF_NEEDED" || "${effectivePolicy}" == "ALWAYS" ]]; then + printInfo "No changes needed, exiting. Server should be already starting or started because effective sever start policy is '${effectivePolicy}'." + exit 0 + fi +fi + +if [ -n "${clusterName}" ]; then + # Server is part of a cluster, check currently started servers + checkStartedServers "${domainJson}" "${serverName}" "${clusterName}" "${withReplicas}" "${withPolicy}" serverStarted + if [[ ${effectivePolicy} == "IF_NEEDED" && ${serverStarted} == "true" ]]; then + printInfo "No changes needed, exiting. The server should be already started or it's in the process of starting. The start policy for server ${serverName} is ${effectivePolicy} and server is chosen to be started based on current replica count." + exit 0 + elif [[ "${effectivePolicy}" == "ALWAYS" && ${serverStarted} == "true" ]]; then + printInfo "No changes needed, exiting. The server should be already started or it's in the process of starting. The start policy for server ${serverName} is ${effectivePolicy}." + exit 0 + fi +else + # Server is an independent managed server. + if [[ "${effectivePolicy}" == "ALWAYS" || "${effectivePolicy}" == "IF_NEEDED" ]]; then + printInfo "No changes needed, exiting. The server should be already started or it's in the process of starting. The start policy for server ${serverName} is ${effectivePolicy}." + exit 0 + fi +fi + +getServerPolicy "${domainJson}" "${serverName}" managedServerPolicy +createServerStartPolicyPatch "${domainJson}" "${serverName}" "ALWAYS" alwaysStartPolicyPatch + +# if server is part of a cluster and replica count will increase +if [[ -n ${clusterName} && "${keepReplicaConstant}" != 'true' ]]; then + #check if server starts by increasing replicas and unsetting policy + withReplicas="INCREASED" + withPolicy="UNSET" + checkStartedServers "${domainJson}" "${serverName}" "${clusterName}" "${withReplicas}" "${withPolicy}" startsByReplicaIncreaseAndPolicyUnset + createReplicaPatch "${domainJson}" "${clusterName}" "INCREMENT" incrementReplicaPatch replicaCount + if [[ -n ${managedServerPolicy} && ${startsByReplicaIncreaseAndPolicyUnset} == "true" ]]; then + # Server starts by increasing replicas and policy unset, increment and unset + printInfo "Unsetting the current start policy '${managedServerPolicy}' for '${serverName}' and incrementing replica count ${replicaCount}." + createPatchJsonToUnsetPolicyAndUpdateReplica "${domainJson}" "${serverName}" "${incrementReplicaPatch}" patchJson + elif [[ -z ${managedServerPolicy} && ${startsByReplicaIncreaseAndPolicyUnset} == "true" ]]; then + # Start policy is not set, server starts by increasing replicas based on effective policy, increment replicas + printInfo "Updating replica count for cluster '${clusterName}' to ${replicaCount}." + createPatchJsonToUpdateReplica "${incrementReplicaPatch}" patchJson + else + # Patch server policy to always and increment replicas + printInfo "Patching start policy of server '${serverName}' from '${effectivePolicy}' to 'ALWAYS' and \ +incrementing replica count for cluster '${clusterName}' to ${replicaCount}." + createPatchJsonToUpdateReplicaAndPolicy "${incrementReplicaPatch}" "${alwaysStartPolicyPatch}" patchJson + fi +elif [[ -n ${clusterName} && "${keepReplicaConstant}" == 'true' ]]; then + # Replica count needs to stay constant, check if server starts by unsetting policy + withReplicas="CONSTANT" + withPolicy="UNSET" + checkStartedServers "${domainJson}" "${serverName}" "${clusterName}" "${withReplicas}" "${withPolicy}" startsByPolicyUnset + if [[ "${effectivePolicy}" == "NEVER" && ${startsByPolicyUnset} == "true" ]]; then + # Server starts by unsetting policy, unset policy + printInfo "Unsetting the current start policy '${effectivePolicy}' for '${serverName}'." + createPatchJsonToUnsetPolicy "${domainJson}" "${serverName}" patchJson + else + # Patch server policy to always + printInfo "Patching start policy for '${serverName}' to 'ALWAYS'." + createPatchJsonToUpdatePolicy "${alwaysStartPolicyPatch}" patchJson + fi +elif [ "${isAdminServer}" == 'true' ]; then + printInfo "Patching start policy of '${serverName}' from '${effectivePolicy}' to 'IF_NEEDED'." + createPatchJsonToUpdateAdminPolicy "${domainJson}" "IF_NEEDED" patchJson +else + # Server is an independent managed server + printInfo "Unsetting the current start policy '${effectivePolicy}' for '${serverName}'." + createPatchJsonToUnsetPolicy "${domainJson}" "${serverName}" patchJson +fi + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Patch command succeeded !" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopCluster.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopCluster.sh new file mode 100644 index 000000000..6e0410932 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopCluster.sh @@ -0,0 +1,119 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; + +function usage() { + + cat << EOF + + This script stops a WebLogic cluster in a domain by patching + 'spec.clusters[].serverStartPolicy' attribute of the domain + resource to 'NEVER'. This change will cause the operator to initiate shutdown + of cluster's WebLogic server instance pods if the pods are running. + + Usage: + + $(basename $0) -c mycluster [-n mynamespace] [-d mydomainuid] [-m kubecli] + + -c : Cluster name (required parameter). + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false +patchJson="" + +while getopts "vc:n:m:d:h" opt; do + case $opt in + c) clusterName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +set -eu + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + if [ -z "${clusterName}" ]; then + validationError "Please specify cluster name using '-c' parameter e.g. '-c cluster-1'." + fi + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +isValidCluster="" +validateClusterName "${domainUid}" "${domainNamespace}" "${clusterName}" isValidCluster +if [ "${isValidCluster}" != 'true' ]; then + printError "cluster ${clusterName} is not part of domain ${domainUid} in namespace ${domainNamespace}. Please make sure that cluster name is correct." + exit 1 +fi + +# Get server start policy for this server +getClusterPolicy "${domainJson}" "${clusterName}" startPolicy +if [ -z "${startPolicy}" ]; then + getDomainPolicy "${domainJson}" startPolicy +fi + +if [[ "${startPolicy}" == 'NEVER' || "${startPolicy}" == 'ADMIN_ONLY' ]]; then + printInfo "No changes needed, exiting. The cluster '${clusterName}' is already stopped or stopping. The effective value of spec.clusters[?(clusterName="${clusterName}"].serverStartPolicy attribute on the domain resource is 'NEVER' or 'ADMIN_ONLY'." + exit 0 +fi + +# Set policy value to NEVER +printInfo "Patching start policy of cluster '${clusterName}' from '${startPolicy}' to 'NEVER'." +createPatchJsonToUpdateClusterPolicy "${domainJson}" "${clusterName}" "NEVER" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched cluster '${clusterName}' with 'NEVER' start policy!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopDomain.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopDomain.sh new file mode 100644 index 000000000..d62f6b280 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopDomain.sh @@ -0,0 +1,95 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh + +function usage() { + + cat << EOF + + This script stops a deployed WebLogic domain by patching + 'spec.serverStartPolicy' attribute of domain resource to 'NEVER'. + This change will cause the operator to initiate shutdown of the + domain's WebLogic server instance pods if the pods are running. + + Usage: + + $(basename $0) [-n mynamespace] [-d mydomainuid] [-m kubecli] + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +verboseMode=false + +while getopts "vn:d:m:h" opt; do + case $opt in + n) domainNamespace="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +set -eu +set -o pipefail + +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) + +if [ -z "${domainJson}" ]; then + printError "Domain resource for domain '${domainUid}' not found in namespace '${domainNamespace}'. Exiting." + exit 1 +fi + +getDomainPolicy "${domainJson}" serverStartPolicy + +if [ "${serverStartPolicy}" == 'NEVER' ]; then + printInfo "No changes needed, exiting. The domain '${domainUid}' is already stopped or stopping. The value of 'spec.serverStartPolicy' attribute on the domain resource is 'NEVER'." + exit 0 +fi + +printInfo "Patching domain '${domainUid}' in namespace '${domainNamespace}' from serverStartPolicy='${serverStartPolicy}' to 'NEVER'." + +createPatchJsonToUpdateDomainPolicy "NEVER" patchJson + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Successfully patched domain '${domainUid}' in namespace '${domainNamespace}' with 'NEVER' start policy!" diff --git a/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopServer.sh b/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopServer.sh new file mode 100644 index 000000000..ec35b4d97 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/domain-lifecycle/stopServer.sh @@ -0,0 +1,248 @@ +# !/bin/sh +# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +# This script stops a WebLogic managed server in a domain. +# Internal code notes :- +# - If server start policy is NEVER or policy is IF_NEEDED and the server is not +# selected to start based on the replica count, it means that server is already +# stopped or is in the process of stopping. In this case, script exits without +# making any changes. +# +# - If server is part of a cluster and keep_replica_constant option is false (the default) +# and the effective start policy of the server is IF_NEEDED and decreasing replica count +# will naturally stop the server, the script decreases the replica count. +# +# - If server is part of a cluster and keep_replica_constant option is false (the default) +# and unsetting policy and decreasing the replica count will stop the server, script +# unsets the policy and decreases replica count. For e.g. if replica count is 2 and +# start policy of server2 is ALWAYS, unsetting policy and decreasing replica count will +# stop server2. +# +# - If option to keep replica count constant ('-k') is selected and unsetting start policy +# will naturally stop the server, script will unset the policy. For e.g. if replica count +# is 1 and start policy of server2 is ALWAYS, unsetting policy will stop server2. +# +# - If above conditions are not true, it implies that server policy is IF_NEEDED and server +# is selected to start. In this case, script sets start policy to NEVER. For e.g. replica +# count is 2 and server1 needs to be stopped. The script also decrements the replica count +# by default. If option to keep replica count constant ('-k') is selected, it only sets the +# start policy to NEVER. +# + +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/helper.sh +if [ "${debug}" == "true" ]; then set -x; fi; +set -eu + +function usage() { + + cat << EOF + + This script stops a running WebLogic server in a domain. For managed servers, it either + decreases the value of 'spec.clusters[].replicas' or updates the + 'spec.managedServers[].serverStartPolicy' attribute of the domain + resource or both as necessary to stop the server. For the administration server, it updates + the value of 'spec.adminServer.serverStartPolicy' attribute of the domain resource. The + 'spec.clusters[].replicas' value can be kept constant by using '-k' option. + Please see README.md for more details. + + Usage: + + $(basename $0) -s myserver [-n mynamespace] [-d mydomainuid] [-k] [-m kubecli] [-v] + + -s : The WebLogic server name (not the pod name). + This parameter is required. + + -d : Domain unique-id. Default is 'sample-domain1'. + + -n : Domain namespace. Default is 'sample-domain1-ns'. + + -k : Keep replica count constant for the clustered servers. The default behavior + is to decrement the replica count for the clustered servers. This parameter + is ignored for the administration and non-clustered managed servers. + + -m : Kubernetes command line interface. Default is 'kubectl' if KUBERNETES_CLI env + variable is not set. Otherwise default is the value of KUBERNETES_CLI env variable. + + -v : Enables verbose mode. Default is 'false'. + + -h : This help. + +EOF +exit $1 +} + +kubernetesCli=${KUBERNETES_CLI:-kubectl} +serverName="" +clusterName="" +domainUid="sample-domain1" +domainNamespace="sample-domain1-ns" +keepReplicaConstant=false +verboseMode=false +serverStartPolicy=NEVER +serverStarted="" +effectivePolicy="" +managedServerPolicy="" +stoppedWhenAlwaysPolicyReset="" +replicasEqualsMinReplicas="" +withReplicas="CONSTANT" +withPolicy="CONSTANT" +patchJson="" +isAdminServer=false + +while getopts "vks:m:n:d:h" opt; do + case $opt in + s) serverName="${OPTARG}" + ;; + n) domainNamespace="${OPTARG}" + ;; + m) kubernetesCli="${OPTARG}" + ;; + d) domainUid="${OPTARG}" + ;; + k) keepReplicaConstant=true; + ;; + v) verboseMode=true; + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +# +# Function to perform validations, read files and initialize workspace +# +function initialize { + + validateErrors=false + + validateKubernetesCliAvailable + validateJqAvailable + + # Validate that server name parameter is specified. + if [ -z "${serverName}" ]; then + validationError "Please specify the server name using '-s' parameter e.g. '-s managed-server1'." + fi + + failIfValidationErrors +} + +initialize + +# Get the domain in json format +domainJson=$(${kubernetesCli} get domain ${domainUid} -n ${domainNamespace} -o json --ignore-not-found) +if [ -z "${domainJson}" ]; then + printError "Unable to get domain resource for domain '${domainUid}' in namespace '${domainNamespace}'. Please make sure the 'domain_uid' and 'namespace' specified by the '-d' and '-n' arguments are correct. Exiting." + exit 1 +fi + +# Validate that specified server is either part of a cluster or is an independent managed server +validateServerAndFindCluster "${domainUid}" "${domainNamespace}" "${serverName}" isValidServer clusterName isAdminServer +if [ "${isValidServer}" != 'true' ]; then + printError "Server ${serverName} is not part of any cluster and it's not an independent managed server. Please make sure that server name specified is correct." + exit 1 +fi + +getEffectivePolicy "${domainJson}" "${serverName}" "${clusterName}" effectivePolicy +if [ "${isAdminServer}" == 'true' ]; then + getEffectiveAdminPolicy "${domainJson}" effectivePolicy + if [ "${effectivePolicy}" == "NEVER" ]; then + printInfo "No changes needed, exiting. Server should be already stopping or stopped because effective sever start policy is 'NEVER'." + exit 0 + fi +fi + +if [ -n "${clusterName}" ]; then + # Server is part of a cluster, check currently started servers + checkStartedServers "${domainJson}" "${serverName}" "${clusterName}" "${withReplicas}" "${withPolicy}" serverStarted + if [[ "${effectivePolicy}" == "NEVER" || "${effectivePolicy}" == "ADMIN_ONLY" || "${serverStarted}" != "true" ]]; then + printInfo "No changes needed, exiting. Server should be already stopping or stopped. This is either because of the sever start policy or server is chosen to be stopped based on current replica count." + exit 0 + fi +else + # Server is an independent managed server. + if [ "${effectivePolicy}" == "NEVER" ] || [[ "${effectivePolicy}" == "ADMIN_ONLY" && "${isAdminServer}" != 'true' ]]; then + printInfo "No changes needed, exiting. Server should be already stopping or stopped because effective sever start policy is 'NEVER' or 'ADMIN_ONLY'." + exit 0 + fi +fi + +if [[ -n "${clusterName}" && "${keepReplicaConstant}" == 'false' ]]; then + # check if replica count can decrease below current value + isReplicaCountEqualToMinReplicas "${domainJson}" "${clusterName}" replicasEqualsMinReplicas + if [ "${replicasEqualsMinReplicas}" == 'true' ]; then + printInfo "Not decreasing the replica count value: it is at its minimum. \ + (See 'domain.spec.allowReplicasBelowMinDynClusterSize' and \ + 'domain.status.clusters[].minimumReplicas' for details)." + keepReplicaConstant=true + fi +fi + +# Create server start policy patch with NEVER value +createServerStartPolicyPatch "${domainJson}" "${serverName}" "${serverStartPolicy}" neverStartPolicyPatch +getServerPolicy "${domainJson}" "${serverName}" managedServerPolicy +if [ -n "${managedServerPolicy}" ]; then + effectivePolicy=${managedServerPolicy} +fi +if [[ -n "${clusterName}" && "${effectivePolicy}" == "ALWAYS" ]]; then + # Server is part of a cluster and start policy is ALWAYS. + withReplicas="CONSTANT" + withPolicy="UNSET" + checkStartedServers "${domainJson}" "${serverName}" "${clusterName}" "${withReplicas}" "${withPolicy}" startedWhenAlwaysPolicyReset +fi + +if [[ -n "${clusterName}" && "${keepReplicaConstant}" != 'true' ]]; then + # server is part of a cluster and replica count will decrease + withReplicas="DECREASED" + withPolicy="UNSET" + checkStartedServers "${domainJson}" "${serverName}" "${clusterName}" "${withReplicas}" "${withPolicy}" startedWhenRelicaReducedAndPolicyReset + createReplicaPatch "${domainJson}" "${clusterName}" "DECREMENT" replicaPatch replicaCount + + if [[ -n ${managedServerPolicy} && "${startedWhenRelicaReducedAndPolicyReset}" != "true" ]]; then + # Server shuts down by unsetting start policy and decrementing replica count, unset and decrement + printInfo "Unsetting the current start policy '${managedServerPolicy}' for '${serverName}' \ + and decrementing replica count to ${replicaCount}." + createPatchJsonToUnsetPolicyAndUpdateReplica "${domainJson}" "${serverName}" "${replicaPatch}" patchJson + elif [[ -z ${managedServerPolicy} && "${startedWhenRelicaReducedAndPolicyReset}" != "true" ]]; then + # Start policy is not set, server shuts down by decrementing replica count, decrement replicas + printInfo "Updating replica count for cluster ${clusterName} to ${replicaCount}." + createPatchJsonToUpdateReplica "${replicaPatch}" patchJson + elif [[ ${managedServerPolicy} == "ALWAYS" && "${startedWhenAlwaysPolicyReset}" != "true" ]]; then + # Server shuts down by unsetting the start policy, unset and decrement replicas + printInfo "Unsetting the current start policy '${managedServerPolicy}' for '${serverName}' \ + and decrementing replica count to ${replicaCount}." + createPatchJsonToUnsetPolicyAndUpdateReplica "${domainJson}" "${serverName}" "${replicaPatch}" patchJson + else + # Patch server start policy to NEVER and decrement replica count + printInfo "Patching start policy of server '${serverName}' from '${effectivePolicy}' to 'NEVER' \ + and decrementing replica count for cluster '${clusterName}' to ${replicaCount}." + createPatchJsonToUpdateReplicaAndPolicy "${replicaPatch}" "${neverStartPolicyPatch}" patchJson + fi +elif [[ -n ${clusterName} && "${keepReplicaConstant}" == 'true' ]]; then + # Server is part of a cluster and replica count needs to stay constant + if [[ ${managedServerPolicy} == "ALWAYS" && "${startedWhenAlwaysPolicyReset}" != "true" ]]; then + # Server start policy is AlWAYS and server shuts down by unsetting the policy, unset policy + printInfo "Unsetting the current start policy '${effectivePolicy}' for '${serverName}'." + createPatchJsonToUnsetPolicy "${domainJson}" "${serverName}" patchJson + else + # Patch server start policy to NEVER + printInfo "Patching start policy of '${serverName}' from '${effectivePolicy}' to 'NEVER'." + createPatchJsonToUpdatePolicy "${neverStartPolicyPatch}" patchJson + fi +elif [ "${isAdminServer}" == 'true' ]; then + printInfo "Patching start policy of '${serverName}' from '${effectivePolicy}' to 'NEVER'." + createPatchJsonToUpdateAdminPolicy "${domainJson}" "${serverStartPolicy}" patchJson +else + # Server is an independent managed server, patch server start policy to NEVER + printInfo "Patching start policy of '${serverName}' from '${effectivePolicy}' to 'NEVER'." + createPatchJsonToUpdatePolicy "${neverStartPolicyPatch}" patchJson +fi + +executePatchCommand "${kubernetesCli}" "${domainUid}" "${domainNamespace}" "${patchJson}" "${verboseMode}" + +printInfo "Patch command succeeded !" diff --git a/OracleWebCenterPortal/kubernetes/elasticsearch-and-kibana/README.md b/OracleWebCenterPortal/kubernetes/elasticsearch-and-kibana/README.md new file mode 100644 index 000000000..bd62bcc56 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/elasticsearch-and-kibana/README.md @@ -0,0 +1,31 @@ +# Sample to deploy Elasticsearch and Kibana + + +When you install the WebLogic operator Helm chart, you can set +`elkIntegrationEnabled` to `true` in your `values.yaml` file to tell the operator to send the contents of the operator's logs to Elasticsearch. + +Typically, you would have already configured Elasticsearch and Kibana in the +Kubernetes cluster, and also would have specified `elasticSearchHost` and `elasticSearchPort` in your `values.yaml` file to point to where Elasticsearch is already running. + +This sample configures the Elasticsearch and Kibana deployments and services. +It's useful for trying out the operator in a Kubernetes cluster that doesn't already +have them configured. + +It runs the Elastic Stack on the same host and port that the operator's Helm chart defaults +to, therefore, you only need to set `elkIntegrationEnabled` to `true` in your +`values.yaml` file. + +To control Elasticsearch memory parameters (Heap allocation and Enabling/Disabling swapping) please open the file `elasticsearch_and_kibana.yaml`, search for env variables of the elasticsearch container and change the values of the following. + +* ES_JAVA_OPTS: value may contain for example -Xms512m -Xmx512m to lower the default memory usage (please be aware that this value is only applicable for demo purpose and it is not the one recommended by Elasticsearch itself) +* bootstrap.memory_lock: value may contain true (enables the usage of mlockall to try to lock the process address space into RAM, preventing any Elasticsearch memory from being swapped out) or false (disables the usage of mlockall to try to lock the process address space into RAM, preventing any Elasticsearch memory from being swapped out). + +To install Elasticsearch and Kibana, use: +```shell +$ kubectl apply -f kubernetes/samples/scripts/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml +``` + +To remove them, use: +```shell +$ kubectl delete -f kubernetes/samples/scripts/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml +``` diff --git a/OracleWebCenterPortal/kubernetes/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml b/OracleWebCenterPortal/kubernetes/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml new file mode 100644 index 000000000..97b0b9186 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml @@ -0,0 +1,117 @@ +# Copyright (c) 2018, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# When a user installs the WebLogic operator Helm chart, the user can set +# elkIntegrationEnabled to true in their values.yaml to tell the operator to send the +# contents of the operator's log to Elasticsearch. +# +# Typically, a user would have already configured Elasticsearch and Kibana in the +# Kubernetes cluster, and also would specify elasticSearchHost and elasticSearchPort +# in their values.yaml file to point to where Elasticsearch is already running. +# +# This sample configures the Elasticsearch and Kibana deployments and services. +# It's useful for trying out the operator in a Kubernetes cluster that doesn't already +# have them configured. +# +# It runs Elasticstack on the same host and port that the operator's Helm chart defaults +# to, therefore, the customer only needs to set elkIntegrationEnabled to true in their +# values.yaml file. +# +# To configure them, use: +# kubectl apply -f kubernetes/samples/scripts/elasticsearch_and_kibana.yaml +# +# To remove them, use: +# kubectl delete -f kubernetes/samples/scripts/elasticsearch_and_kibana.yaml + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: "default" + name: "elasticsearch" + labels: + app: "elasticsearch" +spec: + replicas: 1 + selector: + matchLabels: + app: "elasticsearch" + template: + metadata: + labels: + app: "elasticsearch" + spec: + initContainers: + - name: set-vm-max-map-count + image: busybox + imagePullPolicy: IfNotPresent + command: ['sysctl', '-w', 'vm.max_map_count=262144'] + securityContext: + privileged: true + containers: + - name: "elasticsearch" + image: "elasticsearch:6.8.0" + ports: + - containerPort: 9200 + - containerPort: 9300 + env: + - name: ES_JAVA_OPTS + value: -Xms1024m -Xmx1024m + +--- +kind: "Service" +apiVersion: "v1" +metadata: + namespace: "default" + name: "elasticsearch" +spec: + ports: + - name: "http" + protocol: "TCP" + port: 9200 + targetPort: 9200 + - name: "https" + protocol: "TCP" + port: 9300 + targetPort: 9300 + selector: + app: "elasticsearch" + +--- +apiVersion: "apps/v1" +kind: "Deployment" +metadata: + namespace: "default" + name: "kibana" + labels: + app: "kibana" +spec: + replicas: 1 + selector: + matchLabels: + app: "kibana" + template: + metadata: + labels: + app: "kibana" + spec: + containers: + - name: "kibana" + image: "kibana:6.8.0" + ports: + - containerPort: 5601 + +--- +apiVersion: "v1" +kind: "Service" +metadata: + namespace: "default" + name: "kibana" + labels: + app: "kibana" +spec: + type: "NodePort" + ports: + - port: 5601 + selector: + app: "kibana" diff --git a/OracleWebCenterPortal/kubernetes/imagetool-scripts/buildArgs b/OracleWebCenterPortal/kubernetes/imagetool-scripts/buildArgs index 58be2ac87..1a3abf42f 100755 --- a/OracleWebCenterPortal/kubernetes/imagetool-scripts/buildArgs +++ b/OracleWebCenterPortal/kubernetes/imagetool-scripts/buildArgs @@ -4,6 +4,7 @@ create --version=12.2.1.4.0 --tag=oracle/wcportal:12.2.1.4 --pull +--fromImage ghcr.io/oracle/oraclelinux:7-slim --additionalBuildCommands /docker-images/OracleWebCenterPortal/imagetool/12.2.1.4.0/additionalBuildCmds.txt --additionalBuildFiles /docker-images/OracleWebCenterPortal/dockerfiles/12.2.1.4/container-scripts --opatchBugNumber 28186730_13.9.4.2.5 diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/README.md b/OracleWebCenterPortal/kubernetes/ingress-per-domain/README.md deleted file mode 100755 index 7b7e89972..000000000 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/README.md +++ /dev/null @@ -1,100 +0,0 @@ -# An Ingress per domain chart -This chart is for deploying an Ingress resource in front of a WebLogic domain cluster. We support three Ingress types: Traefik, Voyager, Nginx. - -## Prerequisites -- Have Docker and a Kubernetes cluster running and have `kubectl` installed and configured. -- Have Helm installed. -- The corresponding Ingress controller, Traefik or Voyager, is installed in the Kubernetes cluster. -- A WebLogic domain cluster deployed by `weblogic-operator` is running in the Kubernetes cluster. - -## Generate Secret to access SSL services - -Command to Generate Secret: -``` -$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=*" -$ kubectl -n wcpns create secret tls domain1-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt - -``` - -## Installing the chart - -To install the chart with the release name, `my-ingress`, with the given `values.yaml`: -``` -# Change directory to the cloned git weblogic-kubernetes-operator repo. -$ cd kubernetes/samples/charts - -# Use helm to install the chart. Use `--namespace` to specify the name of the WebLogic domain's namespace. -$ helm install ingress-per-domain --name my-ingress --namespace my-domain-namespace --values values.yaml -``` -The Ingress resource will be created in the same namespace as the WebLogic domain cluster. - -Sample `values.yaml` for the Traefik Ingress: -``` -type: TRAEFIK - -# WLS domain as backend to the load balancer -wlsDomain: - domainUID: domain1 - clusterName: cluster1 - managedServerPort: 8001 - -# Traefik specific values -traefik: - # hostname used by host-routing - hostname: domain1.org -``` - -Sample `values.yaml` for the Voyager Ingress: -``` -type: VOYAGER - -# WLS domain as backend to the load balancer -wlsDomain: - domainUID: domain1 - clusterName: cluster1 - managedServerPort: 8001 - -# Voyager specific values -voyager: - # web port - webPort: 30305 - # stats port - statsPort: 30315 -``` -Sample `values.yaml` for the NGINX Ingress: -``` -type: NGINX - -# WLS domain as backend to the load balancer -wlsDomain: - domainUID: domain1 - clusterName: cluster1 - managedServerPort: 8001 - -# nginx specific values -nginx: - connectTimeout: 1800 - readTimeout: 1800 - sendTimeout: 1800 - cookieExpires: 172800 - cookieMaxAge: 172800 -``` -## Uninstalling the chart -To uninstall and delete the `my-ingress` deployment: -``` -$ helm delete --purge my-ingress -``` -## Configuration -The following table lists the configurable parameters of this chart and their default values. - -| Parameter | Description | Default | -| --- | --- | --- | -| `type` | Type of Ingress controller. Legal values are `TRAEFIK` or `VOYAGER`. | `TRAEFIK` | -| `wlsDomain.domainUID` | DomainUID of the WLS domain. | `domain1` | -| `wlsDomain.clusterName` | Cluster name in the WLS domain. | `cluster-1` | -| `wlsDomain.managedServerPort` | Port number of the managed servers in the WLS domain cluster. | `8001` | -| `traefik.hostname` | Hostname to route to the WLS domain cluster. | `domain1.org` | -| `voyager.webPort` | Web port to access the Voyager load balancer. | `30305` | -| `voyager.statsPort` | Port to access the Voyager/HAProxy stats page. | `30315` | - -**Note:** The input values `domainUID` and `clusterName` will be used to generate the Kubernetes `serviceName` of the WLS cluster with the format `domainUID-cluster-clusterName`. diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/nginx-ingress.yaml b/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/nginx-ingress.yaml deleted file mode 100755 index 51479d7fe..000000000 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/nginx-ingress.yaml +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -{{- if eq .Values.type "NGINX" }} ---- -apiVersion: {{ .Values.apiVersion }} -kind: Ingress -metadata: - name: {{ .Values.wlsDomain.domainUID }}-ingress - namespace: {{ .Release.Namespace }} - annotations: -{{- if eq .Values.tls "SSL" }} - kubernetes.io/ingress.class: nginx - nginx.ingress.kubernetes.io/configuration-snippet: | - more_set_input_headers "X-Forwarded-Proto: https"; - more_set_input_headers "WL-Proxy-SSL: true"; - nginx.ingress.kubernetes.io/ingress.allow-http: "false" -{{- end }} - nginx.ingress.kubernetes.io/proxy-connect-timeout: "{{ .Values.ngnix.connectTimeout }}" - nginx.ingress.kubernetes.io/proxy-read-timeout: "{{ .Values.ngnix.readTimeout }}" - nginx.ingress.kubernetes.io/proxy-send-timeout: "{{ .Values.ngnix.sendTimeout }}" - nginx.ingress.kubernetes.io/affinity: "cookie" - nginx.ingress.kubernetes.io/session-cookie-name: "stickyid" - nginx.ingress.kubernetes.io/session-cookie-expires: "{{ .Values.ngnix.cookieExpires }}" - nginx.ingress.kubernetes.io/session-cookie-max-age: "{{ .Values.ngnix.cookieMaxAge }}" - nginx.ingress.kubernetes.io/ssl-redirect: "false" - nginx.ingress.kubernetes.io/affinity-mode: persistent -spec: - rules: - - host: '{{ .Values.nginx.hostname }}' - http: - paths: - - path: /webcenter - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /console - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName| lower }}' - servicePort: {{.Values.wlsDomain.adminServerPort}} - - path: /rsscrawl - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /webcenterhelp - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /rest - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /em - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName| lower }}' - servicePort: {{.Values.wlsDomain.adminServerPort}} - {{- if eq .Values.tls "SSL" }} -tls: - - hosts: - - '{{ .Values.nginx.hostname }}' - secretName: domain1-tls-cert -{{- end }} - {{- end }} diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/traefik-ingress.yaml b/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/traefik-ingress.yaml deleted file mode 100755 index 7994e11ff..000000000 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/traefik-ingress.yaml +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -{{- if eq .Values.type "TRAEFIK" }} ---- -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ .Values.wlsDomain.domainUID }}-traefik - namespace: {{ .Release.Namespace }} - annotations: - kubernetes.io/ingress.class: traefik -{{- if eq .Values.tls "SSL" }} - traefik.ingress.kubernetes.io/router.entrypoints: websecure - traefik.ingress.kubernetes.io/router.tls: "true" - traefik.ingress.kubernetes.io/router.middlewares: wcpns-wls-proxy-ssl@kubernetescrd -{{- end }} -spec: - rules: - - host: '{{ .Values.traefik.hostname }}' - http: - paths: - - path: /webcenter - backend: - serviceName: '{{ .Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /console - backend: - serviceName: '{{.Values.wlsDomain.domainUID}}-{{.Values.wlsDomain.adminServerName| lower}}' - servicePort: {{.Values.wlsDomain.adminServerPort}} - - path: /rsscrawl - backend: - serviceName: '{{.Values.wlsDomain.domainUID}}-cluster-{{.Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /webcenterhelp - backend: - serviceName: '{{.Values.wlsDomain.domainUID}}-cluster-{{.Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /rest - backend: - serviceName: '{{.Values.wlsDomain.domainUID}}-cluster-{{.Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /em - backend: - serviceName: '{{.Values.wlsDomain.domainUID}}-{{.Values.wlsDomain.adminServerName| lower}}' - servicePort: {{.Values.wlsDomain.adminServerPort}} - - {{- if eq .Values.tls "SSL" }} - tls: - - hosts: - - '{{ .Values.traefik.hostname }}' - secretName: wcpinfra-tls-cert -{{- end }} -{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/voyager-ingress.yaml b/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/voyager-ingress.yaml deleted file mode 100755 index 69ce7147e..000000000 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/templates/voyager-ingress.yaml +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -{{- if eq .Values.type "VOYAGER" }} ---- -apiVersion: voyager.appscode.com/v1beta1 -kind: Ingress -metadata: - name: {{ .Values.wlsDomain.domainUID }}-voyager - namespace: {{ .Release.Namespace }} - annotations: - ingress.appscode.com/type: 'NodePort' - ingress.appscode.com/stats: 'true' - ingress.appscode.com/affinity: 'cookie' -spec: -{{- if eq .Values.tls "SSL" }} - frontendRules: - - port: 443 - rules: - - http-request set-header WL-Proxy-SSL true - tls: - - secretName: wcpinfra-tls-cert - hosts: - - '*' -{{- end }} - rules: - - host: '*' - http: - nodePort: '{{ .Values.voyager.webPort }}' - paths: - - path: /webcenter - backend: - serviceName: '{{.Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /console - backend: - serviceName: '{{.Values.wlsDomain.domainUID }}-{{ .Values.wlsDomain.adminServerName| lower}}' - servicePort: {{.Values.wlsDomain.adminServerPort}} - - path: /rsscrawl - backend: - serviceName: '{{.Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /rest - backend: - serviceName: '{{.Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /webcenterhelp - backend: - serviceName: '{{.Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' - servicePort: {{.Values.wlsDomain.managedServerPort}} - - path: /em - backend: - serviceName: '{{.Values.wlsDomain.domainUID}}-{{.Values.wlsDomain.adminServerName| lower}}' - servicePort: {{.Values.wlsDomain.adminServerPort}} -# - path: /wls-exporter -# backend: -# serviceName: '{{.Values.wlsDomain.domainUID }}-cluster-{{ .Values.wlsDomain.clusterName | lower}}' -# servicePort: {{.Values.wlsDomain.managedServerPort}} - ---- -apiVersion: v1 -kind: Service -metadata: - name: {{.Values.wlsDomain.domainUID}}-voyager-stats - namespace: {{.Release.Namespace}} - labels: - weblogic.resourceVersion: domain-v2 -spec: - type: NodePort - ports: - - name: client - protocol: TCP - port: 56789 - targetPort: 56789 - nodePort: {{.Values.voyager.statsPort}} - selector: - origin: voyager - origin-name: {{.Values.wlsDomain.domainUID}}-voyager -{{- end }} diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/voyager-tls.yaml b/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/voyager-tls.yaml deleted file mode 100755 index dc41c6648..000000000 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/tls/voyager-tls.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -apiVersion: voyager.appscode.com/v1beta1 -kind: Ingress -metadata: - name: voyager-endtoendssl - namespace: wcpns - annotations: - ingress.appscode.com/type: 'NodePort' - ingress.appscode.com/stats: 'true' - ingress.appscode.com/affinity: 'cookie' - ingress.appscode.com/ssl-passthrough: "true" -spec: - tls: - - secretName: domain1-tls-cert - hosts: - - '*' - rules: - - host: '*' - http: - nodePort: '31443' - paths: - - path: / - backend: - serviceName: wcp-domain-cluster-wcp-cluster - servicePort: '8889' diff --git a/OracleWebCenterPortal/kubernetes/ingress-per-domain/values.yaml b/OracleWebCenterPortal/kubernetes/ingress-per-domain/values.yaml deleted file mode 100755 index 6a032d868..000000000 --- a/OracleWebCenterPortal/kubernetes/ingress-per-domain/values.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2021, Oracle and/or its affiliates. -# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - -# Default values for ingress-per-domain. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -apiVersion: networking.k8s.io/v1beta1 - -# Load balancer type. Supported values are: TRAEFIK, VOYAGER ,NGINX -type: TRAEFIK -# Supported values NONSSL ,SSL -tls: NONSSL - -# WLS domain as backend to the load balancer -wlsDomain: - domainUID: wcp-domain - clusterName: wcp-cluster - managedServerPort: 8888 - adminServerPort: 7001 - adminServerName: adminserver - -# Traefik specific values -traefik: - # hostname used by host-routing - hostname: domain1.org - -# Voyager specific values -voyager: - # web port - webPort: 30305 - # stats port - statsPort: 30315 - -# Ngnix specific values -nginx: - connectTimeout: 1800 - readTimeout: 1800 - sendTimeout: 1800 - cookieExpires: 172800 - cookieMaxAge: 172800 diff --git a/OracleWebCenterPortal/kubernetes/logging-services/logstash/README.md b/OracleWebCenterPortal/kubernetes/logging-services/logstash/README.md new file mode 100644 index 000000000..fb55c56df --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/logging-services/logstash/README.md @@ -0,0 +1,59 @@ +## Publish OracleWebCenterPortal server and diagnostics logs into Elasticsearch + +## Prerequisites +See [here](https://oracle.github.io/weblogic-kubernetes-operator/samples/simple/elastic-stack/) for the steps to integrate Elasticsearch for the WebLogic Kubernetes operator. + +Before deploying the WebLogic Kubernetes operator edit `values.yaml` in weblogic-kubernetes-operator/kubernetes/charts/weblogic-operator/ to enable elastic search integration. +Configure the following variables: +```bash +# elkIntegrationEnabled specifies whether or not ELK integration is enabled. +elkIntegrationEnabled: true +# logStashImage specifies the docker image containing logstash. +# This parameter is ignored if 'elkIntegrationEnabled' is false. +logStashImage: "logstash:6.6.0" + +# elasticSearchHost specifies the hostname of where Elasticsearch is running. +# This parameter is ignored if 'elkIntegrationEnabled' is false. +elasticSearchHost: "elasticsearch.default.svc.cluster.local" + +# elasticSearchPort specifies the port number of where Elasticsearch is running. +# This parameter is ignored if 'elkIntegrationEnabled' is false. +elasticSearchPort: 9200 +``` +Deployment of WebLogic Kubernetes operator with above changes, will create an additional logstash container as sidecar. This logstash container will push the operator logs to the configured Elasticsearch server. + +### WebLogic Server logs + +The WebLogic server logs or diagnostics logs can be pushed to Elasticsearch server using logstash pod. The logstash pod should have access to the shared domain home or the log location. The persistent volume of the domain home can be used in the logstash pod. + +### Create the logstash pod + +1. Get Domain home persistence volume claim details +Get the persistent volume details of the domain home of the WebLogic server(s). + + ```bash + $ kubectl get pvc -n wcpns + ``` + +1. Create logstash configuration. +Create logstash configuration file. The logstash configuration file can be loaded from a volume. + ```bash + $ kubectl cp logstash.conf wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains --namespace wcpns + ``` + + You can use sample logstash configuration file generated to push server and diagnostic logs of all servers available at DOMAIN_HOME/servers//logs/-diagnostic.log + +1. Copy the logstash.conf into say /u01/oracle/user_projects/domains so that it can be used for logstash deployment, using Administration Server pod + +1. Create deployment YAML for logstash pod. +You can use sample logstash.yaml file generated to create deployment for logstash pod. The mounted persistent volume of the domain home will provide access to the WebLogic server logs to logstash pod. +Make sure to point the logstash configuration file to correct location and also correct domain home persistence volume claim. + +1. Deploy logstash to start publish logs to Elasticsearch: + + ```bash + $ kubectl create -f logstash.yaml + ``` + +1. Now, you can view the diagnostics logs using Kibana with index pattern `logstash-*`. + diff --git a/OracleWebCenterPortal/kubernetes/logging-services/logstash/logstash.conf b/OracleWebCenterPortal/kubernetes/logging-services/logstash/logstash.conf new file mode 100644 index 000000000..ea9487e11 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/logging-services/logstash/logstash.conf @@ -0,0 +1,25 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +input { + file { + path => "/u01/oracle/user_projects/domains/wcp-domain/servers/**/logs/*-diagnostic.log" + start_position => beginning + } + file { + path => "/u01/oracle/user_projects/domains/logs/wcp-domain/*.log" + start_position => beginning + } +} + +filter { + grok { + match => [ "message", "<%{DATA:log_timestamp}> <%{WORD:log_level}> <%{WORD:thread}> <%{HOSTNAME:hostname}> <%{HOSTNAME:servername}> <%{DATA:timer}> <<%{DATA:kernel}>> <> <%{DATA:uuid}> <%{NUMBER:timestamp}> <%{DATA:misc}> <%{DATA:log_number}> <%{DATA:log_message}>" ] + } +} +output { + elasticsearch { + hosts => ["elasticsearch.default.svc.cluster.local:9200"] + } +} diff --git a/OracleWebCenterPortal/kubernetes/logging-services/logstash/logstash.yaml b/OracleWebCenterPortal/kubernetes/logging-services/logstash/logstash.yaml new file mode 100644 index 000000000..c1938a090 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/logging-services/logstash/logstash.yaml @@ -0,0 +1,39 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: logstash + namespace: wcpns +spec: + selector: + matchLabels: + app: logstash + template: # create pods using pod definition in this template + metadata: + labels: + app: logstash + spec: + volumes: + - name: domain-storage-volume + persistentVolumeClaim: + claimName: wcp-domain-domain-pvc + - name: shared-logs + emptyDir: {} + containers: + - name: logstash + image: logstash:6.6.0 + command: ["/bin/sh"] + args: ["/usr/share/logstash/bin/logstash", "-f", "/u01/oracle/user_projects/domains/logstash.conf"] + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /u01/oracle/user_projects/domains + name: domain-storage-volume + - name: shared-logs + mountPath: /shared-logs + ports: + - containerPort: 5044 + name: logstash + diff --git a/OracleWebCenterPortal/kubernetes/logging-services/weblogic-logging-exporter/README.md b/OracleWebCenterPortal/kubernetes/logging-services/weblogic-logging-exporter/README.md new file mode 100644 index 000000000..2de15b340 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/logging-services/weblogic-logging-exporter/README.md @@ -0,0 +1,131 @@ +## Publish WebLogic Server logs into Elasticsearch + +The WebLogic Logging Exporter adds a log event handler to WebLogic Server, such that WebLogic Server logs can be integrated into Elastic Stack in Kubernetes directly, by using the Elasticsearch REST API. + +## Prerequisite + +This document assumes that you have already deployed Elasticsearch/Kibana environment. If you have not, please use a sample/demo deployment of Elasticsearch/Kibana from WebLogic Kubernetes operator. + +To deploy Elasticsearch and Kibana on the Kubernetes cluster: +```bash +$ kubectl create -f https://raw.githubusercontent.com/oracle/weblogic-kubernetes-operator/master/kubernetes/samples/scripts/elasticsearch-and-kibana/elasticsearch_and_kibana.yaml +``` + +Follow these steps to setup WebLogic Logging Exporter in a WebLogic operator environment and push the WebLogic server logs to Elasticsearch/Kibana + +1. Download WebLogic logging exporter binaries + + The WebLogic logging exporter pre-built binaries are available in the github releases page: [Release 1.0.1](https://github.com/oracle/weblogic-logging-exporter/releases) + + ```bash + $ wget https://github.com/oracle/weblogic-logging-exporter/releases/download/v1.0.1/weblogic-logging-exporter.jar + ``` + + Download weblogic-logging-exporter.jar from the github release link above. Also download dependency jar - snakeyaml-1.27.jar from Maven Central. + + ```bash + $ wget -O snakeyaml-1.27.jar https://search.maven.org/remotecontent?filepath=org/yaml/snakeyaml/1.27/snakeyaml-1.27.jar + ``` +1. Copy JAR files into the Kubernetes WebLogic Administration Server Pod + + Copy weblogic-logging-exporter.jar and snakeyaml-1.27.jar to the domain home folder in the Administration server pod. + + ```bash + $ kubectl cp weblogic-logging-exporter.jar wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/ + $ kubectl cp snakeyaml-1.27.jar wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/ + ``` + +1. Add a startup class to the domain configuration + + In this step, we configure weblogic-logging-exporter JAR as a startup class in the WebLogic servers where we intend to collect the logs. + + a) In the Administration Console, navigate to `Environment` then `Startup and Shutdown classes` in the main menu. + + b) Add a new Startup class. You may choose any descriptive name and the class name must be `weblogic.logging.exporter.Startup`. + + c) Target the startup class to each server that you want to export logs from. + + You can verify this by checking for the update in your config.xml which should be similar to this example: + + ```bash + + LoggingExporterStartupClass + AdminServer + weblogic.logging.exporter.Startup + + ``` + +1. Update WebLogic Server CLASS Path. + + In this step, we set the class path for weblogic-logging-exporter and its dependencies. + + a) Copy setDomainEnv.sh from the pod to local folder. + ```bash + $ kubectl cp wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/bin/setDomainEnv.sh setDomainEnv.sh + ``` + b) Modify setDomainEnv.sh to update the Server Class path. + ```bash + CLASSPATH=/u01/oracle/user_projects/domains/wcp-domain/weblogic-logging-exporter.jar:/u01/oracle/user_projects/domains/wcp-domain/snakeyaml-1.27.jar:${CLASSPATH} + export CLASSPATH + ``` + + c) Copy back the modified setDomainEnv.sh to the pod. + ```bash + $ kubectl cp setDomainEnv.sh wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/bin/setDomainEnv.sh + ``` + +1. Create configuration file for the WebLogic Logging Exporter. +Copy WebLogicLoggingExporter.yaml to the domain folder in the WebLogic server pod. YAML specifies the elasticsearch server host and port number. + ```bash + $ kubectl cp WebLogicLoggingExporter.yaml wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/config/ + ``` + +1. Restart WebLogic Servers + + Now we can restart the WebLogic servers for the weblogic-logging-exporter to get loaded in the servers. + + To restart the servers, use stopDomain.sh and startDomain.sh scripts from https://github.com/oracle/weblogic-kubernetes-operator/tree/master/kubernetes/samples/scripts/domain-lifecycle + + The stopDomain.sh script shuts down a domain by patching the `spec.serverStartPolicy` attribute of the domain resource to `NEVER`. The operator will shut down the WebLogic Server instance Pods that are part of the domain after the `spec.serverStartPolicy` attribute is updated to `NEVER`. See the script usage information by using the -h option. + + ```bash + $ stopDomain.sh -d wcp-domain -n wcpns + ``` + Sample output: + ```bash + [INFO] Patching domain 'wcp-domain' in namespace 'wcpns' from serverStartPolicy='IF_NEEDED' to 'NEVER'. + domain.weblogic.oracle/wcp-domain patched + [INFO] Successfully patched domain 'wcp-domain' in namespace 'wcpns' with 'NEVER' start policy! + ``` + + Verify servers by checking the pod status. + ```bash + $ kubectl get pods -n wcpns + ``` + + After all the servers are shutdown, run startDomain.sh script to start again. + + The startDomain.sh script starts a deployed domain by patching the `spec.serverStartPolicy` attribute of the domain resource to `IF_NEEDED`. The operator will start the WebLogic Server instance Pods that are part of the domain after the `spec.serverStartPolicy` attribute of the domain resource is updated to `IF_NEEDED`. See the script usage information by using the -h option. + + ```bash + $ startDomain.sh -d wcp-domain -n wcpns + ``` + Sample output: + ```bash + [INFO] Patching domain 'wcp-domain' from serverStartPolicy='NEVER' to 'IF_NEEDED'. + domain.weblogic.oracle/wcp-domain patched + [INFO] Successfully patched domain 'wcp-domain' in namespace 'wcpns' with 'IF_NEEDED' start policy! + ``` + + Verify servers by checking the pod status. Pod status will be RUNNING. + ```bash + $ kubectl get pods -n wcpns + ``` + In the server logs, you will be able to see the weblogic-logging-exporter class being called. + +1. Create an index pattern in Kibana + + We need to create an index pattern in Kibana for the logs to be available in the dashboard. + + Create an index pattern `wls*` in `Kibana` > `Management`. After the server starts, you will be able to see the log data from the WebLogic servers in the Kibana dashboard, + diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-logging-exporter/WebLogicLoggingExporter.yaml b/OracleWebCenterPortal/kubernetes/logging-services/weblogic-logging-exporter/WebLogicLoggingExporter.yaml old mode 100755 new mode 100644 similarity index 61% rename from OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-logging-exporter/WebLogicLoggingExporter.yaml rename to OracleWebCenterPortal/kubernetes/logging-services/weblogic-logging-exporter/WebLogicLoggingExporter.yaml index 5c9e711f9..5ba6bf454 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-logging-exporter/WebLogicLoggingExporter.yaml +++ b/OracleWebCenterPortal/kubernetes/logging-services/weblogic-logging-exporter/WebLogicLoggingExporter.yaml @@ -1,9 +1,13 @@ # Copyright (c) 2021, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + weblogicLoggingIndexName: wls -publishHost: elasticsearch.wcpns.svc.cluster.local -publishPort: 9600 +publishHost: elasticsearch.default.svc.cluster.local +publishPort: 9200 domainUID: wcp-domain -weblogicLoggingExporterEnabled: true -weblogicLoggingExporterSeverity: TRACE +weblogicLoggingExporterEnabled: true +weblogicLoggingExporterSeverity: Notice weblogicLoggingExporterBulkSize: 1 + + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/README.md b/OracleWebCenterPortal/kubernetes/monitoring-service/README.md new file mode 100644 index 000000000..23a1c20c9 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/README.md @@ -0,0 +1,276 @@ +# Monitor the OracleWebCenterPortal instance using Prometheus and Grafana +Using the `WebLogic Monitoring Exporter` you can scrape runtime information from a running OracleWebCenterPortal instance and monitor them using Prometheus and Grafana. + +## Prerequisites + +- Have Docker and a Kubernetes cluster running and have `kubectl` installed and configured. +- Have Helm installed. +- An OracleWebCenterPortal domain deployed by `weblogic-operator` is running in the Kubernetes cluster. + +## Set up monitoring for OracleWebCenterPortal domain + +Set up the WebLogic Monitoring Exporter that will collect WebLogic Server metrics and monitor OracleWebCenterPortal domain. + +**Note**: Either of the following methods can be used to set up monitoring for OracleWebCenterPortal domain. Using `setup-monitoring.sh` does the set up in an automated way. + +1. [Set up manually](#set-up-manually) +1. [Set up using `setup-monitoring.sh`](#set-up-using-setup-monitoringsh) + +## Set up manually + +### Deploy Prometheus and Grafana + +Refer to the compatibility matrix of [Kube Prometheus](https://github.com/coreos/kube-prometheus#kubernetes-compatibility-matrix) and clone the [release](https://github.com/coreos/kube-prometheus/releases) version of the `kube-prometheus` repository according to the Kubernetes version of your cluster. + +1. Clone the `kube-prometheus` repository: + ``` + $ git clone https://github.com/coreos/kube-prometheus.git + ``` + +1. Change to folder `kube-prometheus` and enter the following commands to create the namespace and CRDs, and then wait for their availability before creating the remaining resources: + + ``` + $ cd kube-prometheus + $ kubectl create -f manifests/setup + $ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done + $ kubectl create -f manifests/ + ``` + +1. `kube-prometheus` requires all nodes in the Kubernetes cluster to be labeled with `kubernetes.io/os=linux`. If any node is not labeled with this, then you need to label it using the following command: + + ``` + $ kubectl label nodes --all kubernetes.io/os=linux + ``` + +1. Enter the following commands to provide external access for Grafana, Prometheus, and Alertmanager: + + ``` + $ kubectl patch svc grafana -n monitoring --type=json -p '[{"op": "replace", "path": "/spec/type", "value": "NodePort" },{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 32100 }]' + + $ kubectl patch svc prometheus-k8s -n monitoring --type=json -p '[{"op": "replace", "path": "/spec/type", "value": "NodePort" },{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 32101 }]' + + $ kubectl patch svc alertmanager-main -n monitoring --type=json -p '[{"op": "replace", "path": "/spec/type", "value": "NodePort" },{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 32102 }]' + ``` + + Note: + * `32100` is the external port for Grafana + * `32101` is the external port for Prometheus + * `32102` is the external port for Alertmanager + +### Generate the WebLogic Monitoring Exporter Deployment Package + +The `wls-exporter.war` package need to be updated and created for each listening ports (Administration Server and Managed Servers) in the domain. +Set the below environment values based on your environment and run the script `get-wls-exporter.sh` to generate the required WAR files at `${WORKDIR}/monitoring-service/scripts/wls-exporter-deploy`: +- adminServerPort +- wlsMonitoringExporterTowcpCluster +- wcpManagedServerPort +- wlsMonitoringExporterTowcpPortletCluster +- wcpPortletManagedServerPort + +For example: + +``` +$ cd ${WORKDIR}/monitoring-service/scripts +$ export adminServerPort=7001 +$ export wlsMonitoringExporterTowcpCluster=true +$ export wcpManagedServerPort=8888 +$ export wlsMonitoringExporterTowcpPortletCluster=true +$ export wcpPortletManagedServerPort=8889 +$ sh get-wls-exporter.sh +``` + +Verify whether the required WAR files are generated at `${WORKDIR}/monitoring-service/scripts/wls-exporter-deploy`. + +``` +$ ls ${WORKDIR}/monitoring-service/scripts/wls-exporter-deploy +``` + +### Deploy the WebLogic Monitoring Exporter into the OracleWebCenterPortal domain + +Follow these steps to copy and deploy the WebLogic Monitoring Exporter WAR files into the OracleWebCenterPortal Domain. + +**Note**: Replace the `` with appropriate values based on your environment: + +``` +$ cd ${WORKDIR}/monitoring-service/scripts +$ kubectl cp wls-exporter-deploy /:/u01/oracle +$ kubectl cp deploy-weblogic-monitoring-exporter.py /:/u01/oracle/wls-exporter-deploy +$ kubectl exec -it -n -- /u01/oracle/oracle_common/common/bin/wlst.sh /u01/oracle/wls-exporter-deploy/deploy-weblogic-monitoring-exporter.py \ +-domainName -adminServerName -adminURL \ +-wcpClusterName -wlsMonitoringExporterTowcpCluster \ +-wcpPortletClusterName -wlsMonitoringExporterTowcpPortletCluster \ +-username -password +``` + +For example: + +``` +$ cd ${WORKDIR}/monitoring-service/scripts +$ kubectl cp wls-exporter-deploy wcpns/wcp-domain-adminserver:/u01/oracle +$ kubectl cp deploy-weblogic-monitoring-exporter.py wcpns/wcp-domain-adminserver:/u01/oracle/wls-exporter-deploy +$ kubectl exec -it -n wcpns wcp-domain-adminserver -- /u01/oracle/oracle_common/common/bin/wlst.sh /u01/oracle/wls-exporter-deploy/deploy-weblogic-monitoring-exporter.py \ +-domainName wcp-domain -adminServerName -adminserver:7001 \ +-wcpClusterName wcp-cluster -wlsMonitoringExporterTowcpCluster true \ +-wcpPortletClusterName wcportlet-cluster -wlsMonitoringExporterTowcpPortletCluster true \ +-username weblogic -password Welcome1 +``` + +### Configure Prometheus Operator + +Prometheus enables you to collect metrics from the WebLogic Monitoring Exporter. The Prometheus Operator identifies the targets using service discovery. To get the WebLogic Monitoring Exporter end point discovered as a target, you must create a service monitor pointing to the service. + +The service monitor deployment YAML configuration file is available at `${WORKDIR}/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml.template`. Copy the file as `wls-exporter-ServiceMonitor.yaml` to update with appropriate values as detailed below. + +The exporting of metrics from `wls-exporter` requires `basicAuth`, so a Kubernetes `Secret` is created with the user name and password that are base64 encoded. This `Secret` is used in the `ServiceMonitor` deployment. The `wls-exporter-ServiceMonitor.yaml` has namespace as `wcpns` and has `basicAuth` with credentials as `username: %USERNAME%` and `password: %PASSWORD%`. Update `%USERNAME%` and `%PASSWORD% ` in base64 encoded and all occurences of `wcpns` based on your environment. + +Use the following example for base64 encoded: + +``` +$ echo -n "Welcome1" | base64 +V2VsY29tZTE= +``` + +You need to add `RoleBinding` and `Role` for the namespace (wcpns) under which the WebLogic Servers pods are running in the Kubernetes cluster. These are required for Prometheus to access the endpoints provided by the WebLogic Monitoring Exporters. The YAML configuration files for wcpns namespace are provided in "${WORKDIR}/monitoring-service/manifests/". + +If you are using namespace other than `wcpns`, update the namespace details in `prometheus-roleBinding-domain-namespace.yaml` and `prometheus-roleSpecific-domain-namespace.yaml`. + +Perform the below steps for enabling Prometheus to collect the metrics from the WebLogic Monitoring Exporter: + +``` +$ cd ${WORKDIR}/monitoring-service/manifests +$ kubectl apply -f . +``` + +### Verify the service discovery of WebLogic Monitoring Exporter + +After the deployment of the service monitor, Prometheus should be able to discover wls-exporter and collect the metrics. + +1. Access the Prometheus dashboard at `http://mycompany.com:32101/` + +1. Navigate to **Status** to see the **Service Discovery** details. + +1. Verify that `wls-exporter` is listed in the discovered Services. + + +### Deploy Grafana Dashboard + +You can access the Grafana dashboard at `http://mycompany.com:32100/`. + +1. Log in to Grafana dashboard with username: admin and password: admin`. + +1. Navigate to + (Create) -> Import -> Upload the `weblogic-server-dashboard-import.json` file (provided at `${WORKDIR}/monitoring-service/config/weblogic-server-dashboard-import.json`). + + +## Set up using `setup-monitoring.sh` + +Alternatively, you can run the helper script `setup-monitoring.sh` available at `${WORKDIR}/monitoring-service` to setup the monitoring for OracleWebCenterPortal domain. + +This script creates kube-prometheus-stack(Prometheus, Grafana and Alertmanager), WebLogic Monitoring Exporter and imports `weblogic-server-dashboard.json` into Grafana for WebLogic Server Dashboard. + +### Prepare to use the setup monitoring script + +The sample scripts for setup monitoring for OracleWebCenterPortal domain are available at `${WORKDIR}/monitoring-service`. + +You must edit `monitoring-inputs.yaml`(or a copy of it) to provide the details of your domain. Refer to the configuration parameters below to understand the information that you must provide in this file. + +#### Configuration parameters + +The following parameters can be provided in the inputs file. + +| Parameter | Description | Default | +| --- | --- | --- | +| `domainUID` | domainUID of the OracleWebCenterPortal domain. | `wcp-domain` | +| `domainNamespace` | Kubernetes namespace of the OracleWebCenterPortal domain. | `wcpns` | +| `setupKubePrometheusStack` | Boolean value indicating whether kube-prometheus-stack (Prometheus, Grafana and Alertmanager) to be installed | `true` | +| `additionalParamForKubePrometheusStack` | The script install's kube-prometheus-stack with `service.type` as NodePort and values for `service.nodePort` as per the parameters defined in `monitoring-inputs.yaml`. Use `additionalParamForKubePrometheusStack` parameter to further configure with additional parameters as per [values.yaml](https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml). Sample value to disable NodeExporter, Prometheus-Operator TLS support and Admission webhook support for PrometheusRules resources is `--set nodeExporter.enabled=false --set prometheusOperator.tls.enabled=false --set prometheusOperator.admissionWebhooks.enabled=false`| | +| `monitoringNamespace` | Kubernetes namespace for monitoring setup. | `monitoring` | +| `adminServerName` | Name of the Administration Server. | `AdminServer` | +| `adminServerPort` | Port number for the Administration Server inside the Kubernetes cluster. | `7001` | +| `wcpClusterName` | Name of the wcpCluster. | `wcp-cluster` | +| `wcpManagedServerPort` | Port number of the managed servers in the wcpCluster. | `8888` | +| `wlsMonitoringExporterTowcpCluster` | Boolean value indicating whether to deploy WebLogic Monitoring Exporter to wcpCluster. | `false` | +| `wcpPortletClusterName` | Name of the wcpPortletCluster. | `wcportlet-cluster` | +| `wcpPortletManagedServerPort` | Port number of the managed servers in the wcpPortletCluster. | `8889` | +| `wlsMonitoringExporterTowcpPortletCluster` | Boolean value indicating whether to deploy WebLogic Monitoring Exporter to wcpPortletCluster. | `false` | +| `exposeMonitoringNodePort` | Boolean value indicating if the Monitoring Services (Prometheus, Grafana and Alertmanager) is exposed outside of the Kubernetes cluster. | `false` | +| `prometheusNodePort` | Port number of the Prometheus outside the Kubernetes cluster. | `32101` | +| `grafanaNodePort` | Port number of the Grafana outside the Kubernetes cluster. | `32100` | +| `alertmanagerNodePort` | Port number of the Alertmanager outside the Kubernetes cluster. | `32102` | +| `weblogicCredentialsSecretName` | Name of the Kubernetes secret which has Administration Server’s user name and password. | `wcp-domain-domain-credentials` | + +Note that the values specified in the `monitoring-inputs.yaml` file will be used to install kube-prometheus-stack (Prometheus, Grafana and Alertmanager) and deploying WebLogic Monitoring Exporter into the OracleWebCenterPortal domain. Hence make the domain specific values to be same as that used during domain creation. + +### Run the setup monitoring script + +Update the values in `monitoring-inputs.yaml` as per your requirement and run the `setup-monitoring.sh` script, specifying your inputs file: + +```bash +$ cd ${WORKDIR}/monitoring-service +$ ./setup-monitoring.sh \ + -i monitoring-inputs.yaml +``` +The script will perform the following steps: + +- Helm install `prometheus-community/kube-prometheus-stack` of version "16.5.0" if `setupKubePrometheusStack` is set to `true`. +- Deploys WebLogic Monitoring Exporter to Administration Server. +- Deploys WebLogic Monitoring Exporter to `wcpCluster` if `wlsMonitoringExporterTowcpCluster` is set to `true`. +- Deploys WebLogic Monitoring Exporter to `wcpPortletCluster` if `wlsMonitoringExporterTowcpPortletCluster` is set to `true`. +- Exposes the Monitoring Services (Prometheus at `32101`, Grafana at `32100` and Alertmanager at `32102`) outside of the Kubernetes cluster if `exposeMonitoringNodePort` is set to `true`. +- Imports the WebLogic Server Grafana Dashboard if `setupKubePrometheusStack` is set to `true`. + +### Verify the results +The setup monitoring script will report failure if there was any error. However, verify that required resources were created by the script. + +#### Verify the kube-prometheus-stack + +To confirm that `prometheus-community/kube-prometheus-stack` was installed when `setupKubePrometheusStack` is set to `true`, run the following command: + +```bash +$ helm ls -n +``` +Replace with value for Kubernetes namespace used for monitoring. + +Sample output: +```bash +$ helm ls -n monitoring +NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION +monitoring monitoring 1 2021-06-18 12:58:35.177221969 +0000 UTC deployed kube-prometheus-stack-16.5.0 0.48.0 +$ +``` + +#### Verify the Prometheus, Grafana and Alertmanager setup + +When `exposeMonitoringNodePort` was set to `true`, verify that monitoring services are accessible outside of the Kubernetes cluster: + +- `32100` is the external port for Grafana and with credentials `admin:admin` +- `32101` is the external port for Prometheus +- `32102` is the external port for Alertmanager + +#### Verify the service discovery of WebLogic Monitoring Exporter + +Verify whether prometheus is able to discover wls-exporter and collect the metrics: + +1. Access the Prometheus dashboard at http://mycompany.com:32101/ + +1. Navigate to Status to see the Service Discovery details. + +1. Verify that wls-exporter is listed in the discovered services. + +#### Verify the WebLogic Server dashoard + +You can access the Grafana dashboard at http://mycompany.com:32100/. + +1. Log in to Grafana dashboard with username: `admin` and password: `admin`. + +1. Navigate to "WebLogic Server Dashboard" under General and verify. + +### Delete the monitoring setup + +To delete the monitoring setup created by [Run the setup monitoring script](#run-the-setup-monitoring-script), run the below command: + +```bash +$ cd ${WORKDIR}/monitoring-service +$ ./delete-monitoring.sh \ + -i monitoring-inputs.yaml +``` + diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/config_as.yml b/OracleWebCenterPortal/kubernetes/monitoring-service/config/config.yml.template old mode 100755 new mode 100644 similarity index 98% rename from OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/config_as.yml rename to OracleWebCenterPortal/kubernetes/monitoring-service/config/config.yml.template index df8248388..792f64d27 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/config_as.yml +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/config/config.yml.template @@ -1,8 +1,8 @@ # Copyright (c) 2021, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - +# metricsNameSnakeCase: true -restPort: 7001 +restPort: %PORT% queries: - key: name keyName: location @@ -18,26 +18,26 @@ queries: servlets: prefix: wls_servlet_ key: servletName - + - JVMRuntime: prefix: wls_jvm_ key: name - + - executeQueueRuntimes: prefix: wls_socketmuxer_ key: name values: [pendingRequestCurrentCount] - + - workManagerRuntimes: prefix: wls_workmanager_ key: name values: [stuckThreadCount, pendingRequests, completedRequests] - + - threadPoolRuntime: prefix: wls_threadpool_ key: name values: [executeThreadTotalCount, queueLength, stuckThreadCount, hoggingThreadCount] - + - JMSRuntime: key: name keyName: jmsruntime @@ -50,7 +50,7 @@ queries: prefix: wls_jms_dest_ key: name keyName: destination - + - persistentStoreRuntimes: prefix: wls_persistentstore_ key: name @@ -61,3 +61,4 @@ queries: - JTARuntime: prefix: wls_jta_ key: name + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic-server-dashboard-import.json b/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic-server-dashboard-import.json new file mode 100644 index 000000000..c2fa9e2eb --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic-server-dashboard-import.json @@ -0,0 +1,3312 @@ +{ + "__inputs": [], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.4" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "singlestat", + "name": "Singlestat", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1563266678971, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 32, + "panels": [], + "title": "Servers", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 0, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 13, + "x": 0, + "y": 1 + }, + "hideTimeOverride": true, + "id": 16, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "count(count (wls_jvm_uptime{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\"}) by (name))", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Running Servers", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 11, + "x": 13, + "y": 1 + }, + "id": 23, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "count(count(wls_webapp_config_deployment_state{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\"}) by (app))", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Deployed Applications", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 1, + "description": "", + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 0, + "y": 4 + }, + "hideTimeOverride": true, + "id": 104, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "weblogic_serverName", + "targets": [ + { + "expr": "wls_server_activation_time{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\",weblogic_serverName=\"$serverName\"}", + "format": "table", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Server Name", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#56A64B", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 6, + "y": 4 + }, + "id": 84, + "interval": "", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "wls_server_state_val{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Server Status", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "SHUTDOWN", + "value": "0" + }, + { + "op": "=", + "text": "STARTING", + "value": "1" + }, + { + "op": "=", + "text": "RUNNING", + "value": "2" + }, + { + "op": "=", + "text": "STANDBY", + "value": "3" + }, + { + "op": "=", + "text": "FAILED", + "value": "8" + }, + { + "op": "=", + "text": "FAILED", + "value": "17" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 1, + "description": "", + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": true, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 10, + "y": 4 + }, + "hideTimeOverride": true, + "id": 27, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "instance", + "targets": [ + { + "expr": "100 - wls_jvm_heap_free_percent{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Heap Usage", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorPostfix": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 1, + "description": "", + "format": "ms", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 14, + "y": 4 + }, + "hideTimeOverride": true, + "id": 91, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "instance", + "targets": [ + { + "expr": "wls_jvm_uptime{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Running Time", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorPostfix": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 0, + "description": "", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 19, + "y": 4 + }, + "hideTimeOverride": true, + "id": 96, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "instance", + "targets": [ + { + "expr": "wls_server_open_sockets_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Open Sockets", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "aliasColors": { + " heap free managed-server-1": "super-light-green", + " heap free managed-server-2": "dark-green", + "heap size managed-server-1 ": "super-light-red", + "heap size managed-server-2 ": "dark-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 12, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_jvm_heap_free_current{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " Heap Free ()", + "refId": "B" + }, + { + "expr": "wls_jvm_heap_size_current{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "legendFormat": "Heap Size ()", + "refId": "A" + }, + { + "expr": "wls_jvm_heap_size_max{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 1, + "legendFormat": "Heap Max ()", + "refId": "C" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "JVM Heap", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + " heap free managed-server-1": "super-light-green", + " heap free managed-server-2": "dark-green", + "heap size managed-server-1 ": "super-light-red", + "heap size managed-server-2 ": "dark-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 17 + }, + "id": 21, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_jvm_process_cpu_load{weblogic_domainUID=~\"$domainName\", weblogic_clusterName=~\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"} * 100", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " ", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU Load", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 17 + }, + "id": 10, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_threadpool_execute_thread_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Total Threads ()", + "refId": "A" + }, + { + "expr": "wls_threadpool_stuck_thread_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Stuck Threads ()", + "refId": "D" + }, + { + "expr": "wls_threadpool_queue_length{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 1, + "legendFormat": "queue", + "refId": "C" + }, + { + "expr": "wls_threadpool_hogging_thread_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 1, + "legendFormat": "hogging", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Thread Pool", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 35, + "panels": [ + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 28 + }, + "hideTimeOverride": true, + "id": 126, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 13, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Webapp", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "app", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total Sessions", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "topk($topN,sum(wls_webapp_config_sessions_opened_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app))", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Sessions (top $topN)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 28 + }, + "hideTimeOverride": true, + "id": 136, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 13, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Webapp", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "app", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total Requests", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "topk($topN,sum(wls_servlet_invocation_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app))", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Requests (top $topN)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 28 + }, + "hideTimeOverride": true, + "id": 134, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 13, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Webapp", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "app", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total Time", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "topk($topN,sum(wls_servlet_execution_time_total{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app))", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Execution Time (top $topN)", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 35 + }, + "id": 14, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_webapp_config_open_sessions_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app)", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + }, + { + "expr": "", + "format": "time_series", + "intervalFactor": 1, + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Current Sessions ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 35 + }, + "id": 128, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": " sum(irate(wls_webapp_config_sessions_opened_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (app)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Session Rate ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "per second", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 43 + }, + "id": 132, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "(sum(wls_servlet_execution_time_average{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app)) / (count(wls_servlet_execution_time_average{weblogic_domainUID=\"domain1\", weblogic_clusterName=\"cluster-1\"}) by (app))", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Execution Time per Request ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 43 + }, + "id": 138, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_servlet_invocation_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (app)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Request Rate ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "per second", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "title": "Web Applications", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 43, + "panels": [ + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 29 + }, + "hideTimeOverride": true, + "id": 111, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Server", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "weblogic_serverName", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Name", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Active Connections", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #A", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Current Capacity", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #C", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Connections", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Connections", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "sum(wls_datasource_curr_capacity{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName,name)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "C" + }, + { + "expr": "sum(wls_datasource_active_connections_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName,name)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "A" + }, + { + "expr": "sum(wls_datasource_connections_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName,name)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "D" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Overview", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 13, + "x": 0, + "y": 33 + }, + "id": 50, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_datasource_active_connections_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Active Connections", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 11, + "x": 13, + "y": 33 + }, + "id": 71, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(wls_datasource_connections_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Connection Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "per second", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 9, + "w": 11, + "x": 0, + "y": 41 + }, + "id": 46, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_datasource_waiting_for_connection_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Pending Connection Requests", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 9, + "w": 13, + "x": 11, + "y": 41 + }, + "id": 73, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_datasource_connection_delay_time{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Average Connection Delay Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "title": "Data Sources", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 26 + }, + "id": 40, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 30 + }, + "id": 145, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_jmsruntime_connections_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "JMS Connections", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 30 + }, + "id": 147, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_jmsruntime_connections_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (weblogic_serverName)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "JMS Connection Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 36 + }, + "hideTimeOverride": true, + "id": 113, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Name", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "jmsserver", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Current Dests", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #B", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #A", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "Total Dests", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #E", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "sum(wls_jms_destinations_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + }, + { + "expr": "sum(wls_jms_messages_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "A" + }, + { + "expr": "sum(wls_jms_bytes_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "D" + }, + { + "expr": "sum(wls_jms_destinations_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "E" + }, + { + "expr": "sum(wls_jms_destinations_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "F" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "JMSServer Overview", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 40 + }, + "id": 54, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_jms_messages_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Current ()", + "refId": "A" + }, + { + "expr": "sum(wls_jms_messages_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Pending ()", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Messages", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 40 + }, + "id": 56, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_jms_bytes_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Current ()", + "refId": "A" + }, + { + "expr": "sum(wls_jms_bytes_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Pending ()", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Bytes", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 47 + }, + "id": 58, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_jms_messages_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Received Message Rate ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 47 + }, + "id": 117, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_jms_bytes_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Received Byte Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 54 + }, + "hideTimeOverride": true, + "id": 119, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": false + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Destination", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "destination", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Current Consumers", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #A", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Current Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #B", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Pending Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #C", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Currrent Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "Pending Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #E", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #F", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #G", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "sum(wls_jms_dest_consumers_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "A" + }, + { + "expr": "sum(wls_jms_dest_messages_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + }, + { + "expr": "sum(wls_jms_dest_messages_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "C" + }, + { + "expr": "sum(wls_jms_dest_bytes_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "D" + }, + { + "expr": "sum(wls_jms_dest_bytes_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "E" + }, + { + "expr": "sum(wls_jms_dest_messages_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "interval": "", + "intervalFactor": 1, + "refId": "F" + }, + { + "expr": "sum(wls_jms_dest_bytes_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "G" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Destinations Overview", + "transform": "table", + "type": "table" + } + ], + "title": "JMS Services", + "type": "row" + } + ], + "refresh": false, + "schemaVersion": 16, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "text": "prometheus", + "value": "prometheus" + }, + "hide": 0, + "label": null, + "name": "datasource", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "allValue": null, + "current": {}, + "datasource": "$datasource", + "hide": 0, + "includeAll": false, + "label": "Domain", + "multi": false, + "name": "domainName", + "options": [], + "query": "label_values(weblogic_domainUID)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "$datasource", + "hide": 0, + "includeAll": false, + "label": "Cluster", + "multi": false, + "name": "clusterName", + "options": [], + "query": "label_values(wls_jvm_uptime{weblogic_domainUID=\"$domainName\"},weblogic_clusterName)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "label": "Server", + "multi": true, + "name": "serverName", + "options": [], + "query": "label_values(wls_jvm_uptime{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\"},weblogic_serverName)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "selected": false, + "tags": [], + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": "Top N", + "multi": false, + "name": "topN", + "options": [ + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": true, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "7", + "value": "7" + }, + { + "selected": false, + "text": "10", + "value": "10" + } + ], + "query": "3, 5, 7, 10", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "WebLogic Server Dashboard", + "uid": "5yUwzbZWz", + "version": 6 +} diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic-server-dashboard.json b/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic-server-dashboard.json new file mode 100644 index 000000000..cf6d5f776 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic-server-dashboard.json @@ -0,0 +1,3315 @@ +{ + "dashboard": { + "__inputs": [], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.4" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "singlestat", + "name": "Singlestat", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1563266678971, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 32, + "panels": [], + "title": "Servers", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 0, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 13, + "x": 0, + "y": 1 + }, + "hideTimeOverride": true, + "id": 16, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "count(count (wls_jvm_uptime{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\"}) by (name))", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Running Servers", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 11, + "x": 13, + "y": 1 + }, + "id": 23, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "count(count(wls_webapp_config_deployment_state{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\"}) by (app))", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Deployed Applications", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 1, + "description": "", + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 0, + "y": 4 + }, + "hideTimeOverride": true, + "id": 104, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "weblogic_serverName", + "targets": [ + { + "expr": "wls_server_activation_time{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\",weblogic_serverName=\"$serverName\"}", + "format": "table", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Server Name", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#56A64B", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 6, + "y": 4 + }, + "id": 84, + "interval": "", + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "wls_server_state_val{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Server Status", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "SHUTDOWN", + "value": "0" + }, + { + "op": "=", + "text": "STARTING", + "value": "1" + }, + { + "op": "=", + "text": "RUNNING", + "value": "2" + }, + { + "op": "=", + "text": "STANDBY", + "value": "3" + }, + { + "op": "=", + "text": "FAILED", + "value": "8" + }, + { + "op": "=", + "text": "FAILED", + "value": "17" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 1, + "description": "", + "format": "percent", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": true, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 10, + "y": 4 + }, + "hideTimeOverride": true, + "id": 27, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "instance", + "targets": [ + { + "expr": "100 - wls_jvm_heap_free_percent{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Heap Usage", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorPostfix": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 1, + "description": "", + "format": "ms", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 14, + "y": 4 + }, + "hideTimeOverride": true, + "id": 91, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "instance", + "targets": [ + { + "expr": "wls_jvm_uptime{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Running Time", + "type": "singlestat", + "valueFontSize": "50%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorPostfix": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "$datasource", + "decimals": 0, + "description": "", + "format": "short", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 5, + "x": 19, + "y": 4 + }, + "hideTimeOverride": true, + "id": 96, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "repeat": "serverName", + "repeatDirection": "v", + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "instance", + "targets": [ + { + "expr": "wls_server_open_sockets_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=\"$serverName\"}", + "format": "time_series", + "hide": false, + "instant": true, + "interval": "10s", + "intervalFactor": 2, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "50,80", + "timeFrom": null, + "timeShift": null, + "title": "Open Sockets", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "", + "value": "" + } + ], + "valueName": "current" + }, + { + "aliasColors": { + " heap free managed-server-1": "super-light-green", + " heap free managed-server-2": "dark-green", + "heap size managed-server-1 ": "super-light-red", + "heap size managed-server-2 ": "dark-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 12, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_jvm_heap_free_current{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " Heap Free ()", + "refId": "B" + }, + { + "expr": "wls_jvm_heap_size_current{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "legendFormat": "Heap Size ()", + "refId": "A" + }, + { + "expr": "wls_jvm_heap_size_max{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 1, + "legendFormat": "Heap Max ()", + "refId": "C" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "JVM Heap", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": { + " heap free managed-server-1": "super-light-green", + " heap free managed-server-2": "dark-green", + "heap size managed-server-1 ": "super-light-red", + "heap size managed-server-2 ": "dark-red" + }, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 17 + }, + "id": 21, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_jvm_process_cpu_load{weblogic_domainUID=~\"$domainName\", weblogic_clusterName=~\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"} * 100", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " ", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU Load", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 17 + }, + "id": 10, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_threadpool_execute_thread_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Total Threads ()", + "refId": "A" + }, + { + "expr": "wls_threadpool_stuck_thread_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Stuck Threads ()", + "refId": "D" + }, + { + "expr": "wls_threadpool_queue_length{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 1, + "legendFormat": "queue", + "refId": "C" + }, + { + "expr": "wls_threadpool_hogging_thread_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 1, + "legendFormat": "hogging", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Thread Pool", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 35, + "panels": [ + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 28 + }, + "hideTimeOverride": true, + "id": 126, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 13, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Webapp", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "app", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total Sessions", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "topk($topN,sum(wls_webapp_config_sessions_opened_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app))", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Sessions (top $topN)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 28 + }, + "hideTimeOverride": true, + "id": 136, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 13, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Webapp", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "app", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total Requests", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "topk($topN,sum(wls_servlet_invocation_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app))", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Requests (top $topN)", + "transform": "table", + "type": "table" + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 28 + }, + "hideTimeOverride": true, + "id": 134, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 13, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Webapp", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "app", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Total Time", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value", + "thresholds": [], + "type": "number", + "unit": "ms" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "topk($topN,sum(wls_servlet_execution_time_total{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app))", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Execution Time (top $topN)", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 35 + }, + "id": 14, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_webapp_config_open_sessions_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app)", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + }, + { + "expr": "", + "format": "time_series", + "intervalFactor": 1, + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Current Sessions ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 35 + }, + "id": 128, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": " sum(irate(wls_webapp_config_sessions_opened_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (app)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Session Rate ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "per second", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 43 + }, + "id": 132, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "(sum(wls_servlet_execution_time_average{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (app)) / (count(wls_servlet_execution_time_average{weblogic_domainUID=\"domain1\", weblogic_clusterName=\"cluster-1\"}) by (app))", + "format": "time_series", + "interval": "", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Execution Time per Request ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 43 + }, + "id": 138, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_servlet_invocation_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (app)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Request Rate ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "per second", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "title": "Web Applications", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 43, + "panels": [ + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 29 + }, + "hideTimeOverride": true, + "id": 111, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Server", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "weblogic_serverName", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Name", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "name", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Active Connections", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #A", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Current Capacity", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #C", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Connections", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Connections", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "sum(wls_datasource_curr_capacity{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName,name)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "C" + }, + { + "expr": "sum(wls_datasource_active_connections_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName,name)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "A" + }, + { + "expr": "sum(wls_datasource_connections_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName,name)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "D" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Overview", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 13, + "x": 0, + "y": 33 + }, + "id": 50, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_datasource_active_connections_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Active Connections", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 8, + "w": 11, + "x": 13, + "y": 33 + }, + "id": 71, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "irate(wls_datasource_connections_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Connection Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "per second", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 9, + "w": 11, + "x": 0, + "y": 41 + }, + "id": 46, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_datasource_waiting_for_connection_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Pending Connection Requests", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 9, + "w": 13, + "x": 11, + "y": 41 + }, + "id": 73, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "wls_datasource_connection_delay_time{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": " @ ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Average Connection Delay Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "title": "Data Sources", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 26 + }, + "id": 40, + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 30 + }, + "id": 145, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_jmsruntime_connections_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (weblogic_serverName)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "JMS Connections", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 30 + }, + "id": 147, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_jmsruntime_connections_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (weblogic_serverName)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "JMS Connection Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 4, + "w": 24, + "x": 0, + "y": 36 + }, + "hideTimeOverride": true, + "id": 113, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 0, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Name", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "jmsserver", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Current Dests", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #B", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #A", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "Total Dests", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #E", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "sum(wls_jms_destinations_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + }, + { + "expr": "sum(wls_jms_messages_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "A" + }, + { + "expr": "sum(wls_jms_bytes_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "D" + }, + { + "expr": "sum(wls_jms_destinations_total_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "E" + }, + { + "expr": "sum(wls_jms_destinations_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "F" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "JMSServer Overview", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 40 + }, + "id": 54, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_jms_messages_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Current ()", + "refId": "A" + }, + { + "expr": "sum(wls_jms_messages_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Pending ()", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Messages", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 40 + }, + "id": 56, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(wls_jms_bytes_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Current ()", + "refId": "A" + }, + { + "expr": "sum(wls_jms_bytes_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "Pending ()", + "refId": "B" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Bytes", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 47 + }, + "id": 58, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_jms_messages_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Received Message Rate ", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": true, + "dashLength": 10, + "dashes": false, + "datasource": "$datasource", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 47 + }, + "id": 117, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "paceLength": 10, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(irate(wls_jms_bytes_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}[5m])) by (jmsserver)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Received Byte Rate", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "columns": [], + "datasource": "$datasource", + "fontSize": "100%", + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 54 + }, + "hideTimeOverride": true, + "id": 119, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 3, + "desc": false + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "Destination", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "destination", + "thresholds": [], + "type": "string", + "unit": "short" + }, + { + "alias": "Current Consumers", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #A", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Current Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #B", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Pending Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #C", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Currrent Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #D", + "thresholds": [], + "type": "number", + "unit": "bytes" + }, + { + "alias": "Pending Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #E", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Msgs", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #F", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "Total Bytes", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 0, + "mappingType": 1, + "pattern": "Value #G", + "thresholds": [], + "type": "number", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "decimals": 2, + "pattern": "/.*/", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "sum(wls_jms_dest_consumers_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "A" + }, + { + "expr": "sum(wls_jms_dest_messages_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "B" + }, + { + "expr": "sum(wls_jms_dest_messages_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "C" + }, + { + "expr": "sum(wls_jms_dest_bytes_current_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "D" + }, + { + "expr": "sum(wls_jms_dest_bytes_pending_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "E" + }, + { + "expr": "sum(wls_jms_dest_messages_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "interval": "", + "intervalFactor": 1, + "refId": "F" + }, + { + "expr": "sum(wls_jms_dest_bytes_received_count{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\", weblogic_serverName=~\"${serverName:regex}\"}) by (destination)", + "format": "table", + "instant": true, + "intervalFactor": 1, + "refId": "G" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Destinations Overview", + "transform": "table", + "type": "table" + } + ], + "title": "JMS Services", + "type": "row" + } + ], + "refresh": false, + "schemaVersion": 16, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "text": "prometheus", + "value": "prometheus" + }, + "hide": 0, + "label": null, + "name": "datasource", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "allValue": null, + "current": {}, + "datasource": "$datasource", + "hide": 0, + "includeAll": false, + "label": "Domain", + "multi": false, + "name": "domainName", + "options": [], + "query": "label_values(weblogic_domainUID)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "$datasource", + "hide": 0, + "includeAll": false, + "label": "Cluster", + "multi": false, + "name": "clusterName", + "options": [], + "query": "label_values(wls_jvm_uptime{weblogic_domainUID=\"$domainName\"},weblogic_clusterName)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "label": "Server", + "multi": true, + "name": "serverName", + "options": [], + "query": "label_values(wls_jvm_uptime{weblogic_domainUID=\"$domainName\", weblogic_clusterName=\"$clusterName\"},weblogic_serverName)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": { + "selected": false, + "tags": [], + "text": "5", + "value": "5" + }, + "hide": 0, + "includeAll": false, + "label": "Top N", + "multi": false, + "name": "topN", + "options": [ + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": true, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "7", + "value": "7" + }, + { + "selected": false, + "text": "10", + "value": "10" + } + ], + "query": "3, 5, 7, 10", + "skipUrlSync": false, + "type": "custom" + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "hidden": false, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "WebLogic Server Dashboard", + "uid": "5yUwzbZWz", + "version": 6 + } +} + diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/weblogic.xml b/OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic.xml old mode 100755 new mode 100644 similarity index 100% rename from OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/config/weblogic.xml rename to OracleWebCenterPortal/kubernetes/monitoring-service/config/weblogic.xml diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/delete-monitoring.sh b/OracleWebCenterPortal/kubernetes/monitoring-service/delete-monitoring.sh new file mode 100644 index 000000000..eee881c77 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/delete-monitoring.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# delete-monitoring.sh + +# Initialize +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +OLD_PWD=`pwd` + + +# +## Function to exit and print an error message +## $1 - text of message +function fail { + printError $* + exit 1 +} + +# Function to print an error message +function removeFileIfExists { + echo "input is $1" + if [ -f $1 ]; then + rm -f $1 + fi +} + +function exitIfError { + if [ "$1" != "0" ]; then + echo "$2" + exit $1 + fi +} +# +# Function to parse a yaml file and generate the bash exports +# $1 - Input filename +# $2 - Output filename +function parseYaml { + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ + -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + awk -F$fs '{ + if (length($3) > 0) { + # javaOptions may contain tokens that are not allowed in export command + # we need to handle it differently. + if ($2=="javaOptions") { + printf("%s=%s\n", $2, $3); + } else { + printf("export %s=\"%s\"\n", $2, $3); + } + } + }' > $2 +} + +function usage { + echo usage: ${script} -i file [-v] [-h] + echo " -i Parameter inputs file, must be specified." + echo " -h Help" + exit $1 +} + + +function deletePrometheusGrafana { + helm delete ${monitoringNamespace} --namespace ${monitoringNamespace} +} + +#Parse the inputs +while getopts "hi:" opt; do + case $opt in + i) valuesInputFile="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${valuesInputFile} ]; then + echo "${script}: -i must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +if [ ! -f ${valuesInputFile} ]; then + echo "Unable to locate the input parameters file ${valuesInputFile}" + fail 'The error listed above must be resolved before the script can continue' +fi + +exportValuesFile=$(mktemp /tmp/export-values-XXXXXXXXX.sh) +parseYaml ${valuesInputFile} ${exportValuesFile} + + +source ${exportValuesFile} +rm ${exportValuesFile} + +# Setting up the WebLogic Monitoring Exporter + +echo "Undeploy WebLogic Monitoring Exporter started" +serviceMonitor=${scriptDir}/manifests/wls-exporter-ServiceMonitor.yaml +kubectl delete --ignore-not-found=true -f ${serviceMonitor} +script=${scriptDir}/scripts/undeploy-weblogic-monitoring-exporter.sh +sh ${script} +if [ "$?" != "0" ]; then + echo "ERROR: $script failed." + echo "Undeploy WebLogic Monitoring Exporter completed with errors. Review the logs and rerun" +else + echo "Undeploy WebLogic Monitoring Exporter completed." +fi + +if [ "${setupKubePrometheusStack}" = "true" ]; then + echo "Deleting Prometheus and grafana started" + deletePrometheusGrafana + echo "Deleting Prometheus and grafana completed" +fi +cd $OLD_PWD + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/prometheus-roleBinding-domain-namespace.yaml b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/prometheus-roleBinding-domain-namespace.yaml new file mode 100644 index 000000000..98e23c3ea --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/prometheus-roleBinding-domain-namespace.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: rbac.authorization.k8s.io/v1 +items: +- apiVersion: rbac.authorization.k8s.io/v1 + kind: RoleBinding + metadata: + name: prometheus-k8s + namespace: wcpns + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: prometheus-k8s + subjects: + - kind: ServiceAccount + name: prometheus-k8s + namespace: monitoring +kind: RoleBindingList + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/prometheus-roleSpecific-domain-namespace.yaml b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/prometheus-roleSpecific-domain-namespace.yaml new file mode 100644 index 000000000..aab147753 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/prometheus-roleSpecific-domain-namespace.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: rbac.authorization.k8s.io/v1 +items: +- apiVersion: rbac.authorization.k8s.io/v1 + kind: Role + metadata: + name: prometheus-k8s + namespace: wcpns + rules: + - apiGroups: + - "" + resources: + - services + - endpoints + - pods + verbs: + - get + - list + - watch +kind: RoleList + diff --git a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/wls-exporter.yaml b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml old mode 100755 new mode 100644 similarity index 90% rename from OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/wls-exporter.yaml rename to OracleWebCenterPortal/kubernetes/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml index 075afa320..0d54521e7 --- a/OracleWebCenterPortal/kubernetes/create-wcp-domain/utils/weblogic-monitoring-exporter/wls-exporter.yaml +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml @@ -1,20 +1,20 @@ # Copyright (c) 2021, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. - +# apiVersion: v1 kind: Secret metadata: name: basic-auth namespace: monitoring data: - password: d2VsY29tZTEK # welcome1 i.e.'WebLogic password' + password: V2VsY29tZTE= # Welcome1 i.e.'WebLogic password' user: d2VibG9naWM= # weblogic i.e. 'WebLogic username' type: Opaque --- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: - name: wls-exporter-wcp-domain + name: wls-exporter namespace: monitoring labels: k8s-app: wls-exporter @@ -40,3 +40,4 @@ spec: interval: 10s honorLabels: true path: /wls-exporter/metrics + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml.template b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml.template new file mode 100644 index 000000000..63328f19d --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/manifests/wls-exporter-ServiceMonitor.yaml.template @@ -0,0 +1,44 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +apiVersion: v1 +kind: Secret +metadata: + name: basic-auth + namespace: wcpns +data: + password: %PASSWORD% + user: %USERNAME% +type: Opaque +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: wls-exporter + namespace: wcpns + labels: + k8s-app: wls-exporter + release: monitoring +spec: + namespaceSelector: + matchNames: + - wcpns + selector: + matchLabels: + weblogic.domainName: wcp-domain + endpoints: + - basicAuth: + password: + name: basic-auth + key: password + username: + name: basic-auth + key: user + port: default + relabelings: + - action: labelmap + regex: __meta_kubernetes_service_label_(.+) + interval: 10s + honorLabels: true + path: /wls-exporter/metrics + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/monitoring-inputs.yaml b/OracleWebCenterPortal/kubernetes/monitoring-service/monitoring-inputs.yaml new file mode 100644 index 000000000..a2b3c6647 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/monitoring-inputs.yaml @@ -0,0 +1,64 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# The version of this inputs file. Do not modify. +version: create-wcp-domain-monitoring-inputs-v1 + +# Unique ID identifying your domain. +# This ID must not contain an underscope ("_"), and must be lowercase and unique across all domains in a Kubernetes cluster. +domainUID: wcp-domain + +# Name of the domain namespace +domainNamespace: wcpns + +# Boolean value indicating whether to install kube-prometheus-stack +setupKubePrometheusStack: true + +# Additional parameters for helm install kube-prometheus-stack +# Refer https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml for additional parameters +# Sample : +# additionalParamForKubePrometheusStack: --set nodeExporter.enabled=false --set prometheusOperator.tls.enabled=false --set prometheusOperator.admissionWebhooks.enabled=false +additionalParamForKubePrometheusStack: + +# Name of the monitoring namespace +monitoringNamespace: monitoring + +# Name of the Admin Server +adminServerName: AdminServer +# +# Port number for admin server +adminServerPort: 7001 + +# Cluster name +wcpClusterName: wcp-cluster + +# Port number for managed server +wcpManagedServerPort: 8888 + +# WebLogic Monitoring Exporter to Cluster +wlsMonitoringExporterTowcpCluster: false + +# Portlet Cluster name +wcpPortletClusterName: wcportlet-cluster + +# Port number for Portlet managed server +wcpPortletManagedServerPort: 8889 + +# WebLogic Monitoring Exporter to PortletCluster +wlsMonitoringExporterTowcpPortletCluster: false + +# Boolean to indicate if the adminNodePort will be exposed +exposeMonitoringNodePort: false + +# NodePort to expose Prometheus +prometheusNodePort: 32101 + +# NodePort to expose Grafana +grafanaNodePort: 32100 + +# NodePort to expose Alertmanager +alertmanagerNodePort: 32102 + +# Name of the Kubernetes secret for the Admin Server's username and password +weblogicCredentialsSecretName: wcp-domain-domain-credentials + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/deploy-weblogic-monitoring-exporter.py b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/deploy-weblogic-monitoring-exporter.py new file mode 100644 index 000000000..ebc5d0932 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/deploy-weblogic-monitoring-exporter.py @@ -0,0 +1,105 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +import sys +#======================================================= +# Function for fresh plain deployment +#======================================================= +def newDeploy(appName,target): + try: + print 'Deploying .........' + deploy(appName,'/u01/oracle/wls-exporter-deploy/'+appName+'.war', target, upload="true",remote="true") + startApplication(appName) + except Exception, ex: + print ex.toString() + +#======================================================== +# Main program here... +# Target you can change as per your need +#======================================================== + +def usage(): + argsList = ' -domainName -adminServerName -adminURL -username -password ' + argsList=argsList + ' -wcpClusterName ' + ' -wlsMonitoringExporterTowcpCluster ' + argsList=argsList + ' -wcpPortletClusterName ' + ' -wlsMonitoringExporterTowcpPortletCluster ' + print sys.argv[0] + argsList + sys.exit(0) + +if len(sys.argv) < 1: + usage() + +# domainName will be passed by command line parameter -domainName. +domainName = "wcp-domain" + +# adminServerName will be passed by command line parameter -adminServerName +adminServerName = "AdminServer" + +# adminURL will be passed by command line parameter -adminURL +adminURL = "wcp-domain-adminserver:7001" + +# wcpClusterName will be passed by command line parameter -wcpClusterName +wcpClusterName = "wcp-cluster" + +# wlsMonitoringExporterTowcpCluster will be passed by command line parameter -wlsMonitoringExporterTowcpCluster +wlsMonitoringExporterTowcpCluster = "false" + + +# wcpPortletClusterName will be passed by command line parameter -wcpPortletClusterName +wcpPortletClusterName = "wcportlet-cluster" + +# wlsMonitoringExporterTowcpPortletCluster will be passed by command line parameter -wlsMonitoringExporterTowcpPortletCluster +wlsMonitoringExporterTowcpPortletCluster = "false" + +# username will be passed by command line parameter -username +username = "weblogic" + +# password will be passed by command line parameter -password +password = "Welcome1" + +i=1 +while i < len(sys.argv): + if sys.argv[i] == '-domainName': + domainName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-adminServerName': + adminServerName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-adminURL': + adminURL = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-username': + username = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-password': + password = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wcpClusterName': + wcpClusterName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wlsMonitoringExporterTowcpCluster': + wlsMonitoringExporterTowcpCluster = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wcpPortletClusterName': + wcpPortletClusterName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wlsMonitoringExporterTowcpPortletCluster': + wlsMonitoringExporterTowcpPortletCluster = sys.argv[i+1] + i += 2 + else: + print 'Unexpected argument switch at position ' + str(i) + ': ' + str(sys.argv[i]) + usage() + sys.exit(1) + +# Deployment +connect(username, password, 't3://' + adminURL) +cd('AppDeployments') +newDeploy('wls-exporter-adminserver',adminServerName) +if 'true' == wlsMonitoringExporterTowcpCluster: + newDeploy('wls-exporter-wcp',wcpClusterName) + +if 'true' == wlsMonitoringExporterTowcpPortletCluster: + newDeploy('wls-exporter-wcpPortlet',wcpPortletClusterName) + +disconnect() +exit() + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/deploy-weblogic-monitoring-exporter.sh b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/deploy-weblogic-monitoring-exporter.sh new file mode 100644 index 000000000..32895973a --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/deploy-weblogic-monitoring-exporter.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Initialize +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +warDir=$PWD +source ${scriptDir}/utils.sh + +# Setting default values +initialize +# Function to lowercase a value and make it a legal DNS1123 name +# $1 - value to convert to lowercase +function toDNS1123Legal { + local val=`echo $1 | tr "[:upper:]" "[:lower:]"` + val=${val//"_"/"-"} + echo "$val" +} + +# username and password from Kubernetes secret +username=`kubectl get secrets ${weblogicCredentialsSecretName} -n ${domainNamespace} -o=jsonpath='{.data.username}'|base64 --decode` +password=`kubectl get secrets ${weblogicCredentialsSecretName} -n ${domainNamespace} -o=jsonpath='{.data.password}'|base64 --decode` + +adminServerPodName="${domainUID}-$(toDNS1123Legal ${adminServerName})" + +InputParameterList=" -domainName ${domainUID} -adminServerName ${adminServerName} -adminURL ${adminServerPodName}:${adminServerPort} -username ${username} -password ${password}" +InputParameterList="${InputParameterList} -wcpClusterName ${wcpClusterName} -wlsMonitoringExporterTowcpCluster ${wlsMonitoringExporterTowcpCluster}" +InputParameterList="${InputParameterList} -wcpPortletClusterName ${wcpPortletClusterName} -wlsMonitoringExporterTowcpPortletCluster ${wlsMonitoringExporterTowcpPortletCluster}" + +echo "Deploying WebLogic Monitoring Exporter with domainNamespace[$domainNamespace], domainUID[$domainUID], adminServerPodName[$adminServerPodName]" +. $scriptDir/get-wls-exporter.sh +kubectl cp $scriptDir/wls-exporter-deploy ${domainNamespace}/${adminServerPodName}:/u01/oracle +kubectl cp $scriptDir/deploy-weblogic-monitoring-exporter.py ${domainNamespace}/${adminServerPodName}:/u01/oracle/wls-exporter-deploy +EXEC_DEPLOY="kubectl exec -it -n ${domainNamespace} ${adminServerPodName} -- /u01/oracle/oracle_common/common/bin/wlst.sh /u01/oracle/wls-exporter-deploy/deploy-weblogic-monitoring-exporter.py ${InputParameterList}" +eval ${EXEC_DEPLOY} + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/get-wls-exporter.sh b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/get-wls-exporter.sh new file mode 100644 index 000000000..f4f47a7b7 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/get-wls-exporter.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Initialize +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/utils.sh +warDir=$scriptDir/../bin +mkdir -p $warDir +curl -L -o $warDir/wls-exporter.war https://github.com/oracle/weblogic-monitoring-exporter/releases/download/v2.0.0/wls-exporter.war +mkdir -p $scriptDir/wls-exporter-deploy +echo "created $scriptDir/wls-exporter-deploy dir" + +function update_wls_exporter_war { + servername=$1 + port=$2 + tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) + echo "created $tmp_dir" + mkdir -p $tmp_dir/WEB-INF + cp $scriptDir/../config/config.yml.template $tmp_dir/config.yml + cp $scriptDir/../config/weblogic.xml $tmp_dir/WEB-INF/weblogic.xml + cp $warDir/wls-exporter.war $tmp_dir/wls-exporter.war + + sed -i -e "s:%PORT%:${port}:g" $tmp_dir/config.yml + pushd $tmp_dir + echo "in temp dir" + zip wls-exporter.war WEB-INF/weblogic.xml + zip wls-exporter.war config.yml + + cp wls-exporter.war ${scriptDir}/wls-exporter-deploy/wls-exporter-${servername}.war + popd +} + +initialize + +update_wls_exporter_war adminserver ${adminServerPort} +if [[ ${wlsMonitoringExporterTowcpCluster} == "true" ]]; +then + update_wls_exporter_war wcp ${wcpManagedServerPort} +fi +if [[ ${wlsMonitoringExporterTowcpPortletCluster} == "true" ]]; +then + update_wls_exporter_war wcpPortlet ${wcpPortletManagedServerPort} +fi + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/undeploy-weblogic-monitoring-exporter.py b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/undeploy-weblogic-monitoring-exporter.py new file mode 100644 index 000000000..52fc3d040 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/undeploy-weblogic-monitoring-exporter.py @@ -0,0 +1,103 @@ +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +import sys +#======================================================= +# Function for undeployment +#======================================================= +def unDeploy(appName,target): + print 'Undeploying .........' + try: + stopApplication(appName) + undeploy(appName, target) + except Exception, ex: + print ex.toString() + +#======================================================== +# Main program here... +# Target you can change as per your need +#======================================================== +def usage(): + argsList = ' -domainName -adminServerName -adminURL -username -password ' + argsList=argsList + ' -wcpClusterName ' + ' -wlsMonitoringExporterTowcpCluster ' + argsList=argsList + ' -wcpPortletClusterName ' + ' -wlsMonitoringExporterTowcpPortletCluster ' + print sys.argv[0] + argsList + sys.exit(0) + +if len(sys.argv) < 1: + usage() + +# domainName will be passed by command line parameter -domainName. +domainName = "wcp-domain" + +# adminServerName will be passed by command line parameter -adminServerName +adminServerName = "AdminServer" + +# adminURL will be passed by command line parameter -adminURL +adminURL = "wcp-domain-adminserver:7001" + +# wcpClusterName will be passed by command line parameter -wcpClusterName +wcpClusterName = "wcp-cluster" + +# wlsMonitoringExporterTowcpCluster will be passed by command line parameter -wlsMonitoringExporterTowcpCluster +wlsMonitoringExporterTowcpCluster = "false" +# wcpPortletClusterName will be passed by command line parameter -wcpPortletClusterName +wcpPortletClusterName = "wcportlet-cluster" + +# wlsMonitoringExporterTowcpPortletCluster will be passed by command line parameter -wlsMonitoringExporterTowcpPortletCluster +wlsMonitoringExporterTowcpPortletCluster = "false" + +# username will be passed by command line parameter -username +username = "weblogic" + +# password will be passed by command line parameter -password +password = "Welcome1" + + +i=1 +while i < len(sys.argv): + if sys.argv[i] == '-domainName': + domainName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-adminServerName': + adminServerName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-adminURL': + adminURL = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-username': + username = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-password': + password = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wcpClusterName': + wcpClusterName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wlsMonitoringExporterTowcpCluster': + wlsMonitoringExporterTowcpCluster = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wcpPortletClusterName': + wcpPortletClusterName = sys.argv[i+1] + i += 2 + elif sys.argv[i] == '-wlsMonitoringExporterTowcpPortletCluster': + wlsMonitoringExporterTowcpPortletCluster = sys.argv[i+1] + i += 2 + + else: + print 'Unexpected argument switch at position ' + str(i) + ': ' + str(sys.argv[i]) + usage() + sys.exit(1) + +# Undeploy +connect(username, password, 't3://' + adminURL) +unDeploy('wls-exporter-adminserver',adminServerName) +if 'true' == wlsMonitoringExporterTowcpCluster: + unDeploy('wls-exporter-wcp',wcpClusterName) + +if 'true' == wlsMonitoringExporterTowcpPortletCluster: + unDeploy('wls-exporter-wcpPortlet',wcpPortletClusterName) + +disconnect() +exit() + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/undeploy-weblogic-monitoring-exporter.sh b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/undeploy-weblogic-monitoring-exporter.sh new file mode 100644 index 000000000..873ea52c2 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/undeploy-weblogic-monitoring-exporter.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# Initialize +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +source ${scriptDir}/utils.sh + +# Function to lowercase a value and make it a legal DNS1123 name +# $1 - value to convert to lowercase +function toDNS1123Legal { + local val=`echo $1 | tr "[:upper:]" "[:lower:]"` + val=${val//"_"/"-"} + echo "$val" +} + +initialize + +# username and password from Kubernetes secret +username=`kubectl get secrets ${weblogicCredentialsSecretName} -n ${domainNamespace} -o=jsonpath='{.data.username}'|base64 --decode` +password=`kubectl get secrets ${weblogicCredentialsSecretName} -n ${domainNamespace} -o=jsonpath='{.data.password}'|base64 --decode` + +adminServerPodName="${domainUID}-$(toDNS1123Legal ${adminServerName})" + +InputParameterList="-domainName ${domainUID} -adminServerName ${adminServerName} -adminURL ${adminServerPodName}:${adminServerPort} -username ${username} -password ${password}" +InputParameterList="${InputParameterList} -wcpClusterName ${wcpClusterName} -wlsMonitoringExporterTowcpCluster ${wlsMonitoringExporterTowcpCluster}" +InputParameterList="${InputParameterList} -wcpPortletClusterName ${wcpPortletClusterName} -wlsMonitoringExporterTowcpPortletCluster ${wlsMonitoringExporterTowcpPortletCluster}" + +# Copy weblogic monitoring exporter jars for deployment +echo "Undeploying WebLogic Monitoring Exporter: domainNamespace[$domainNamespace], domainUID[$domainUID], adminServerPodName[$adminServerPodName]" + +kubectl cp $scriptDir/undeploy-weblogic-monitoring-exporter.py ${domainNamespace}/${adminServerPodName}:/u01/oracle/undeploy-weblogic-monitoring-exporter.py +EXEC_UNDEPLOY="kubectl exec -it -n ${domainNamespace} ${adminServerPodName} -- /u01/oracle/oracle_common/common/bin/wlst.sh /u01/oracle/undeploy-weblogic-monitoring-exporter.py ${InputParameterList}" +eval ${EXEC_UNDEPLOY} + +# Cleanup the local wars +rm -rf ${scriptDir}/wls-exporter-deploy + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/utils.sh b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/utils.sh new file mode 100644 index 000000000..7d68513a2 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/scripts/utils.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# + +function initialize { + if [ -z ${domainNamespace} ]; then + echo "domainNamespace is empty, setting to default wcpns" + domainNamespace="wcpns" + fi + + if [ -z ${domainUID} ]; then + echo "domainUID is empty, setting to default wcp-domain" + domainUID="wcp-domain" + fi + + if [ -z ${weblogicCredentialsSecretName} ]; then + echo "weblogicCredentialsSecretName is empty, setting to default \"wcp-domain-domain-credentials\"" + weblogicCredentialsSecretName="wcp-domain-domain-credentials" + fi + + if [ -z ${adminServerName} ]; then + echo "adminServerName is empty, setting to default \"AdminServer\"" + adminServerName="AdminServer" + fi + + if [ -z ${adminServerPort} ]; then + echo "adminServerPort is empty, setting to default \"7001\"" + adminServerPort="7001" + fi + + if [ -z ${wcpClusterName} ]; then + echo "wcpClusterName is empty, setting to default \"wcp-cluster\"" + wcpClusterName="wcp-cluster" + fi + + if [ -z ${wcpManagedServerPort} ]; then + echo "wcpManagedServerPort is empty, setting to default \"8888\"" + wcpManagedServerPort="8888" + fi + + if [ -z ${wlsMonitoringExporterTowcpCluster} ]; then + echo "wlsMonitoringExporterTowcpCluster is empty, setting to default \"false\"" + wlsMonitoringExporterTowcpCluster="false" + fi + if [ -z ${wcpPortletClusterName} ]; then + echo "wcpPortletClusterName is empty, setting to default \"wcportlet-cluster\"" + wcpPortletClusterName="wcportlet-cluster" + fi + + if [ -z ${wcpPortletManagedServerPort} ]; then + echo "wcpPortletManagedServerPort is empty, setting to default \"8889\"" + wcpPortletManagedServerPort="8889" + fi + + if [ -z ${wlsMonitoringExporterTowcpPortletCluster} ]; then + echo "wlsMonitoringExporterTowcpPortletCluster is empty, setting to default \"false\"" + wlsMonitoringExporterTowcpPortletCluster="false" + fi +} + diff --git a/OracleWebCenterPortal/kubernetes/monitoring-service/setup-monitoring.sh b/OracleWebCenterPortal/kubernetes/monitoring-service/setup-monitoring.sh new file mode 100644 index 000000000..bf7d3619c --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/monitoring-service/setup-monitoring.sh @@ -0,0 +1,194 @@ +#!/bin/bash +# Copyright (c) 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# setup-monitoring.sh + +# Initialize +script="${BASH_SOURCE[0]}" +scriptDir="$( cd "$( dirname "${script}" )" && pwd )" +OLD_PWD=`pwd` + + + +# +# Function to exit and print an error message +# $1 - text of message +function fail { + printError $* + exit 1 +} + +# Function to print an error message +function printError { + echo [ERROR] $* +} + + +# +# Function to remove a file if it exists +# +function removeFileIfExists { + echo "input is $1" + if [ -f $1 ]; then + rm -f $1 + fi +} + +function exitIfError { + if [ "$1" != "0" ]; then + echo "$2" + exit $1 + fi +} + +# +# Function to parse a yaml file and generate the bash exports +# $1 - Input filename +# $2 - Output filename +function parseYaml { + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\):|\1|" \ + -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 | + awk -F$fs '{ + if (length($3) > 0) { + # javaOptions may contain tokens that are not allowed in export command + # we need to handle it differently. + if ($2=="javaOptions") { + printf("%s=%s\n", $2, $3); + } else { + printf("export %s=\"%s\"\n", $2, $3); + } + } + }' > $2 +} + +function usage { + echo usage: ${script} -i file [-v] [-h] + echo " -i Parameter inputs file, must be specified." + echo " -h Help" + exit $1 +} + +function installKubePrometheusStack { + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts + helm repo update + echo "Setup prometheus-community/kube-prometheus-stack in progress" + if [ ${exposeMonitoringNodePort} == "true" ]; then + + helm install ${monitoringNamespace} prometheus-community/kube-prometheus-stack \ + --namespace ${monitoringNamespace} ${additionalParamForKubePrometheusStack} \ + --set prometheus.service.type=NodePort --set prometheus.service.nodePort=${prometheusNodePort} \ + --set alertmanager.service.type=NodePort --set alertmanager.service.nodePort=${alertmanagerNodePort} \ + --set grafana.adminPassword=admin --set grafana.service.type=NodePort --set grafana.service.nodePort=${grafanaNodePort} \ + --version "16.5.0" \ + --atomic --wait + else + helm install ${monitoringNamespace} prometheus-community/kube-prometheus-stack \ + --namespace ${monitoringNamespace} ${additionalParamForKubePrometheusStack} \ + --set grafana.adminPassword=admin \ + --version "16.5.0" \ + --atomic --wait + fi + exitIfError $? "ERROR: prometheus-community/kube-prometheus-stack install failed." +} + +#Parse the inputs +while getopts "hi:" opt; do + case $opt in + i) valuesInputFile="${OPTARG}" + ;; + h) usage 0 + ;; + *) usage 1 + ;; + esac +done + +if [ -z ${valuesInputFile} ]; then + echo "${script}: -i must be specified." + missingRequiredOption="true" +fi + +if [ "${missingRequiredOption}" == "true" ]; then + usage 1 +fi + +if [ ! -f ${valuesInputFile} ]; then + echo "Unable to locate the input parameters file ${valuesInputFile}" + fail 'The error listed above must be resolved before the script can continue' +fi + + +exportValuesFile=$(mktemp /tmp/export-values-XXXXXXXXX.sh) +parseYaml ${valuesInputFile} ${exportValuesFile} + + +source ${exportValuesFile} +rm ${exportValuesFile} + + +if [ "${setupKubePrometheusStack}" = "true" ]; then + if test "$(kubectl get namespace ${monitoringNamespace} --ignore-not-found | wc -l)" = 0; then + echo "The namespace ${monitoringNamespace} for install prometheus-community/kube-promethues-stack does not exist. Creating the namespace ${monitoringNamespace}" + kubectl create namespace ${monitoringNamespace} + fi + echo -e "Monitoring setup in ${monitoringNamespace} in progress.......\n" + + # Create the namespace and CRDs, and then wait for them to be availble before creating the remaining resources + kubectl label nodes --all kubernetes.io/os=linux --overwrite=true + + echo "Setup prometheus-community/kube-prometheus-stack started" + installKubePrometheusStack + cd $OLD_PWD + + echo "Setup prometheus-community/kube-prometheus-stack completed" +fi + +export username=`kubectl get secrets ${weblogicCredentialsSecretName} -n ${domainNamespace} -o=jsonpath='{.data.username}'|base64 --decode` +export password=`kubectl get secrets ${weblogicCredentialsSecretName} -n ${domainNamespace} -o=jsonpath='{.data.password}'|base64 --decode` + +# Setting up the WebLogic Monitoring Exporter +echo "Deploy WebLogic Monitoring Exporter started" +script=${scriptDir}/scripts/deploy-weblogic-monitoring-exporter.sh +sh ${script} +exitIfError $? "ERROR: $script failed." +echo "Deploy WebLogic Monitoring Exporter completed" + + +# Deploy servicemonitors +serviceMonitor=${scriptDir}/manifests/wls-exporter-ServiceMonitor.yaml +cp "${serviceMonitor}.template" "${serviceMonitor}" +sed -i -e "s/release: monitoring/release: ${monitoringNamespace}/g" ${serviceMonitor} +sed -i -e "s/user: %USERNAME%/user: `echo -n $username|base64 -w0`/g" ${serviceMonitor} +sed -i -e "s/password: %PASSWORD%/password: `echo -n $password|base64 -w0`/g" ${serviceMonitor} +sed -i -e "s/namespace:.*/namespace: ${domainNamespace}/g" ${serviceMonitor} +sed -i -e "s/weblogic.domainName:.*/weblogic.domainName: ${domainUID}/g" ${serviceMonitor} +sed -i -e "$!N;s/matchNames:\n -.*/matchNames:\n - ${domainNamespace}/g;P;D" ${serviceMonitor} + +kubectl apply -f ${serviceMonitor} + + +if [ "${setupKubePrometheusStack}" = "true" ]; then + # Deploying WebLogic Server Grafana Dashboard + echo "Deploying WebLogic Server Grafana Dashboard...." + grafanaEndpointIP=$(kubectl get endpoints ${monitoringNamespace}-grafana -n ${monitoringNamespace} -o=jsonpath="{.subsets[].addresses[].ip}") + grafanaEndpointPort=$(kubectl get endpoints ${monitoringNamespace}-grafana -n ${monitoringNamespace} -o=jsonpath="{.subsets[].ports[].port}") + grafanaEndpoint="${grafanaEndpointIP}:${grafanaEndpointPort}" + curl --noproxy "*" -X POST -H "Content-Type: application/json" -d @config/weblogic-server-dashboard.json http://admin:admin@${grafanaEndpoint}/api/dashboards/db + echo "" + echo "Deployed WebLogic Server Grafana Dashboard successfully" + echo "" + if [ ${exposeMonitoringNodePort} == "true" ]; then + echo "Grafana is available at NodePort: ${grafanaNodePort}" + echo "Prometheus is available at NodePort: ${prometheusNodePort}" + echo "Altermanager is available at NodePort: ${alertmanagerNodePort}" + echo "==============================================================" + fi +else + echo "Please import config/weblogic-server-dashboard.json manually into Grafana" +fi + +echo "" + diff --git a/OracleWebCenterPortal/kubernetes/rest/README.md b/OracleWebCenterPortal/kubernetes/rest/README.md new file mode 100644 index 000000000..f0e09b088 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/rest/README.md @@ -0,0 +1,38 @@ +# Sample to create certificates and keys for the operator + +When a user enables the operator's external REST API (by setting +`externalRestEnabled` to `true` when installing the operator Helm chart), the user needs +to provide the certificate and private key for api's SSL identity too (by creating a +`tls secret` before the installation of the operator helm chart). + +This sample script generates a self-signed certificate and private key that can be used +for the operator's external REST api when experimenting with the operator. They should +not be used in a production environment. + +The syntax of the script is: +```shell +$ kubernetes/samples/scripts/rest/generate-external-rest-identity.sh -n [-s ] +``` + +Where `` lists the subject alternative names to put into the generated self-signed +certificate for the external WebLogic Operator REST HTTPS interface, should match +the namespace where the operator will be installed, and optionally the secret name, which defaults +to `weblogic-operator-external-rest-identity`. Each must be prefaced +by `DNS:` (for a name) or `IP:` (for an address), for example: +``` +DNS:myhost,DNS:localhost,IP:127.0.0.1 +``` + +You should include the addresses of all masters and load balancers in this list. The certificate +cannot be conveniently changed after installation of the operator. + +The script creates the secret in the weblogic-operator namespace with the self-signed +certificate and private key + +Example usage: +```shell +$ generate-external-rest-identity.sh IP:127.0.0.1 -n weblogic-operator > my_values.yaml +$ echo "externalRestEnabled: true" >> my_values.yaml + ... +$ helm install my_operator kubernetes/charts/weblogic-operator --namespace my_operator-ns --values my_values.yaml --wait +``` diff --git a/OracleWebCenterPortal/kubernetes/rest/generate-external-rest-identity.sh b/OracleWebCenterPortal/kubernetes/rest/generate-external-rest-identity.sh new file mode 100644 index 000000000..e645d3925 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/rest/generate-external-rest-identity.sh @@ -0,0 +1,200 @@ +#!/usr/bin/env bash +# Copyright (c) 2017, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +# +# When the customer enables the operator's external REST api (by setting +# externalRestEnabled to true when installing the operator helm chart), the customer needs +# to provide the certificate and private key for api's SSL identity too (by creating a +# tls secret before the installation of the operator helm chart). +# +# This sample script generates a self-signed certificate and private key that can be used +# for the operator's external REST api when experimenting with the operator. They should +# not be used in a production environment. +# +# The sytax of the script is: +# +# kubernetes/samples/scripts/rest/generate-external-rest-identity.sh -a -n +# +# Where lists the subject alternative names to put into the generated self-signed +# certificate for the external WebLogic Operator REST https interface, for example: +# +# DNS:myhost,DNS:localhost,IP:127.0.0.1 +# +# You should include the addresses of all masters and load balancers in this list. The certificate +# cannot be conveniently changed after installation of the operator. +# +# The script creates the secret in the weblogic-operator namespace with the self-signed +# certificate and private key +# +# Example usage: +# generate-external-rest-identity.sh -a IP:127.0.0.1 -n weblogic-operator > my_values.yaml +# echo "externalRestEnabled: true" >> my_values.yaml +# ... +# helm install my_operator kubernetes/charts/weblogic-operator --namespace my_operator-ns --values my_values.yaml --wait +usage(){ +cat < -n +Options: +-a SANS Required, the SANs for the certificate +-n NAMESPACE Required, the namespace where the secret will be created. +-s SECRET_NAME Optional, the name of the kubernetes secret. Default is: weblogic-operator-external-rest-identity. +-h, --help Display this help text. +EOF +exit 1 +} + +if [ ! -x "$(command -v keytool)" ]; then + echo "Can't find keytool. Please add it to the path." + exit 1 +fi + +if [ ! -x "$(command -v openssl)" ]; then + echo "Can't find openssl. Please add it to the path." + exit 1 +fi + +if [ ! -x "$(command -v base64)" ]; then + echo "Can't find base64. Please add it to the path." + exit 1 +fi + +TEMP_DIR=`mktemp -d` +if [ $? -ne 0 ]; then + echo "$0: Can't create temp directory." + exit 1 +fi + +if [ -z $TEMP_DIR ]; then + echo "Can't create temp directory." + exit 1 +fi + +function cleanup { + rm -r $TEMP_DIR + if [[ $SUCCEEDED != "true" ]]; then + exit 1 + fi +} + +set -e +#set -x + +trap "cleanup" EXIT + +SECRET_NAME="weblogic-operator-external-rest-identity" + +while [ $# -gt 0 ] + do + key="$1" + case $key in + -a) + shift # past argument + if [ $# -eq 0 ] || [ ${1:0:1} == "-" ]; then echo "SANs is required and is missing"; usage; fi + SANS=$1 + shift # past value + ;; + -n) + shift # past argument + if [ $# -eq 0 ] || [ ${1:0:1} == "-" ]; then echo "Namespace is required and is missing"; usage; fi + NAMESPACE=$1 + shift # past value + ;; + -s) + shift # past argument + if [ $# -eq 0 ] || [ ${1:0:1} == "-" ]; then echo "Invalid secret name $1"; usage; fi + SECRET_NAME=$1 + shift # past value + ;; + -h) + shift # past argument + ;; + *) + SANS=$1 + shift # past argument + ;; + esac +done + +if [ -z "$SANS" ] +then + 1>&2 + echo "SANs is required and is missing" + usage +fi + +if [ -z "$NAMESPACE" ] +then + 1>&2 + echo "Namespace is required and is missing" + usage +fi + +DAYS_VALID="3650" +TEMP_PW="temp_password" +OP_PREFIX="weblogic-operator" +OP_ALIAS="${OP_PREFIX}-alias" +OP_JKS="${TEMP_DIR}/${OP_PREFIX}.jks" +OP_PKCS12="${TEMP_DIR}/${OP_PREFIX}.p12" +OP_CSR="${TEMP_DIR}/${OP_PREFIX}.csr" +OP_CERT_PEM="${TEMP_DIR}/${OP_PREFIX}.cert.pem" +OP_KEY_PEM="${TEMP_DIR}/${OP_PREFIX}.key.pem" + +# generate a keypair for the operator's REST service, putting it in a keystore +keytool \ + -genkey \ + -keystore ${OP_JKS} \ + -alias ${OP_ALIAS} \ + -storepass ${TEMP_PW} \ + -keypass ${TEMP_PW} \ + -keysize 2048 \ + -keyalg RSA \ + -validity ${DAYS_VALID} \ + -dname "CN=weblogic-operator" \ + -ext KU=digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment,keyAgreement \ + -ext SAN="${SANS}" \ +2> /dev/null + +# extract the cert to a pem file +keytool \ + -exportcert \ + -keystore ${OP_JKS} \ + -storepass ${TEMP_PW} \ + -alias ${OP_ALIAS} \ + -rfc \ +> ${OP_CERT_PEM} 2> /dev/null + +# convert the keystore to a pkcs12 file +keytool \ + -importkeystore \ + -srckeystore ${OP_JKS} \ + -srcstorepass ${TEMP_PW} \ + -destkeystore ${OP_PKCS12} \ + -srcstorepass ${TEMP_PW} \ + -deststorepass ${TEMP_PW} \ + -deststoretype PKCS12 \ +2> /dev/null + +# extract the private key from the pkcs12 file to a pem file +openssl \ + pkcs12 \ + -in ${OP_PKCS12} \ + -passin pass:${TEMP_PW} \ + -nodes \ + -nocerts \ + -out ${OP_KEY_PEM} \ +2> /dev/null + +set +e +# Check if namespace exist +kubectl get namespace $NAMESPACE >/dev/null 2>/dev/null +if [ $? -eq 1 ]; then + echo "Namespace $NAMESPACE does not exist" + exit 1 +fi +kubectl get secret $SECRET_NAME -n $NAMESPACE >/dev/null 2>/dev/null +if [ $? -eq 1 ]; then + kubectl create secret tls "$SECRET_NAME" --cert=${OP_CERT_PEM} --key=${OP_KEY_PEM} -n $NAMESPACE >/dev/null +fi +echo "externalRestIdentitySecret: $SECRET_NAME" + +SUCCEEDED=true diff --git a/OracleWebCenterPortal/kubernetes/scaling/scalingAction.sh b/OracleWebCenterPortal/kubernetes/scaling/scalingAction.sh new file mode 100644 index 000000000..0da098e68 --- /dev/null +++ b/OracleWebCenterPortal/kubernetes/scaling/scalingAction.sh @@ -0,0 +1,504 @@ +#!/bin/bash +# Copyright (c) 2017, 2021, Oracle and/or its affiliates. +# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. + +# script parameters +scaling_action="" +wls_domain_uid="" +wls_cluster_name="" +wls_domain_namespace="default" +operator_service_name="internal-weblogic-operator-svc" +operator_namespace="weblogic-operator" +operator_service_account="weblogic-operator" +scaling_size=1 +access_token="" +no_op="" +kubernetes_master="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}" +log_file_name="scalingAction.log" + +# timestamp +# purpose: echo timestamp in the form yyyy-mm-ddThh:mm:ss.nnnnnnZ +# example: 2018-10-01T14:00:00.000001Z +function timestamp() { + local timestamp="`date --utc '+%Y-%m-%dT%H:%M:%S.%NZ' 2>&1`" + if [ ! "${timestamp/illegal/xyz}" = "${timestamp}" ]; then + # old shell versions don't support %N or --utc + timestamp="`date -u '+%Y-%m-%dT%H:%M:%S.000000Z' 2>&1`" + fi + echo "${timestamp}" +} + +function trace() { + echo "@[$(timestamp)][$wls_domain_namespace][$wls_domain_uid][$wls_cluster_name][INFO]" "$@" >> ${log_file_name} +} + +function print_usage() { + echo "Usage: scalingAction.sh --action=[scaleUp | scaleDown] --domain_uid= --cluster_name= [--kubernetes_master=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}] [--access_token=] [--wls_domain_namespace=default] [--operator_namespace=weblogic-operator] [--operator_service_name=weblogic-operator] [--scaling_size=1] [--no_op]" + echo " where" + echo " action - scaleUp or scaleDown" + echo " domain_uid - WebLogic Domain Unique Identifier" + echo " cluster_name - WebLogic Cluster Name" + echo " kubernetes_master - Kubernetes master URL, default=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}" + echo " access_token - Service Account Bearer token for authentication and authorization for access to REST Resources" + echo " wls_domain_namespace - Kubernetes name space WebLogic Domain is defined in, default=default" + echo " operator_service_name - WebLogic Operator Service name, default=internal-weblogic-operator-svc" + echo " operator_service_account - Kubernetes Service Account for WebLogic Operator, default=weblogic-operator" + echo " operator_namespace - WebLogic Operator Namespace, default=weblogic-operator" + echo " scaling_size - number of WebLogic server instances by which to scale up or down, default=1" + echo " no_op - if specified, returns without doing anything. For use by unit test to include methods in the script" + exit 1 +} + +# Retrieve WebLogic Operator Service Account Token for Authorization +function initialize_access_token() { + if [ -z "$access_token" ] + then + access_token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` + fi +} + +function logScalingParameters() { + trace "scaling_action: $scaling_action" + trace "wls_domain_uid: $wls_domain_uid" + trace "wls_cluster_name: $wls_cluster_name" + trace "wls_domain_namespace: $wls_domain_namespace" + trace "operator_service_name: $operator_service_name" + trace "operator_service_account: $operator_service_account" + trace "operator_namespace: $operator_namespace" + trace "scaling_size: $scaling_size" +} + +function jq_available() { + if [ -x "$(command -v jq)" ] && [ -z "$DONT_USE_JQ" ]; then + return; + fi + false +} + +# Query WebLogic Operator Service Port +function get_operator_internal_rest_port() { + local STATUS=$(curl \ + -v \ + --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ + -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \ + -X GET $kubernetes_master/api/v1/namespaces/$operator_namespace/services/$operator_service_name/status) + if [ $? -ne 0 ] + then + trace "Failed to retrieve status of $operator_service_name in name space: $operator_namespace" + trace "STATUS: $STATUS" + exit 1 + fi + + local port + if jq_available; then + local extractPortCmd="(.spec.ports[] | select (.name == \"rest\") | .port)" + port=$(echo "${STATUS}" | jq "${extractPortCmd}" 2>> ${log_file_name}) + else +cat > cmds-$$.py << INPUT +import sys, json +for i in json.load(sys.stdin)["spec"]["ports"]: + if i["name"] == "rest": + print(i["port"]) +INPUT +port=$(echo "${STATUS}" | python cmds-$$.py 2>> ${log_file_name}) + fi + echo "$port" +} + +# Retrieve the api version of the deployed Custom Resource Domain +function get_domain_api_version() { + # Retrieve Custom Resource Definition for WebLogic domain + local APIS=$(curl \ + -v \ + --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ + -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \ + -X GET \ + $kubernetes_master/apis) + if [ $? -ne 0 ] + then + trace "Failed to retrieve list of APIs from Kubernetes cluster" + trace "APIS: $APIS" + exit 1 + fi + +# Find domain version + local domain_api_version + if jq_available; then + local extractVersionCmd="(.groups[] | select (.name == \"weblogic.oracle\") | .preferredVersion.version)" + domain_api_version=$(echo "${APIS}" | jq -r "${extractVersionCmd}" 2>> ${log_file_name}) + else +cat > cmds-$$.py << INPUT +import sys, json +for i in json.load(sys.stdin)["groups"]: + if i["name"] == "weblogic.oracle": + print(i["preferredVersion"]["version"]) +INPUT +domain_api_version=`echo ${APIS} | python cmds-$$.py 2>> ${log_file_name}` + fi + echo "$domain_api_version" +} + +# Retrieve Custom Resource Domain +function get_custom_resource_domain() { + local DOMAIN=$(curl \ + -v \ + --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ + -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \ + $kubernetes_master/apis/weblogic.oracle/$domain_api_version/namespaces/$wls_domain_namespace/domains/$wls_domain_uid) + if [ $? -ne 0 ]; then + trace "Failed to retrieve WebLogic Domain Custom Resource Definition" + exit 1 + fi + echo "$DOMAIN" +} + +# Verify if cluster is defined in clusters of the Custom Resource Domain +# args: +# $1 Custom Resource Domain +function is_defined_in_clusters() { + local DOMAIN="$1" + local in_cluster_startup="False" + + if jq_available; then + local inClusterStartupCmd="(.spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\"))" + local clusterDefinedInCRD=$(echo "${DOMAIN}" | jq "${inClusterStartupCmd}" 2>> ${log_file_name}) + if [ "${clusterDefinedInCRD}" != "" ]; then + in_cluster_startup="True" + fi + else +cat > cmds-$$.py << INPUT +import sys, json +outer_loop_must_break = False +for j in json.load(sys.stdin)["spec"]["clusters"]: + if j["clusterName"] == "$wls_cluster_name": + outer_loop_must_break = True + print (True) + break +if outer_loop_must_break == False: + print (False) +INPUT +in_cluster_startup=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}` + fi + echo "$in_cluster_startup" +} + +# Gets the current replica count of the cluster +# args: +# $1 Custom Resource Domain +function get_num_ms_in_cluster() { + local DOMAIN="$1" + local num_ms + if jq_available; then + local numManagedServersCmd="(.spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\") | .replicas)" + num_ms=$(echo "${DOMAIN}" | jq "${numManagedServersCmd}" 2>> ${log_file_name}) + else +cat > cmds-$$.py << INPUT +import sys, json +for j in json.load(sys.stdin)["spec"]["clusters"]: + if j["clusterName"] == "$wls_cluster_name": + print (j["replicas"]) +INPUT + num_ms=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}` + fi + + if [ "${num_ms}" == "null" ] || [ "${num_ms}" == '' ] ; then + num_ms=0 + fi + + echo "$num_ms" +} + +# Gets the replica count at the Domain level +# args: +# $1 Custom Resource Domain +function get_num_ms_domain_scope() { + local DOMAIN="$1" + local num_ms + if jq_available; then + num_ms=$(echo "${DOMAIN}" | jq -r '.spec.replicas' 2>> ${log_file_name}) + else +cat > cmds-$$.py << INPUT +import sys, json +print (json.load(sys.stdin)["spec"]["replicas"]) +INPUT + num_ms=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}` + fi + + if [ "${num_ms}" == "null" ] || [ "${num_ms}" == '' ] ; then + # if not defined then default to 0 + num_ms=0 + fi + + echo "$num_ms" +} + +# +# Function to get minimum replica count for cluster +# $1 - Domain resource in json format +# $2 - Name of the cluster +# $3 - Return value containing minimum replica count +# +function get_min_replicas { + local domainJson=$1 + local clusterName=$2 + local __result=$3 + + eval $__result=0 + if jq_available; then + minReplicaCmd="(.status.clusters[] | select (.clusterName == \"${clusterName}\")) \ + | .minimumReplicas" + minReplicas=$(echo ${domainJson} | jq "${minReplicaCmd}" 2>> ${log_file_name}) + else +cat > cmds-$$.py << INPUT +import sys, json +for j in json.load(sys.stdin)["status"]["clusters"]: + if j["clusterName"] == "$clusterName": + print (j["minimumReplicas"]) +INPUT + minReplicas=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}` + fi + eval $__result=${minReplicas} +} + +# Get the current replica count for the WLS cluster if defined in the CRD's Cluster +# configuration. If WLS cluster is not defined in the CRD then return the Domain +# scoped replica value, if present. Returns replica count = 0 if no replica count found. +# args: +# $1 "True" if WLS cluster configuration defined in CRD, "False" otherwise +# $2 Custom Resource Domain +function get_replica_count() { + local in_cluster_startup="$1" + local DOMAIN="$2" + local num_ms + if [ "$in_cluster_startup" == "True" ] + then + trace "$wls_cluster_name defined in clusters" + num_ms=$(get_num_ms_in_cluster "$DOMAIN") + else + trace "$wls_cluster_name NOT defined in clusters" + num_ms=$(get_num_ms_domain_scope "$DOMAIN") + fi + + get_min_replicas "${DOMAIN}" "${wls_cluster_name}" minReplicas + if [[ "${num_ms}" -lt "${minReplicas}" ]]; then + # Reset managed server count to minimum replicas + num_ms=${minReplicas} + fi + + echo "$num_ms" +} + +# Determine the nuber of managed servers to scale +# args: +# $1 scaling action (scaleUp or scaleDown) +# $2 current replica count +# $3 scaling increment value +function calculate_new_ms_count() { + local scaling_action="$1" + local current_replica_count="$2" + local scaling_size="$3" + local new_ms + if [ "$scaling_action" == "scaleUp" ]; + then + # Scale up by specified scaling size + # shellcheck disable=SC2004 + new_ms=$(($current_replica_count + $scaling_size)) + else + # Scale down by specified scaling size + new_ms=$(($current_replica_count - $scaling_size)) + fi + echo "$new_ms" +} + +# Verify if requested managed server scaling count is less than the configured +# minimum replica count for the cluster. +# args: +# $1 Managed server count +# $2 Custom Resource Domain +# $3 Cluster name +function verify_minimum_ms_count_for_cluster() { + local new_ms="$1" + local domainJson="$2" + local clusterName="$3" + # check if replica count is less than minimum replicas + get_min_replicas "${domainJson}" "${clusterName}" minReplicas + if [ "${new_ms}" -lt "${minReplicas}" ]; then + trace "Scaling request to new managed server count $new_ms is less than configured minimum \ + replica count $minReplicas" + exit 1 + fi +} + +# Create the REST endpoint CA certificate in PEM format +# args: +# $1 certificate file name to create +function create_ssl_certificate_file() { + local pem_filename="$1" + if [ ${INTERNAL_OPERATOR_CERT} ]; + then + echo ${INTERNAL_OPERATOR_CERT} | base64 --decode > $pem_filename + else + trace "Operator Cert File not found" + exit 1 + fi +} + +# Create request body for scaling request +# args: +# $1 replica count +function get_request_body() { +local new_ms="$1" +local request_body=$(cat <Note that this release is only for evaluation purposes and hence applicable to Development and Test deployments only. #### Recent changes and known issues @@ -43,3 +46,9 @@ please use this table of contents: * Configuring Kubernetes load balancers * Configuring Prometheus and Grafana to monitor WebCenter Portal * Configuring Logging using ElasticSearch + +#### Documentation for earlier releases + +To view documentation for an earlier release, see: + +* [Version 21.2.3](https://oracle.github.io/fmw-kubernetes/21.2.3/wcportal-domains/) diff --git a/docs-source/content/wcportal-domains/appendix/quickstart-deployment-on-prem.md b/docs-source/content/wcportal-domains/appendix/quickstart-deployment-on-prem.md index 287a74f3a..21c3e2660 100644 --- a/docs-source/content/wcportal-domains/appendix/quickstart-deployment-on-prem.md +++ b/docs-source/content/wcportal-domains/appendix/quickstart-deployment-on-prem.md @@ -125,7 +125,7 @@ Any time you see `YOUR_USERID` in a command, you should replace it with your act 1. Install the latest `docker-engine` and start the Docker service: ``` $ yum-config-manager --enable ol7_addons - $ docker_version="19.03.1.ol" + $ docker_version="19.03.11-ol" $ yum install docker-engine-$docker_version $ systemctl enable docker @@ -144,33 +144,33 @@ Any time you see `YOUR_USERID` in a command, you should replace it with your act Example output: ``` Client: Docker Engine - Community - Version: 19.03.1-ol + Version: 19.03.11-ol API version: 1.40 - Go version: go1.12.5 - Git commit: ead9442 - Built: Wed Sep 11 06:40:28 2019 + Go version: go1.15.5 + Git commit: 748876d + Built: Thu Dec 3 19:36:03 2020 OS/Arch: linux/amd64 Experimental: false - + Server: Docker Engine - Community Engine: - Version: 19.03.1-ol - API version: 1.40 (minimum version 1.12) - Go version: go1.12.5 - Git commit: ead9442 - Built: Wed Sep 11 06:38:43 2019 - OS/Arch: linux/amd64 - Experimental: false - Default Registry: docker.io - containerd: - Version: v1.2.0-rc.0-108-gc444666 - GitCommit: c4446665cb9c30056f4998ed953e6d4ff22c7c39 - runc: - Version: 1.0.0-rc5+dev - GitCommit: 4bb1fe4ace1a32d3676bb98f5d3b6a4e32bf6c58 - docker-init: - Version: 0.18.0 - GitCommit: fec3683 + Version: 19.03.11-ol + API version: 1.40 (minimum version 1.12) + Go version: go1.15.8 + Git commit: f0aae77 + Built: Wed Feb 10 16:13:32 2021 + OS/Arch: linux/amd64 + Experimental: false + Default Registry: docker.io + containerd: + Version: v1.3.9 + GitCommit: + runc: + Version: 1.0.0-rc5+dev + GitCommit: 4bb1fe4ace1a32d3676bb98f5d3b6a4e32bf6c58 + docker-init: + Version: 0.18.0 + GitCommit: fec3683 ``` 1. Update the Docker engine configuration: @@ -275,8 +275,8 @@ Any time you see `YOUR_USERID` in a command, you should replace it with your act $ export HTTPS_PROXY=http://REPLACE-WITH-YOUR-COMPANY-PROXY-HOST:PORT $ export HTTP_PROXY=http://REPLACE-WITH-YOUR-COMPANY-PROXY-HOST:PORT - ### install kubernetes 1.18.4-1 - $ VERSION=1.18.4-1 + ### install kubernetes 1.20.10 + $ VERSION=1.20.10 $ yum install -y kubelet-$VERSION kubeadm-$VERSION kubectl-$VERSION --disableexcludes=kubernetes ### enable kubelet service so that it auto-restart on reboot @@ -303,17 +303,17 @@ Any time you see `YOUR_USERID` in a command, you should replace it with your act #### 1.4 Set up Helm -1. Install Helm v3.x. +1. Install Helm v3.4+ a. Download Helm from https://github.com/helm/helm/releases. - For example, to download Helm v3.1.3: + For example, to download Helm v3.4.1: ``` - $ wget https://get.helm.sh/helm-v3.1.3-linux-amd64.tar.gz + $ wget https://get.helm.sh/helm-v3.4.1-linux-amd64.tar.gz ``` b. Unpack `tar.gz`: ``` - $ tar -zxvf helm-v3.1.3-linux-amd64.tar.gz + $ tar -zxvf helm-v3.4.1-linux-amd64.tar.gz ``` c. Find the Helm binary in the unpacked directory, and move it to its desired destination: ``` @@ -323,7 +323,7 @@ Any time you see `YOUR_USERID` in a command, you should replace it with your act 1. Run `helm version` to verify its installation: ``` $ helm version - version.BuildInfo{Version:"v3.1.3", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"} + version.BuildInfo{Version:"v3.4.1", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"} ``` ### 2. Set up a single instance Kubernetes cluster @@ -443,7 +443,7 @@ Follow [these steps]({{< relref "/wcportal-domains/installguide/prepare-your-env 1. Pull the operator image: ``` - $ docker pull ghcr.io/oracle/weblogic-kubernetes-operator:3.1.1 + $ docker pull ghcr.io/oracle/weblogic-kubernetes-operator:3.3.0 ``` 1. Obtain the Oracle Database image from the [Oracle Container Registry](https://container-registry.oracle.com): @@ -484,10 +484,10 @@ Follow [these steps]({{< relref "/wcportal-domains/installguide/prepare-your-env Use Helm to install and start the operator from the directory you just cloned: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator - $ helm install weblogic-kubernetes-operator kubernetes/charts/weblogic-operator \ + $ cd ${WORKDIR} + $ helm install weblogic-kubernetes-operator charts/weblogic-operator \ --namespace operator-ns \ - --set image=oracle/weblogic-kubernetes-operator:3.1.1 \ + --set image=oracle/weblogic-kubernetes-operator:3.3.0 \ --set serviceAccount=operator-sa \ --set "domainNamespaces={}" \ --wait @@ -504,11 +504,11 @@ Use Helm to install and start the operator from the directory you just cloned: $ kubectl logs -n operator-ns -c weblogic-operator deployments/weblogic-operator ``` -The WebLogic Kubernetes operator v3.1.1 has been installed. Continue with the load balancer and Oracle WebCenter Portal domain setup. +The WebLogic Kubernetes operator v3.3.0 has been installed. Continue with the load balancer and Oracle WebCenter Portal domain setup. ### 5. Install the Traefik (ingress-based) load balancer -The WebLogic Kubernetes Operator supports three load balancers: Traefik, Voyager, and Apache. Samples are provided in the documentation. +The WebLogic Kubernetes Operator supports three load balancers: Traefik, NGINX and Apache. Samples are provided in the documentation. This Quick Start demonstrates how to install the Traefik ingress controller to provide load balancing for an Oracle WebCenter Portal domain. @@ -524,10 +524,10 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p 1. Install the Traefik operator in the `traefik` namespace with the provided sample values: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator + $ cd ${WORKDIR} $ helm install traefik traefik/traefik \ --namespace traefik \ - --values kubernetes/samples/scripts/charts/traefik/values.yaml \ + --values charts/traefik/values.yaml \ --set "kubernetes.namespaces={traefik}" \ --set "service.type=NodePort" \ --wait @@ -543,8 +543,8 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p 1. Use Helm to configure the operator to manage Oracle WebCenter Portal domain in this namespace: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator - $ helm upgrade weblogic-kubernetes-operator kubernetes/charts/weblogic-operator \ + $ cd ${WORKDIR} + $ helm upgrade weblogic-kubernetes-operator charts/weblogic-operator \ --reuse-values \ --namespace operator-ns \ --set "domainNamespaces={wcpns}" \ @@ -556,8 +556,8 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p a. Create a Kubernetes secret for the domain in the same Kubernetes namespace as the domain. In this example, the username is `weblogic`, the password is `welcome1`, and the namespace is `wcpns`: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-weblogic-domain-credentials - $ sh create-weblogic-credentials.sh -u weblogic -p welcome1 -n wcpns -d wcp-domain -s wcpinfra-domain-credentials + $ cd ${WORKDIR}/create-weblogic-domain-credentials + $ sh create-weblogic-credentials.sh -u weblogic -p welcome1 -n wcpns -d wcp-domain -s wcp-domain-domain-credentials ``` b. Create a Kubernetes secret for the RCU in the same Kubernetes namespace as the domain: @@ -567,11 +567,11 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p * DB sys user password : `Oradoc_db1` * Domain name : `wcp-domain` * Domain Namespace : `wcpns` - * Secret name : `wcpinfra-rcu-credentials` + * Secret name : `wcp-domain-rcu-credentials` ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-rcu-credentials - $ sh create-rcu-credentials.sh -u WCP1 -p Oradoc_db1 -a sys -q Oradoc_db1 -n wcpns -d wcp-domain -s wcpinfra-rcu-credentials + $ cd ${WORKDIR}/create-rcu-credentials + $ sh create-rcu-credentials.sh -u WCP1 -p Oradoc_db1 -a sys -q Oradoc_db1 -n wcpns -d wcp-domain -s wcp-domain-rcu-credentials ``` 1. Create the Kubernetes persistence volume and persistence volume claim. @@ -601,7 +601,7 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p * weblogicDomainStoragePath: `/scratch/k8s_dir` ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc + $ cd ${WORKDIR}/create-weblogic-domain-pv-pvc $ cp create-pv-pvc-inputs.yaml create-pv-pvc-inputs.yaml.orig $ sed -i -e "s:baseName\: weblogic-sample:baseName\: domain:g" create-pv-pvc-inputs.yaml $ sed -i -e "s:domainUID\::domainUID\: wcp-domain:g" create-pv-pvc-inputs.yaml @@ -631,7 +631,7 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p a. Create a database in a container: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-oracle-db-service + $ cd ${WORKDIR}/create-oracle-db-service $ ./start-db-service.sh -i container-registry.oracle.com/database/enterprise:12.2.0.1-slim -p none ``` @@ -641,20 +641,14 @@ This Quick Start demonstrates how to install the Traefik ingress controller to p To create the Oracle WebCenter Portal schemas, run the following commands: ``` - $ kubectl run rcu --generator=run-pod/v1 --image oracle/wcportal:12.2.1.4 -n wcpns -- sleep infinity - #check the status of rcu pod - $ kubectl get pods -n wcpns - #make sure rcu pod status is running before executing this - $ kubectl exec -n wcpns -ti rcu /bin/bash - #After Getting Shell in RCU Container run the below command. - export CONNECTION_STRING=oracle-db.default.svc.cluster.local:1521/devpdb.k8s - export RCUPREFIX=WCP1 - echo -e Oradoc_db1"\n"Oradoc_db1 > /tmp/pwd.txt - /u01/oracle/oracle_common/bin/rcu -silent -dropRepository -databaseType ORACLE -connectString $CONNECTION_STRING -dbUser sys -dbRole sysdba -selectDependentsForComponents true -schemaPrefix $RCUPREFIX -component OPSS -component IAU_VIEWER -component WEBCENTER -component MDS -component IAU_APPEND -component STB -component IAU -component WLS -f < /tmp/pwd.txt - /u01/oracle/oracle_common/bin/rcu -silent -createRepository -databaseType ORACLE -connectString $CONNECTION_STRING -dbUser sys -dbRole sysdba -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -schemaPrefix $RCUPREFIX -component OPSS -component IAU_VIEWER -component WEBCENTER -component MDS -component IAU_APPEND -component STB -component IAU -component WLS -tablespace USERS -tempTablespace TEMP -f < /tmp/pwd.txt - #exit from the container - exit - + $ ./create-rcu-schema.sh \ + -s WCP1 \ + -t wcp \ + -d oracle-db.default.svc.cluster.local:1521/devpdb.k8s \ + -i oracle/wcportal:12.2.1.4\ + -n wcpns \ + -q Oradoc_db1 \ + -r welcome1 ``` Now the environment is ready to start the Oracle WebCenter Portal domain creation. @@ -662,7 +656,7 @@ Now the environment is ready to start the Oracle WebCenter Portal domain creatio #### 6.2 Create an Oracle WebCenter Portal domain -1. The sample scripts for Oracle WebCenter Portal domain deployment are available at `/kubernetes/samples/scripts/create-wcp-domain`. You must edit `create-domain-inputs.yaml` (or a copy of it) to provide the details for your domain. +1. The sample scripts for Oracle WebCenter Portal domain deployment are available at `create-wcp-domain`. You must edit `create-domain-inputs.yaml` (or a copy of it) to provide the details for your domain. Update `create-domain-inputs.yaml` with the following values for domain creation: @@ -671,7 +665,7 @@ Now the environment is ready to start the Oracle WebCenter Portal domain creatio 1. Run the `create-domain.sh` script to create a domain: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/domain-home-on-pv/ + $ cd ${WORKDIR}/create-wcp-domain/domain-home-on-pv/ $ ./create-domain.sh -i create-domain-inputs.yaml -o output ``` @@ -680,7 +674,7 @@ Now the environment is ready to start the Oracle WebCenter Portal domain creatio Once the `create-domain.sh` is successful, it generates `output/weblogic-domains/wcp-domain/domain.yaml`, which you can use to create the Kubernetes resource domain to start the domain and servers: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/domain-home-on-pv + $ cd ${WORKDIR}/create-wcp-domain/domain-home-on-pv $ kubectl create -f output/weblogic-domains/wcp-domain/domain.yaml ``` @@ -715,11 +709,11 @@ Watch the `wcpns` namespace for the status of domain creation: 1. Create an ingress for the domain in the domain namespace by using the sample Helm chart: ``` - $ cd ${WORKDIR}/weblogic-kubernetes-operator + $ cd ${WORKDIR} helm install wcp-traefik-ingress \ - kubernetes/samples/charts/ingress-per-domain \ + charts/ingress-per-domain \ --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ + --values charts/ingress-per-domain/values.yaml \ --set "traefik.hostname=$(hostname -f)" ``` 1. Verify the created ingress per domain details: diff --git a/docs-source/content/wcportal-domains/cleanup-domain-setup.md b/docs-source/content/wcportal-domains/cleanup-domain-setup.md index efbcf1b75..bb01ea653 100644 --- a/docs-source/content/wcportal-domains/cleanup-domain-setup.md +++ b/docs-source/content/wcportal-domains/cleanup-domain-setup.md @@ -11,7 +11,7 @@ To clean up the Oracle WebCenter Portal domain setup, follow the steps below. #### Delete the Generated Domain Home -To remove a domain home that you generated by running the `create-domain.sh` script in your production or testing environment, use the `delete-domain-job.yaml` file located at, `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/domain-home-on-pv/output/weblogic-domains/wcp-domain>` directory. +To remove a domain home that you generated by running the `create-domain.sh` script in your production or testing environment, use the `delete-domain-job.yaml` file located at, `<$WORKDIR>/create-wcp-domain/domain-home-on-pv/output/weblogic-domains/wcp-domain>` directory. ``` $ kubectl create -f delete-domain-job.yaml diff --git a/docs-source/content/wcportal-domains/create-or-update-image/_index.md b/docs-source/content/wcportal-domains/create-or-update-image/_index.md index 287554423..b3b836a46 100644 --- a/docs-source/content/wcportal-domains/create-or-update-image/_index.md +++ b/docs-source/content/wcportal-domains/create-or-update-image/_index.md @@ -106,7 +106,7 @@ To create an Oracle WebCenter Portal Docker image using the WebLogic Image Tool, ```bash $ mkdir -p imagetool-setup/docker-images/OracleWebCenterPortal/imagetool/12.2.1.4.0 $ cd imagetool-setup/docker-images/OracleWebCenterPortal/imagetool/12.2.1.4.0 - $ cp -rf ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/imagetool-scripts/* . + $ cp -rf ${WORKDIR}/imagetool-scripts/* . ``` >Note: To create the image, continue with the following steps. To update the image, see [update an image](#update-an-image). @@ -226,6 +226,7 @@ The following files in the code repository location `/ --version=12.2.1.4.0 --tag=oracle/wcportal:12.2.1.4 --pull + --fromImage ghcr.io/oracle/oraclelinux:7-slim --additionalBuildCommands /docker-images/OracleWebCenterPortal/imagetool/12.2.1.4.0/additionalBuildCmds.txt --additionalBuildFiles /docker-images/OracleWebCenterPortal/dockerfiles/12.2.1.4/container-scripts --opatchBugNumber 28186730_13.9.4.2.5 @@ -236,7 +237,7 @@ The following files in the code repository location `/ > * `--version` value must match the `--version` value used in the `imagetool cache addInstaller` command for `--type wcp`. > * `--pull` always pulls the latest base Linux image `oraclelinux:7-slim` from the Docker registry. This flag can be removed if you want to use the Linux image `oraclelinux:7-slim`, which is already available on the host where the WCP image is created. - Refer to [this page](https://github.com/oracle/weblogic-image-tool/blob/master/site/create-image.md) for the complete list of options available with the WebLogic Image Tool `create` command. + Refer to [this page](https://oracle.github.io/weblogic-image-tool/userguide/tools/create-image/) for the complete list of options available with the WebLogic Image Tool `create` command. 1. Create the Oracle WebCenter Portal image: @@ -422,7 +423,7 @@ After [setting up the WebLogic Image Tool]({{< relref "/wcportal-domains/create- * `–-patches` - Multiple patches can be specified as a comma-separated list. * `--tag` - Specify the new tag to be applied for the image being built. - Refer [here](https://github.com/oracle/weblogic-image-tool/blob/master/site/update-image.md) for the complete list of options available with the WebLogic Image Tool `update` command. + Refer [here](https://oracle.github.io/weblogic-image-tool/userguide/tools/update-image/) for the complete list of options available with the WebLogic Image Tool `update` command. > Note: The WebLogic Image Tool cache should have the latest OPatch zip. The WebLogic Image Tool updates the OPatch if it is not already updated in the image. @@ -433,13 +434,13 @@ After [setting up the WebLogic Image Tool]({{< relref "/wcportal-domains/create- $ imagetool update --fromImage oracle/wcportal:12.2.1.4 --tag=wcportal:12.2.1.4-32224021 --patches=32224021_12.2.1.4.0 [INFO ] Image Tool build ID: 50f9b9aa-596c-4bae-bdff-c47c16b4c928 - [INFO ] Temporary directory used for docker build context: /scratch/asirasag/imagetoolcache/builddir/wlsimgbuilder_temp5130105621506307568 - [INFO ] Using patch 28186730_13.9.4.2.5 from cache: /home/asirasag/imagetool-setup/jars/p28186730_139425_Generic.zip + [INFO ] Temporary directory used for docker build context: /scratch/imagetoolcache/builddir/wlsimgbuilder_temp5130105621506307568 + [INFO ] Using patch 28186730_13.9.4.2.5 from cache: /home/imagetool-setup/jars/p28186730_139425_Generic.zip [INFO ] Updating OPatch in final image from version 13.9.4.2.1 to version 13.9.4.2.5 [WARNING] Skipping patch conflict check, no support credentials provided [WARNING] No credentials provided, skipping validation of patches - [INFO ] Using patch 32224021_12.2.1.4 from cache: /home/asirasag/imagetool-setup/jars/p32224021_122140_Generic.zip - [INFO ] docker cmd = docker build --no-cache --force-rm --tag wcportal:12.2.1.4-32224021 --build-arg http_proxy=http://www-proxy.us.oracle.com:80 --build-arg https_proxy=http://www-proxy.us.oracle.com:80 --build-arg no_proxy=localhost,127.0.0.0/8,.us.oracle.com,.oraclecorp.com,/var/run/docker.sock,100.111.157.155 /scratch/asirasag/imagetoolcache/builddir/wlsimgbuilder_temp5130105621506307568 + [INFO ] Using patch 32224021_12.2.1.4 from cache: /home/imagetool-setup/jars/p32224021_122140_Generic.zip + [INFO ] docker cmd = docker build --no-cache --force-rm --tag wcportal:12.2.1.4-32224021 --build-arg http_proxy=http:// --build-arg https_proxy=http:// --build-arg no_proxy=,/var/run/docker.sock /wlstmp/wlsimgbuilder_temp5130105621506307568 Sending build context to Docker daemon 192.4MB Step 1/9 : FROM oracle/wcportal:12.2.1.4 as final_build @@ -1087,13 +1088,13 @@ After [setting up the WebLogic Image Tool]({{< relref "/wcportal-domains/create- $ imagetool update --fromImage oracle/wcportal:12.2.1.4 --tag=wcportal:12.2.1.4-30761841 --patches=30761841_12.2.1.4.0 --dryRun [INFO ] Image Tool build ID: a473ba32-84b6-4374-9425-9e92ac90ee87 - [INFO ] Temporary directory used for docker build context: /scratch/asirasag/imagetoolcache/builddir/wlsimgbuilder_temp874401188519547557 - [INFO ] Using patch 28186730_13.9.4.2.5 from cache: /home/asirasag/imagetool-setup/jars/p28186730_139425_Generic.zip + [INFO ] Temporary directory used for docker build context: /scratch/imagetoolcache/builddir/wlsimgbuilder_temp874401188519547557 + [INFO ] Using patch 28186730_13.9.4.2.5 from cache: /home/imagetool-setup/jars/p28186730_139425_Generic.zip [INFO ] Updating OPatch in final image from version 13.9.4.2.1 to version 13.9.4.2.5 [WARNING] Skipping patch conflict check, no support credentials provided [WARNING] No credentials provided, skipping validation of patches - [INFO ] Using patch 32224021_12.2.1.4 from cache: /home/asirasag/imagetool-setup/jars/p32224021_122140_Generic.zip - [INFO ] docker cmd = docker build --no-cache --force-rm --tag wcportal:12.2.1.4-32224021 --build-arg http_proxy=http://www-proxy.us.oracle.com:80 --build-arg https_proxy=http://www-proxy.us.oracle.com:80 --build-arg no_proxy=localhost,127.0.0.0/8,.us.oracle.com,.oraclecorp.com,/var/run/docker.sock,100.111.157.155 /scratch/asirasag/imagetoolcache/builddir/wlsimgbuilder_temp874401188519547557 + [INFO ] Using patch 32224021_12.2.1.4 from cache: /home/imagetool-setup/jars/p32224021_122140_Generic.zip + [INFO ] docker cmd = docker build --no-cache --force-rm --tag wcportal:12.2.1.4-32224021 --build-arg http_proxy=http:// --build-arg https_proxy=http:// --build-arg no_proxy=,/var/run/docker.sock /wlstmp/wlsimgbuilder_temp874401188519547557 ########## BEGIN DOCKERFILE ########## # # Copyright (c) 2019, 2021, Oracle and/or its affiliates. diff --git a/docs-source/content/wcportal-domains/installguide/configure-wcp-search/_index.md b/docs-source/content/wcportal-domains/installguide/configure-wcp-search/_index.md index fc7315aac..21b55bd3c 100644 --- a/docs-source/content/wcportal-domains/installguide/configure-wcp-search/_index.md +++ b/docs-source/content/wcportal-domains/installguide/configure-wcp-search/_index.md @@ -18,7 +18,7 @@ description = "Set up search functionality in Oracle WebCenter Portal using Elas Elasticsearch is a highly scalable search engine. It allows you to store, search, and analyze big volumes of data quickly and provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON document. #### Set Up Persistent Volume and Persistent Volume Claim -Create a Kubernetes PV and PVC (Persistent Volume and Persistent Volume Claim) to store Elasticsearch data. To create PV and PVC, use the deployment YAML configuration file located at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-es-cluster/es-pvpvc.yaml`. +Create a Kubernetes PV and PVC (Persistent Volume and Persistent Volume Claim) to store Elasticsearch data. To create PV and PVC, use the deployment YAML configuration file located at `${WORKDIR}/create-wcp-es-cluster/es-pvpvc.yaml`. ```yaml apiVersion: v1 @@ -54,7 +54,7 @@ To create PV & PVC run the below command: $ kubectl apply -f es-pvpvc.yaml ``` #### Create a Secret -To grant access to Oracle WebCenter Portal, create a Kubernetes secret using the deployment YAML configuration file located at `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-es-cluster/es-secret.yaml` +To grant access to Oracle WebCenter Portal, create a Kubernetes secret using the deployment YAML configuration file located at `${WORKDIR}/create-wcp-es-cluster/es-secret.yaml` ```yaml apiVersion: v1 @@ -79,7 +79,7 @@ To create Kubernetes Secret run the below command: $ kubectl apply -f es-secret.yaml ``` #### Headless Service - Each node in Elasticsearch cluster can communicate using a headless service. Create a headless service using the deployment YAML configuration file located at `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-es-cluster/es-service.yaml` to establish cluster communication. + Each node in Elasticsearch cluster can communicate using a headless service. Create a headless service using the deployment YAML configuration file located at `${WORKDIR}/create-wcp-es-cluster/es-service.yaml` to establish cluster communication. ```yaml apiVersion: v1 kind: Service @@ -104,7 +104,7 @@ To create Headless Service run below command: $ kubectl apply -f es-service.yaml ``` ### LoadBalancer -To access the Elasticsearch service outside of the Kubernetes cluster, create an external loadbalancer. Then access the Elasticsearch service by using the external IP of loadbalancer, create a loadbalancer using the deployment YAML configuration file located at `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-es-cluster/es-loadbalancer.yaml`. +To access the Elasticsearch service outside of the Kubernetes cluster, create an external loadbalancer. Then access the Elasticsearch service by using the external IP of loadbalancer, create a loadbalancer using the deployment YAML configuration file located at `${WORKDIR}/create-wcp-es-cluster/es-loadbalancer.yaml`. ```yaml apiVersion: v1 kind: Service @@ -134,7 +134,7 @@ $ kubectl get svc -n wcpns -l type=external ``` Make a note of the external IP from the above command and use this below sample URL to access Elasticsearch cluster health : http://externalIP:9200/_cluster/health #### Elasticsearch Cluster - Using the Kubernetes StatefulSet controller create an Elasticsearch Cluster comprising of three node using the deployment YAML configuration file located at `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-es-cluster/es-statefulset.yaml` + Using the Kubernetes StatefulSet controller create an Elasticsearch Cluster comprising of three node using the deployment YAML configuration file located at `${WORKDIR}/create-wcp-es-cluster/es-statefulset.yaml` ```yaml apiVersion: apps/v1 diff --git a/docs-source/content/wcportal-domains/installguide/create-wcp-domain/_index.md b/docs-source/content/wcportal-domains/installguide/create-wcp-domain/_index.md index 8e6d922f2..376bc627e 100644 --- a/docs-source/content/wcportal-domains/installguide/create-wcp-domain/_index.md +++ b/docs-source/content/wcportal-domains/installguide/create-wcp-domain/_index.md @@ -29,7 +29,7 @@ You can use the sample scripts to create a WebCenter Portal domain home on an ex If required, you can customize the parameters used for creating a domain in the `create-domain-inputs.yaml` file. -Please note that the sample scripts for the WebCenter Portal domain deployment are available from the previously downloaded repository at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/domain-home-on-pv/`. +Please note that the sample scripts for the WebCenter Portal domain deployment are available from the previously downloaded repository at `${WORKDIR}/create-wcp-domain/domain-home-on-pv/`. Make a copy of the `create-domain-inputs.yaml` file before updating the default values. @@ -38,6 +38,7 @@ The default domain created by the script has the following characteristics: * An Administration Server named `AdminServer` listening on port `7001`. * A configured cluster named `wcp-cluster` of size `5`. * Managed Server, named `wcpserver`, listening on port `8888`. +* If `configurePortletServer` is set to `true` . It configures a cluster named `wcportlet-cluster` of size `5` and Managed Server, named `wcportletserver`, listening on port `8889`. * Log files that are located in `/shared/logs/`. ##### Configuration parameters @@ -47,9 +48,11 @@ The following parameters can be provided in the inputs file: | --- | --- | --- | | `adminPort` | Port number for the Administration Server inside the Kubernetes cluster. | `7001` | | `sslEnabled` | SSL mode enabling flag | `false` | +| `configurePortletServer` |Configure portlet server cluster | `false` | | `adminServerSSLPort` | SSL Port number for the Administration Server inside the Kubernetes cluster. | `7002` | | `adminServerName` | Name of the Administration Server. | `AdminServer` | | `clusterName` | Name of the WebLogic cluster instance to generate for the domain. By default the cluster name is `wcp-cluster` for the WebCenter Portal domain. | `wcp-cluster` | +| `portletClusterName` | Name of the Portlet cluster instance to generate for the domain. By default the cluster name is `wcportlet-cluster` for the Portlet. | `wcportlet-cluster` | | `configuredManagedServerCount` | Number of Managed Server instances for the domain. | `5` | | `createDomainFilesDir` | Directory on the host machine to locate all the files that you need to create a WebLogic domain, including the script that is specified in the `createDomainScriptName` property. By default, this directory is set to the relative path `wlst`, and the *create script* uses the built-in WLST offline scripts in the `wlst` directory to create the WebLogic domain. An absolute path is also supported to point to an arbitrary directory in the file system. The built-in scripts can be replaced by the user-provided scripts or model files as long as those files are in the specified directory. Files in this directory are put into a Kubernetes config map, which in turn is mounted to `createDomainScriptsMountPath,` so that the Kubernetes pod can use the scripts and supporting files to create a domain home. | `wlst` | | `createDomainScriptsMountPath` | Mount path where the *create domain* scripts are located inside a pod. The `create-domain.sh` script creates a Kubernetes job to run the script (specified in the `createDomainScriptName` property) in a Kubernetes pod that creates a domain home. Files in the `createDomainFilesDir` directory are mounted to this location in the pod, so that the Kubernetes pod can use the scripts and supporting files to create a domain home. | `/u01/weblogic` | @@ -59,7 +62,7 @@ The following parameters can be provided in the inputs file: | `domainUID` | Unique ID that identifies this particular domain. Used as the name of the generated WebLogic domain as well as the name of the Kubernetes domain resource. This ID must be unique across all domains in a Kubernetes cluster. This ID cannot contain any character that is not valid in a Kubernetes service name. | `wcp-domain` | | `exposeAdminNodePort` | Boolean indicating if the Administration Server is exposed outside of the Kubernetes cluster. | `false` | | `exposeAdminT3Channel` | Boolean indicating if the T3 administrative channel is exposed outside the Kubernetes cluster. | `false` | -| `image` | WebCenter Portal Docker image. The WebLogic Kubernetes Operator requires WebCenter Portal release 12.2.1.4. Refer to [WebCenter Portal Docker Image](https://github.com/oracle/docker-images/tree/master/OracleWebCenterPortal) for details on how to obtain or create the image. | `oracle/wcportal:12.2.1.4` | +| `image` | WebCenter Portal Docker image. The WebLogic Kubernetes Operator requires WebCenter Portal release 12.2.1.4. Refer to [WebCenter Portal Docker Image](https://github.com/oracle/docker-images/tree/main/OracleWebCenterPortal) for details on how to obtain or create the image. | `oracle/wcportal:12.2.1.4` | | `imagePullPolicy` | WebLogic Docker image pull policy. Legal values are `IfNotPresent`, `Always`, or `Never` | `IfNotPresent` | | `imagePullSecretName` | Name of the Kubernetes secret to access the Docker Store to pull the WebLogic Server Docker image. The presence of the secret is validated when this parameter is specified. | | | `includeServerOutInPodLog` | Boolean indicating whether to include *server.out* to the pod's stdout. | `true` | @@ -67,20 +70,23 @@ The following parameters can be provided in the inputs file: | `javaOptions` | Java options for starting the Administration Server and Managed Servers. A Java option can include references to one or more of the following pre-defined variables to obtain WebLogic domain information: `$(DOMAIN_NAME)`, `$(DOMAIN_HOME)`, `$(ADMIN_NAME)`, `$(ADMIN_PORT)`, and `$(SERVER_NAME)`. | `-Dweblogic.StdoutDebugEnabled=false` | | `logHome` | The in-pod location for the domain log, server logs, server out, and Node Manager log files. `This field cannot be modified.` | `/u01/oracle/user_projects/logs/wcp-domain` | | `managedServerNameBase` | Base string used to generate Managed Server names. | `wcpserver` | -| `managedServerPort` | Port number for each Managed Server. | `8888` | -| `managedServerSSLPort` | SSL port number for each Managed Server. | `8889` | +| `portletServerNameBase` | Base string used to generate Portlet Server names. | `wcportletserver` | +| `managedServerPort` | Port number for each Managed Server. By default the managedServerPort is `8888` for the `wcpserver` and managedServerPort is `8889` for the `wcportletserver`. | `8888` | +| `managedServerSSLPort` | SSL port number for each Managed Server. By default the managedServerPort is `8788` for the wcpserver and managedServerPort is `8789` for the `wcportletserver`. | `8788` | +| `portletServerPort` |Port number for each Portlet Server. By default the portletServerPort is `8889` for the `wcportletserver`. | `8888` | +| `portletServerSSLPort` |SSL port number for each Portlet Server. By default the portletServerSSLPort is `8789` for the `wcportletserver`. | `8789` | | `namespace` | Kubernetes namespace in which to create the domain. | `wcpns` | | `persistentVolumeClaimName` | Name of the persistent volume claim created to host the domain home. If not specified, the value is derived from the `domainUID` as `-weblogic-sample-pvc`. | `wcp-domain-domain-pvc` | | `productionModeEnabled` | Boolean indicating if production mode is enabled for the domain. | `true` | | `serverStartPolicy` | Determines which WebLogic Server instances are to be started. Legal values are `NEVER`, `IF_NEEDED`, `ADMIN_ONLY`. | `IF_NEEDED` | | `t3ChannelPort` | Port for the T3 channel of the *NetworkAccessPoint*. | `30012` | | `t3PublicAddress` | Public address for the T3 channel. This should be set to the public address of the Kubernetes cluster. This would typically be a load balancer address.

For development environments only: In a single server (all-in-one) Kubernetes deployment, this may be set to the address of the master, or at the very least, it must be set to the address of one of the worker nodes. | If not provided, the script will attempt to set it to the IP address of the Kubernetes cluster. | -| `weblogicCredentialsSecretName` | Name of the Kubernetes secret for the Administration Server's user name and password. If not specified, then the value is derived from the `domainUID` as `-weblogic-credentials`. | wcpinfra-domain-credentials +| `weblogicCredentialsSecretName` | Name of the Kubernetes secret for the Administration Server's user name and password. If not specified, then the value is derived from the `domainUID` as `-weblogic-credentials`. | wcp-domain-domain-credentials | `weblogicImagePullSecretName` | Name of the Kubernetes secret for the Docker Store, used to pull the WebLogic Server image. | | | `serverPodCpuRequest`, `serverPodMemoryRequest`, `serverPodCpuCLimit`, `serverPodMemoryLimit` | The maximum amount of compute resources allowed and minimum amount of compute resources required for each server pod. Please refer to the Kubernetes documentation on `Managing Compute Resources for Containers` for details. | Resource requests and resource limits are not specified. Refer to [WebCenter Portal Cluster Sizing Recommendations](../pre-requisites/#webcenter-portal-cluster-sizing-recommendations) for more details. | | `rcuSchemaPrefix` | The schema prefix to use in the database, for example `WCP1`. You may wish to make this the same as the domainUID in order to simplify matching domain to their RCU schemas. | `WCP1` | | `rcuDatabaseURL` | The database URL. | `dbhostname:dbport/servicename` | -| `rcuCredentialsSecret` | The Kubernetes secret containing the database credentials. | `wcpinfra-rcu-credentials` | +| `rcuCredentialsSecret` | The Kubernetes secret containing the database credentials. | `wcp-domain-rcu-credentials` | | `loadBalancerHostName` | Host name for the final url accessible outside K8S environment. | `abc.def.com` | | `loadBalancerPortNumber` | Port for the final url accessible outside K8S environment. | `30305` | | `loadBalancerProtocol` | Protocol for the final url accessible outside K8S environment. | `http` | @@ -120,7 +126,7 @@ or `kubectl apply -f` command: 1. Run the `create-domain.sh` sample script, pointing it at the `create-domain-inputs.yaml` inputs file and an output directory like below: ```bash - $ cd <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/ + $ cd ${WORKDIR}/create-wcp-domain/ $ sh create-domain.sh -i create-domain-inputs.yaml -o output Input parameters being used export version="create-weblogic-sample-domain-inputs-v1" @@ -136,11 +142,13 @@ or `kubectl apply -f` command: export initialManagedServerReplicas="2" export managedServerNameBase="wcpserver" export managedServerPort="8888" - export managedServerSSLPort="8889" + export managedServerSSLPort="8788" + export portletServerPort="8889" + export portletServerSSLPort="8789" export image="oracle/wcportal:12.2.1.4" export imagePullPolicy="IfNotPresent" export productionModeEnabled="true" - export weblogicCredentialsSecretName="wcpinfra-domain-credentials" + export weblogicCredentialsSecretName="wcp-domain-domain-credentials" export includeServerOutInPodLog="true" export logHome="/u01/oracle/user_projects/domains/logs/$domainUID" export httpAccessLogInLogHome="true" @@ -157,7 +165,7 @@ or `kubectl apply -f` command: export createDomainFilesDir="wlst" export rcuSchemaPrefix="WCP1" export rcuDatabaseURL="oracle-db.wcpns.svc.cluster.local:1521/devpdb.k8s" - export rcuCredentialsSecret="wcpinfra-rcu-credentials" + export rcuCredentialsSecret="wcp-domain-rcu-credentials" export loadBalancerHostName="abc.def.com" export loadBalancerPortNumber="30305" export loadBalancerProtocol="http" @@ -167,7 +175,7 @@ or `kubectl apply -f` command: Generating output/weblogic-domains/wcp-domain/create-domain-job.yaml Generating output/weblogic-domains/wcp-domain/delete-domain-job.yaml Generating output/weblogic-domains/wcp-domain/domain.yaml - Checking to see if the secret wcpinfra-domain-credentials exists in namespace wcpns + Checking to see if the secret wcp-domain-domain-credentials exists in namespace wcpns configmap/wcp-domain-create-wcp-infra-sample-domain-job-cm created Checking the configmap wcp-domain-create-wcp-infra-sample-domain-job-cm was created configmap/wcp-domain-create-wcp-infra-sample-domain-job-cm labeled @@ -220,15 +228,15 @@ or `kubectl apply -f` command: The domain will be created using the script /u01/weblogic/create-domain-script.sh Initializing WebLogic Scripting Tool (WLST) ... - - + + Welcome to WebLogic Server Administration Scripting Shell - + Type help() for help on available commands - + ================================================================= - WebCenter Portal Weblogic Operator Domain Creation Script - 12.2.1.4.0 + WebCenter Portal Weblogic Operator Domain Creation Script + 12.2.1.4.0 ================================================================= Creating Base Domain... Creating Admin Server... @@ -239,6 +247,11 @@ or `kubectl apply -f` command: managed server name is wcpserver4 managed server name is wcpserver5 ['wcpserver1', 'wcpserver2', 'wcpserver3', 'wcpserver4', 'wcpserver5'] + Creating porlet cluster... + managed server name is wcportletserver1 + managed server name is wcportletserver2 + managed server name is wcportletserver3 + ['wcportletserver1', 'wcportletserver2', 'wcportletserver3', 'wcportletserver4', 'wcportletserver5'] Managed servers created... Creating Node Manager... Will create Base domain at /u01/oracle/user_projects/domains/wcp-domain @@ -261,16 +274,20 @@ or `kubectl apply -f` command: Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:wcpserver3 Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:wcpserver4 Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:wcpserver5 + Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:wcportletserver1 + Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:wcportletserver2 + Set CoherenceClusterSystemResource to defaultCoherenceCluster for server:wcportletserver3 Targeting Cluster ... Set CoherenceClusterSystemResource to defaultCoherenceCluster for cluster:wcp-cluster Set WLS clusters as target of defaultCoherenceCluster:wcp-cluster + Set CoherenceClusterSystemResource to defaultCoherenceCluster for cluster:wcportlet-cluster + Set WLS clusters as target of defaultCoherenceCluster:wcportlet-cluster Preparing to update domain... Jan 12, 2021 10:30:09 AM oracle.security.jps.az.internal.runtime.policy.AbstractPolicyImpl initializeReadStore INFO: Property for read store in parallel: oracle.security.jps.az.runtime.readstore.threads = null Domain updated successfully Domain Creation is done... - Successfully Completed - + Successfully Completed ``` #### Initialize the WebCenter Portal Domain @@ -306,12 +323,17 @@ pod/wcp-domain-adminserver 1/1 Running 0 pod/wcp-domain-create-fmw-infra-sample-domain-job-8jr6k 0/1 Completed 0 3h12m pod/wcp-domain-wcp-server1 1/1 Running 0 11m pod/wcp-domain-wcp-server2 1/1 Running 0 11m +pod/wcp-domain-wcportletserver1 1/1 Running 1 21h + + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/wcp-domain-adminserver ClusterIP None 7001/TCP 13m +service/wcp-domain-cluster-wcp-cluster ClusterIP 10.98.145.173 8888/TCP 11m +service/wcp-domain-wcp-server1 ClusterIP None 8888/TCP 11m +service/wcp-domain-wcp-server2 ClusterIP None 8888/TCP 11m +service/wcp-domain-cluster-wcportlet-cluster ClusterIP 10.98.145.173 8889/TCP 11m +service/wcp-domain-wcportletserver1 ClusterIP None 8889/TCP 11m -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -service/wcp-domain-adminserver ClusterIP None 7001/TCP 13m -service/wcp-domain-cluster-wcp-cluster ClusterIP 10.98.145.173 8888/TCP 11m -service/wcp-domain-wcp-server1 ClusterIP None 8888/TCP 11m -service/wcp-domain-wcp-server2 ClusterIP None 8888/TCP 11m NAME COMPLETIONS DURATION AGE job.batch/wcp-domain-create-fmw-infra-sample-domain-job 1/1 16m 3h12m @@ -345,6 +367,8 @@ wcp-domain-adminserver 1/1 Running 0 wcp-domain-create-fmw-infra-sample-domain-job-8jr6k 0/1 Completed 0 3h14m wcp-domain-wcp-server1 1/1 Running 0 14m wcp-domain-wcp-server2 1/1 Running 0 14m +wcp-domain-wcportletserver1 1/1 Running 1 14m + ``` #### Verify the Services @@ -358,11 +382,14 @@ $ kubectl get services -n NAMESPACE Here is an example of the output of this command: ``` -bash-4.2$ kubectl get services -n wcpns -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -wcp-domain-adminserver ClusterIP None 7001/TCP 17m -wcp-domain-cluster-wcp-cluster ClusterIP 10.98.145.173 8888/TCP 14m -wcp-domain-wcp-server1 ClusterIP None 8888/TCP 14m -wcp-domain-wcp-server2 ClusterIP None 8888/TCP 14m +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +wcp-domain-adminserver ClusterIP None 7001/TCP 17m +wcp-domain-cluster-wcp-cluster ClusterIP 10.98.145.173 8888/TCP 14m +wcp-domain-wcp-server1 ClusterIP None 8888/TCP 14m +wcp-domain-wcp-server2 ClusterIP None 8888/TCP 14m +wcp-domain-cluster-wcportlet-cluster ClusterIP 10.98.145.173 8889/TCP 14m +wcp-domain-wcportletserver1 ClusterIP None 8889/TCP 14m + ``` #### Managing WebCenter Portal diff --git a/docs-source/content/wcportal-domains/installguide/prepare-your-environment/_index.md b/docs-source/content/wcportal-domains/installguide/prepare-your-environment/_index.md index 0eea74c32..edd9695ce 100644 --- a/docs-source/content/wcportal-domains/installguide/prepare-your-environment/_index.md +++ b/docs-source/content/wcportal-domains/installguide/prepare-your-environment/_index.md @@ -44,7 +44,7 @@ After creating Kubernetes clusters, you can optionally: ### Obtain the Oracle WebCenter Portal Docker Image The Oracle WebCenter Portal image with latest bundle patch and required interim patches can be obtained from My Oracle Support (MOS). This is the only image supported for production deployments. Follow the below steps to download the Oracle WebCenter Portal image from My Oracle Support. -1. Download patch [32688937](https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?patchId=32688937) from My Oracle Support (MOS). +1. Download patch [33807917](https://support.oracle.com/epmos/faces/ui/patch/PatchDetail.jspx?patchId=33807917) from My Oracle Support (MOS). 1. Unzip the downloaded patch zip file. @@ -52,8 +52,8 @@ The Oracle WebCenter Portal image with latest bundle patch and required interim For example: ```bash - $ docker load < wcportal-12.2.1.4.0-210326.0857.320.tar - Loaded image: oracle/wcportal:12.2.1.4.0-210326.0857.320 + $ docker load < wcportal-12.2.1.4-jdk8-ol7-220203.0823.tar + Loaded image: oracle/wcportal:12.2.1.4-jdk8-ol7-220203.0823 ``` If you want to build and use an Oracle WebCenter Portal Docker image with any additional bundle patch or interim patches that are not part of the image obtained from My Oracle Support, then follow these [steps]({{< relref "/wcportal-domains/create-or-update-image/">}}) to create the image. @@ -81,7 +81,7 @@ $ docker login https://container-registry.oracle.com (enter your Oracle email Id WebLogic Kubernetes Operator image: ```bash -$ docker pull ghcr.io/oracle/weblogic-kubernetes-operator:3.1.1 +$ docker pull ghcr.io/oracle/weblogic-kubernetes-operator:3.3.0 ``` @@ -104,35 +104,19 @@ Oracle WebCenter Portal domain deployment on Kubernetes leverages the WebLogic K 1. Create a working directory to set up the source code. ```bash - $ export WORKDIR=$HOME/wcp_3.1.1 - $ mkdir - $ cd + $ mkdir $HOME/wcp_22.2.3 + $ cd $HOME/wcp_22.2.3 ``` -1. Download the supported version of WebLogic Kubernetes Operator source code archive file (`.zip`/`.tar.gz`) from the operator [relases page](https://github.com/oracle/weblogic-kubernetes-operator/releases). You can also download the supported operator version from [3.1.1](https://github.com/oracle/weblogic-kubernetes-operator/archive/v3.1.1.zip). - ```bash - $ git clone https://github.com/oracle/weblogic-kubernetes-operator.git --branch release/3.1.1 - ``` -1. Download the WebCenter Portal Kubernetes deployment scripts from this [repository](https://github.com/oracle/fmw-kubernetes.git) and copy them in to WebLogic operator samples location. +1. Download the Oracle WebCenter Portal Kubernetes deployment scripts from the Github [repository](https://github.com/oracle/fmw-kubernetes). Required artifacts are available at `OracleWeCenterPortal/kubernetes`. ```bash - $ git clone https://github.com/oracle/fmw-kubernetes.git --branch release/21.2.3 - - $ cp -rf ${WORKDIR}/fmw-kubernetes/OracleWebCenterPortal/kubernetes/create-wcp-domain ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/ - $ cp -rf ${WORKDIR}/fmw-kubernetes/OracleWebCenterPortal/kubernetes/ingress-per-domain ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ - $ cp -rf ${WORKDIR}/fmw-kubernetes/OracleWebCenterPortal/kubernetes/create-wcp-es-cluster ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/ - $ cp -rf ${WORKDIR}/fmw-kubernetes/OracleWebCenterPortal/kubernetes/imagetool-scripts ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/ - $ cp -rf ${WORKDIR}/fmw-kubernetes/OracleWebCenterPortal/kubernetes/charts ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/ + $ git clone https://github.com/oracle/fmw-kubernetes.git + $ export WORKDIR=$HOME/wcp_22.2.3/fmw-kubernetes/OracleWebCenterPortal/kubernetes/ ``` -You can now use the deployment scripts from `<$WORKDIR>/weblogic-kubernetes-operator` to set up the WebCenter Portal domain as described later in this document. - -Your home directory for running all the required scripts: - -```bash -$ cd <$WORKDIR>/weblogic-kubernetes-operator -``` +You can now use the deployment scripts from `<$WORKDIR>` to set up the WebCenter Portal domain as described later in this document. ### Grant Roles and Clear Stale Resources @@ -179,7 +163,8 @@ $ cd <$WORKDIR>/weblogic-kubernetes-operator > Helm install weblogic-operator ```bash - $ helm install weblogic-kubernetes-operator kubernetes/charts/weblogic-operator --namespace operator-ns --set serviceAccount=operator-sa --set "domainNamespaces={}" --wait + $ cd ${WORKDIR} + $ helm install weblogic-kubernetes-operator charts/weblogic-operator --namespace operator-ns --set serviceAccount=operator-sa --set "domainNamespaces={}" --wait NAME: weblogic-kubernetes-operator LAST DEPLOYED: Wed Jan 6 01:47:33 2021 @@ -246,7 +231,7 @@ $ kubectl create namespace wcpns >Helm upgrade weblogic-operator ```bash $ helm upgrade --reuse-values --set "domainNamespaces={wcpns}" \ - --wait weblogic-kubernetes-operator kubernetes/charts/weblogic-operator --namespace operator-ns + --wait weblogic-kubernetes-operator charts/weblogic-operator --namespace operator-ns NAME: weblogic-kubernetes-operator LAST DEPLOYED: Wed Jan 6 01:52:58 2021 @@ -261,13 +246,12 @@ $ kubectl create namespace wcpns Using the create-weblogic-credentials script, create a Kubernetes secret that contains the user name and password for the domain in the same Kubernetes namespace as the domain: ```bash -$ sh kubernetes/samples/scripts/create-weblogic-domain-credentials/create-weblogic-credentials.sh \ - -u weblogic -p welcome1 -n wcpns \ - -d wcp-domain -s wcpinfra-domain-credentials + $ cd ${WORKDIR}/create-weblogic-domain-credentials + $ ./create-weblogic-credentials.sh -u weblogic -p welcome1 -n wcpns -d wcp-domain -s wcp-domain-domain-credentials - secret/wcpinfra-domain-credentials created - secret/wcpinfra-domain-credentials labeled - The secret wcpinfra-domain-credentials has been successfully created in the wcpns namespace. + secret/wcp-domain-domain-credentials created + secret/wcp-domain-domain-credentials labeled + The secret wcp-domain-domain-credentials has been successfully created in the wcpns namespace. ``` Where: @@ -275,23 +259,24 @@ $ sh kubernetes/samples/scripts/create-weblogic-domain-credentials/create-weblog * welcome1 is the weblogic password * wcp-domain is the domain name * wcpns is the domain namespace - * wcpinfra-domain-credentials is the secret name + * wcp-domain-domain-credentials is the secret name Note: You can inspect the credentials as follows: ```bash - $ kubectl get secret wcpinfra-domain-credentials -o yaml -n wcpns + $ kubectl get secret wcp-domain-domain-credentials -o yaml -n wcpns ``` #### Create a Kubernetes secret with the RCU credentials Create a Kubernetes secret for the Repository Configuration Utility (user name and password) using the `create-rcu-credentials.sh` script in the same Kubernetes namespace as the domain: ```bash - $ sh kubernetes/samples/scripts/create-rcu-credentials/create-rcu-credentials.sh \ + $ cd ${WORKDIR}/create-rcu-credentials + $ sh create-rcu-credentials.sh \ -u WCP1 -p welcome1 -a sys -q Oradoc_db1 -n wcpns \ - -d wcp-domain -s wcpinfra-rcu-credentials + -d wcp-domain -s wcp-domain-rcu-credentials - secret/wcpinfra-rcu-credentials created - secret/wcpinfra-rcu-credentials labeled - The secret wcpinfra-rcu-credentials has been successfully created in the wcpns namespace. + secret/wcp-domain-rcu-credentials created + secret/wcp-domain-rcu-credentials labeled + The secret wcp-domain-rcu-credentials has been successfully created in the wcpns namespace. ``` Where: @@ -300,12 +285,12 @@ $ sh kubernetes/samples/scripts/create-weblogic-domain-credentials/create-weblog * Oradoc_db1 is the database SYS users password * wcp-domain is the domain name * wcpns is the domain namespace - * wcpinfra-rcu-credentials is the secret name + * wcp-domain-rcu-credentials is the secret name Note: You can inspect the credentials as follows: ```bash - $ kubectl get secret wcpinfra-rcu-credentials -o yaml -n wcpns + $ kubectl get secret wcp-domain-rcu-credentials -o yaml -n wcpns ``` #### Create a persistent storage for an Oracle WebCenter Portal domain @@ -313,7 +298,7 @@ $ sh kubernetes/samples/scripts/create-weblogic-domain-credentials/create-weblog In the Kubernetes namespace you created, create the PV and PVC for the domain by running the [create-pv-pvc.sh](https://oracle.github.io/weblogic-kubernetes-operator/samples/simple/storage/) script. Follow the instructions for using the script to create a dedicated PV and PVC for the Oracle WebCenter Portal domain. - * Review the configuration parameters for PV creation [here](https://oracle.github.io/weblogic-kubernetes-operator/samples/simple/storage/#configuration-parameters). Based on your requirements, update the values in the `create-pv-pvc-inputs.yaml` file located at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc/`. Sample configuration parameter values for an Oracle WebCenter Portal domain are: + * Review the configuration parameters for PV creation [here](https://oracle.github.io/weblogic-kubernetes-operator/samples/simple/storage/#configuration-parameters). Based on your requirements, update the values in the `create-pv-pvc-inputs.yaml` file located at `${WORKDIR}/create-weblogic-domain-pv-pvc/`. Sample configuration parameter values for an Oracle WebCenter Portal domain are: * `baseName`: domain * `domainUID`: wcp-domain * `namespace`: wcpns @@ -323,7 +308,7 @@ $ sh kubernetes/samples/scripts/create-weblogic-domain-credentials/create-weblog * Ensure that the path for the `weblogicDomainStoragePath` property exists (create one if it doesn't exist), that it has full access permissions, and that the folder is empty. * Run the `create-pv-pvc.sh` script: ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-weblogic-domain-pv-pvc + $ cd ${WORKDIR}/create-weblogic-domain-pv-pvc $ ./create-pv-pvc.sh -i create-pv-pvc-inputs.yaml -o output Input parameters being used export version="create-weblogic-sample-domain-pv-pvc-inputs-v1" @@ -355,19 +340,42 @@ For production deployments, you must set up and use a standalone (non-container) Before creating a domain, you need to set up the necessary schemas in your database. #### Run the Repository Creation Utility to set up your database schemas - Run a container to create Repository Creation Utility. + To create the database schemas for Oracle WebCenter Portal domain, run the create-rcu-schema.sh script. ```bash - $ kubectl run rcu --generator=run-pod/v1 --image oracle/wcportal:12.2.1.4 -n wcpns -- sleep infinity - #check the status of rcu pod - $ kubectl get pods -n wcpns - #make sure rcu pod status is running before executing this - $ kubectl exec -n wcpns -ti rcu /bin/bash - export CONNECTION_STRING=databasehostname:/ - export RCUPREFIX=WCP1 - echo -e "\n" > /tmp/pwd.txt - /u01/oracle/oracle_common/bin/rcu -silent -dropRepository -databaseType ORACLE -connectString $CONNECTION_STRING -dbUser sys -dbRole sysdba -selectDependentsForComponents true -schemaPrefix $RCUPREFIX -component OPSS -component IAU_VIEWER -component WEBCENTER -component MDS -component IAU_APPEND -component STB -component IAU -component WLS -component ACTIVITIES -f < /tmp/pwd.txt - /u01/oracle/oracle_common/bin/rcu -silent -createRepository -databaseType ORACLE -connectString $CONNECTION_STRING -dbUser sys -dbRole sysdba -useSamePasswordForAllSchemaUsers true -selectDependentsForComponents true -schemaPrefix $RCUPREFIX -component OPSS -component IAU_VIEWER -component WEBCENTER -component MDS -component IAU_APPEND -component STB -component IAU -component WLS -component ACTIVITIES -tablespace USERS -tempTablespace TEMP -f < /tmp/pwd.txt - #exit from the container - exit - ``` \ No newline at end of file + $ cd ${WORKDIR}/create-rcu-schema + $ sh create-rcu-schema.sh -h + usage: create-rcu-schema.sh -s -t -d -i -u -p -n -q -r -o [-h] + -s RCU Schema Prefix (required) + -t RCU Schema Type (optional) + (supported values: wcp(default), wcpp) + -d RCU Oracle Database URL (optional) + (default: oracle-db.default.svc.cluster.local:1521/devpdb.k8s) + -p FMW Infrastructure ImagePullSecret (optional) + (default: none) + -i Oracle WebCenter Portal Image (optional) + (default: oracle/wcportal:12.2.1.4) + -u FMW Infrastructure ImagePullPolicy (optional) + (default: IfNotPresent) + -n Namespace for RCU pod (optional) + (default: default) + -q password for database SYSDBA user. (optional) + (default: Oradoc_db1) + -r password for all schema owner (regular user). (optional) + (default: Oradoc_db1) + -o Output directory for the generated YAML file. (optional) + (default: rcuoutput) + -c Comma-separated variables in the format variablename=value. (optional). + (default: none) + -h Help + + $ ./create-rcu-schema.sh \ + -s WCP1 \ + -t wcp \ + -d oracle-db.default.svc.cluster.local:1521/devpdb.k8s \ + -i oracle/wcportal:12.2.1.4\ + -n wcpns \ + -q Oradoc_db1 \ + -r welcome1 + ``` +> Where RCU Schema type `wcp` generates webcenter portal related schema and `wcpp` generates webcenter portal plus portlet schemas. \ No newline at end of file diff --git a/docs-source/content/wcportal-domains/installguide/prerequisites/_index.md b/docs-source/content/wcportal-domains/installguide/prerequisites/_index.md index c20f0f5bb..c706b05f7 100644 --- a/docs-source/content/wcportal-domains/installguide/prerequisites/_index.md +++ b/docs-source/content/wcportal-domains/installguide/prerequisites/_index.md @@ -19,11 +19,11 @@ Other than those considerations listed here, the WebCenter Portal domain works i In this release, WebCenter Portal domain is based on the `domain on a persistent volume` [model](https://oracle.github.io/weblogic-kubernetes-operator/userguide/managing-domains/choosing-a-model/) where a WebCenter Portal domain is located in a persistent volume (PV). #### System Requirements -* Kubernetes 1.14.8+, 1.15.7+, 1.16.0+, 1.17.0+, and 1.18.0+ (check with `kubectl version`). -* Flannel networking v0.9.1-amd64 or later (check with `docker images | grep flannel`). -* Docker 18.9.1 or 19.03.1 (check with `docker version`). -* Helm 3.1.3+ (check with `helm version`). -* WebLogic Kubernetes operator 3.1.1 (see [the operator releases](https://github.com/oracle/weblogic-kubernetes-operator/releases/tag/v3.1.1) page). +* Kubernetes 1.18.18+, 1.19.7+, and 1.20.6+ (check with `kubectl version`). +* Flannel networking v0.14.0 or later (check with `docker images | grep flannel`), Calico networking v3.15. +* Docker 19.03.11+ (check with `docker version`). +* Helm 3.4+ (check with `helm version`). +* WebLogic Kubernetes operator 3.3.0 (see [the operator releases](https://github.com/oracle/weblogic-kubernetes-operator/releases/tag/v3.3.0) page). * Oracle WebCenter Portal 12.2.1.4.0 image. * These proxy setups are used for pulling the required binaries and source code from the respective repositories: * export NO_PROXY="localhost,127.0.0.0/8,$(hostname -i),.your-company.com,/var/run/docker.sock" @@ -43,7 +43,7 @@ following limitations currently exist for a WebCenter Portal domain: * `Domain in image` model is not supported in this version of the operator. * Only configured clusters are supported. Dynamic clusters are not supported on WebCenter Portal domains. Note that you can still use all of the scaling features. You just need to define the maximum size of your cluster at the time when you create a domain. * At present, WebCenter Portal doesn't run on non-Linux containers. -* Deploying and running a WebCenter Portal domain is supported only in the operator versions 3.1.1 and later. +* Deploying and running a WebCenter Portal domain is supported only in the operator versions 3.3.0 and later. * The [WebLogic Logging Exporter](https://github.com/oracle/weblogic-logging-exporter) currently supports WebLogic Server logs only. Other logs are not sent to Elasticsearch. Note, however, that you can use a sidecar with a log handling tool like Fluentd to get logs. * The [WebLogic Monitoring Exporter](https://github.com/oracle/weblogic-monitoring-exporter) diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/_index.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/_index.md index 4cdf23135..720b12ad0 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/_index.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/_index.md @@ -7,7 +7,7 @@ pre = " " description = "Configure different load balancers for the Oracle WebCenter Portal domain." +++ -The WebLogic Kubernetes Operator supports ingress-based load balancers such as Traefik, NGINX (kubernetes/ingress-nginx) and Voyager. It also supports the Apache webtier load balancer. +The WebLogic Kubernetes Operator supports ingress-based load balancers such as Traefik and NGINX (kubernetes/ingress-nginx) . It also supports the Apache webtier load balancer. {{% children style="h4" description="true" %}} diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/apachewebtier.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/apachewebtier.md index f7948a7b7..d7d5262bf 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/apachewebtier.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/apachewebtier.md @@ -28,7 +28,7 @@ To build the Apache webtier Docker image, refer to the [sample](https://github.c {{%expand "Click here to see the sample content of the configuration file custom_mod_wl_apache.conf for wcp-domain domain" %}} ```bash -$ cat <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/charts/apache-samples/custom-sample/custom_mod_wl_apache.conf +$ cat ${WORKDIR}/charts/apache-samples/custom-sample/custom_mod_wl_apache.conf #Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. # @@ -76,16 +76,28 @@ WLSRequest On WebLogicCluster wcp-domain-cluster-wcp-cluster:8888 PathTrim /weblogic1 + + +WLSRequest On +WebLogicCluster wcp-domain-cluster-wcportlet-cluster:8889 +PathTrim /weblogic1 + + + +WLSRequest On +WebLogicCluster wcp-domain-cluster-wcportlet-cluster:8889 +PathTrim /weblogic1 + ``` {{% /expand %}} -1. Update `persistentVolumeClaimName` in `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/charts/apache-samples/custom-sample/input.yaml`with Persistence Volume which contains your own custom_mod_wl_apache.conf file. Use the PV/PVC created at the time of preparing environment, Copy the custom_mod_wl_apache.conf file to existing PersistantVolume. +1. Update `persistentVolumeClaimName` in `${WORKDIR}/charts/apache-samples/custom-sample/input.yaml`with Persistence Volume which contains your own custom_mod_wl_apache.conf file. Use the PV/PVC created at the time of preparing environment, Copy the custom_mod_wl_apache.conf file to existing PersistantVolume. #### Prepare the certificate and private key 1. (For the SSL termination configuration only) Run the following commands to generate your own certificate and private key using `openssl`. ```bash - $ cd <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/charts/apache-samples/custom-sample + $ cd ${WORKDIR}/charts/apache-samples/custom-sample $ export VIRTUAL_HOST_NAME=WEBLOGIC_HOST $ export SSL_CERT_FILE=WEBLOGIC_HOST.crt $ export SSL_CERT_KEY_FILE=WEBLOGIC_HOST.key @@ -121,7 +133,7 @@ PathTrim /weblogic1 $ touch input.yaml ``` - Update `virtualHostName` with the value of the `WEBLOGIC_HOST` in file `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/charts/apache-samples/custom-sample/input.yaml` + Update `virtualHostName` with the value of the `WEBLOGIC_HOST` in file `${WORKDIR}/charts/apache-samples/custom-sample/input.yaml` {{%expand "Click here to see the snapshot of the sample input.yaml file " %}} ```bash @@ -139,7 +151,7 @@ PathTrim /weblogic1 1. Install the Apache webtier Helm chart to the domain `wcpns` namespace with the specified input parameters: ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts + $ cd ${WORKDIR}/charts $ kubectl create namespace apache-webtier $ helm install apache-webtier --values apache-samples/custom-sample/input.yaml --namespace wcpns apache-webtier --set image=oracle/apache:12.2.1.3 ``` diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/nginx.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/nginx.md index f1156e310..7a3396c0f 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/nginx.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/nginx.md @@ -105,20 +105,34 @@ Follow these steps to set up NGINX as a load balancer for an Oracle WebCenter Po #### Configure NGINX to manage ingresses -1. Create an ingress for the domain in the domain namespace by using the sample Helm chart. Here path-based routing is used for ingress. Sample values for default configuration are shown in the file `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/values.yaml`. By default, `type` is `TRAEFIK`, `tls` is `Non-SSL`. You can override these values by passing values through the command line or edit them in the sample `values.yaml` file. If needed, you can update the ingress YAML file to define more path rules (in section `spec.rules.host.http.paths`) based on the domain application URLs that need to be accessed. Update the template YAML file for the NGINX load balancer located at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/templates/nginx-ingress.yaml` +1. Create an ingress for the domain in the domain namespace by using the sample Helm chart. Here path-based routing is used for ingress. Sample values for default configuration are shown in the file `${WORKDIR}/charts/ingress-per-domain/values.yaml`. By default, `type` is `TRAEFIK`, `tls` is `Non-SSL`. You can override these values by passing values through the command line or edit them in the sample `values.yaml` file. + +>NOTE: This is not an exhaustive list of rules. You can enhance it based on the application URLs that need to be accessed externally. + +If needed, you can update the ingress YAML file to define more path rules (in section `spec.rules.host.http.paths`) based on the domain application URLs that need to be accessed. Update the template YAML file for the NGINX load balancer located at `${WORKDIR}/charts/ingress-per-domain/templates/nginx-ingress.yaml` +You can add new path rules like shown below . +```yaml + - path: /NewPathRule + backend: + serviceName: 'Backend Service Name' + servicePort: 'Backend Service Port' + +``` + + ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator - $ helm install wcp-nginx-ingress kubernetes/samples/charts/ingress-per-domain \ + $ cd ${WORKDIR} + $ helm install wcp-domain-nginx charts/ingress-per-domain \ --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ + --values charts/ingress-per-domain/values.yaml \ --set "nginx.hostname=$(hostname -f)" \ --set type=NGINX ``` Sample output: ```bash - NAME: wcp-nginx-ingress + NAME: wcp-domain-nginx LAST DEPLOYED: Fri Jul 24 09:34:03 2020 NAMESPACE: wcpns STATUS: deployed @@ -129,24 +143,24 @@ Follow these steps to set up NGINX as a load balancer for an Oracle WebCenter Po ```bash $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=*" - $ kubectl -n wcpns create secret tls domain1-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt + $ kubectl -n wcpns create secret tls wcp-domain-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt ``` 1. Install `ingress-per-domain` using Helm for SSL configuration: ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator - $ helm install wcp-nginx-ingress kubernetes/samples/charts/ingress-per-domain \ + $ cd ${WORKDIR} + $ helm install wcp-domain-nginx charts/ingress-per-domain \ --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ + --values charts/ingress-per-domain/values.yaml \ --set "nginx.hostname=$(hostname -f)" \ - --set type=NGINX --set tls=SSL + --set type=NGINX --set sslType=SSL ``` 1. For non-SSL access to the Oracle WebCenter Portal application, get the details of the services by the ingress: ```bash - $ kubectl describe ingress wcp-domain-ingress -n wcpns + $ kubectl describe ingress wcp-domain-nginx -n wcpns ``` {{%expand "Click here to see the sample output of the services supported by the above deployed ingress." %}} - Name: wcp-domain-ingress + Name: wcp-domain-nginx Namespace: wcpns Address: 10.101.123.106 Default backend: default-http-backend:80 () @@ -159,8 +173,10 @@ Follow these steps to set up NGINX as a load balancer for an Oracle WebCenter Po /rsscrawl wcp-domain-cluster-wcp-cluster:8888 (10.244.0.53:8888) /rest wcp-domain-cluster-wcp-cluster:8888 (10.244.0.53:8888) /webcenterhelp wcp-domain-cluster-wcp-cluster:8888 (10.244.0.53:8888) + /wsrp-tools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.53:8889) + /portalTools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.53:8889) /em wcp-domain-adminserver:7001 (10.244.0.51:7001) - Annotations: meta.helm.sh/release-name: wcp-nginx-ingress + Annotations: meta.helm.sh/release-name: wcp-domain-nginx meta.helm.sh/release-namespace: wcpns nginx.com/sticky-cookie-services: serviceName=wcp-domain-cluster-wcp-cluster srv_id expires=1h path=/; nginx.ingress.kubernetes.io/proxy-connect-timeout: 1800 @@ -175,15 +191,15 @@ Follow these steps to set up NGINX as a load balancer for an Oracle WebCenter Po 1. For SSL access to the Oracle WebCenter Portal application, get the details of the services by the above deployed ingress: ```bash - $ kubectl describe ingress wcp-domain-ingress -n wcpns + $ kubectl describe ingress wcp-domain-nginx -n wcpns ``` {{%expand "Click here to see the sample output of the services supported by the above deployed ingress." %}} - Name: wcp-domain-ingress + Name: wcp-domain-nginx Namespace: wcpns Address: 10.106.220.140 Default backend: default-http-backend:80 () TLS: - domain1-tls-cert terminates mydomain.com + wcp-domain-tls-cert terminates mydomain.com Rules: Host Path Backends ---- ---- -------- @@ -194,8 +210,10 @@ Follow these steps to set up NGINX as a load balancer for an Oracle WebCenter Po /webcenterhelp wcp-domain-cluster-wcp-cluster:8888 (10.244.0.43:8888,10.244.0.44:8888) /rest wcp-domain-cluster-wcp-cluster:8888 (10.244.0.43:8888,10.244.0.44:8888) /em wcp-domain-adminserver:7001 (10.244.0.42:7001) + /wsrp-tools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.43:8889,10.244.0.44:8889) + /portalTools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.43:8889,10.244.0.44:8889) Annotations: kubernetes.io/ingress.class: nginx - meta.helm.sh/release-name: wcp-nginx-ingress + meta.helm.sh/release-name: wcp-domain-nginx meta.helm.sh/release-namespace: wcpns nginx.ingress.kubernetes.io/affinity: cookie nginx.ingress.kubernetes.io/affinity-mode: persistent @@ -213,7 +231,7 @@ Follow these steps to set up NGINX as a load balancer for an Oracle WebCenter Po Events: {{% /expand %}} #### Verify non-SSL and SSL termination access -Verify that the Oracle WebCenter Portal domain application URLs are accessible through the ngnix NodePort `LOADBALANCER-NODEPORT` `30305`: +Verify that the Oracle WebCenter Portal domain application URLs are accessible through the nginx NodePort `LOADBALANCER-NODEPORT` `30305`: ```bash http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-NODEPORT}/console @@ -222,6 +240,8 @@ Verify that the Oracle WebCenter Portal domain application URLs are accessible t http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-NODEPORT}/rsscrawl http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-NODEPORT}/rest http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-NODEPORT}/webcenterhelp + http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-NODEPORT}/wsrp-tools + http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-NODEPORT}/portalTools ``` @@ -232,7 +252,7 @@ Verify that the Oracle WebCenter Portal domain application URLs are accessible t Uninstall and delete the `ingress-nginx` deployment: ```bash - $ helm delete wcp-nginx-ingress -n wcpns + $ helm delete wcp-domain-nginx -n wcpns $ helm delete nginx-ingress -n wcpns ``` @@ -245,14 +265,14 @@ Uninstall and delete the `ingress-nginx` deployment: ```bash $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=domain1.org" - $ kubectl -n wcpns create secret tls domain1-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt + $ kubectl -n wcpns create secret tls wcp-domain-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt ``` > Note: The value of `CN` is the host on which this ingress is to be deployed. 1. Deploy the ingress-nginx controller by using Helm on the domain namespace: ```bash $ helm install nginx-ingress -n wcpns \ - --set controller.extraArgs.default-ssl-certificate=wcpns/domain1-tls-cert \ + --set controller.extraArgs.default-ssl-certificate=wcpns/wcp-domain-tls-cert \ --set controller.service.type=NodePort \ --set controller.admissionWebhooks.enabled=false \ --set controller.extraArgs.enable-ssl-passthrough=true \ @@ -343,7 +363,7 @@ Uninstall and delete the `ingress-nginx` deployment: 1. Deploy the secured ingress: ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/tls + $ cd ${WORKDIR}/charts/ingress-per-domain/tls $ kubectl create -f nginx-tls.yaml ``` > Note: The default `nginx-tls.yaml` contains the backend for WebCenter Portal service with domainUID `wcp-domain`. You need to create similar tls configuration YAML files separately for each backend service. @@ -362,7 +382,7 @@ Uninstall and delete the `ingress-nginx` deployment: tls: - hosts: - domain1.org - secretName: domain1-tls-cert + secretName: wcp-domain-tls-cert rules: - host: domain1.org http: @@ -391,13 +411,15 @@ Verify that the Oracle WebCenter Portal domain application URLs are accessible t https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rsscrawl https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenterhelp https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rest + https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/wsrp-tools + https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/portalTools ``` #### Uninstall ingress-nginx tls ```bash - $ cd weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/tls + $ cd ${WORKDIR}/charts/ingress-per-domain/tls $ kubectl delete -f nginx-tls.yaml $ helm delete nginx-ingress -n wcpns ``` diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/traefik.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/traefik.md index 09158b534..55a514876 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/traefik.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/traefik.md @@ -31,7 +31,7 @@ To load balance Oracle WebCenter Portal domain clusters, you can install the ing You can use the following `values.yaml` sample file and set kubernetes.namespaces as required. ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator + $ cd ${WORKDIR} $ kubectl create namespace traefik $ helm repo add traefik https://containous.github.io/traefik-helm-chart ``` @@ -44,7 +44,7 @@ You can use the following `values.yaml` sample file and set kubernetes.namespac ```bash $ helm install traefik traefik/traefik \ --namespace traefik \ - --values kubernetes/samples/scripts/charts/traefik/values.yaml \ + --values charts/traefik/values.yaml \ --set "kubernetes.namespaces={traefik}" \ --set "service.type=NodePort" --wait ``` @@ -147,18 +147,28 @@ TEST SUITE: None #### Create an ingress for the domain Create an ingress for the domain in the domain namespace by using the sample Helm chart. Here path-based routing is used for ingress. -Sample values for default configuration are shown in the file `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/values.yaml`. +Sample values for default configuration are shown in the file `${WORKDIR}/charts/ingress-per-domain/values.yaml`. By default, `type` is `TRAEFIK` , `tls` is `Non-SSL`. You can override these values by passing values through the command line or edit them in the sample `values.yaml` file based on the type of configuration (non-SSL or SSL). -If needed, you can update the ingress YAML file to define more path rules (in section `spec.rules.host.http.paths`) based on the domain application URLs that need to be accessed. The template YAML file for the Traefik (ingress-based) load balancer is located at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/templates/traefik-ingress.yaml` +>NOTE: This is not an exhaustive list of rules. You can enhance it based on the application URLs that need to be accessed externally. + +If needed, you can update the ingress YAML file to define more path rules (in section `spec.rules.host.http.paths`) based on the domain application URLs that need to be accessed. The template YAML file for the Traefik (ingress-based) load balancer is located at `${WORKDIR}/charts/ingress-per-domain/templates/traefik-ingress.yaml` +You can add new path rules like shown below . +```yaml + - path: /NewPathRule + backend: + serviceName: 'Backend Service Name' + servicePort: 'Backend Service Port' +``` + 1. Install `ingress-per-domain` using Helm for non-SSL configuration: ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator + $ cd ${WORKDIR} $ helm install wcp-traefik-ingress \ - kubernetes/samples/charts/ingress-per-domain \ + charts/ingress-per-domain \ --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ + --values charts/ingress-per-domain/values.yaml \ --set "traefik.hostname=$(hostname -f)" ``` Sample output: @@ -175,27 +185,10 @@ If needed, you can update the ingress YAML file to define more path rules (in se ```bash $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=*" - $ kubectl -n wcpns create secret tls wcpinfra-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt + $ kubectl -n wcpns create secret tls wcp-domain-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt ``` > Note: The value of `CN` is the host on which this ingress is to be deployed. -1. Create a Traefik Middleware custom resource - - In case of SSL termination, Traefik must pass a custom header `WL-Proxy-SSL:true` to the WebLogic Server endpoints. Create the Middleware using the following command: - ```bash - $ cat <-@kubernetescrd`. ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator + $ cd ${WORKDIR} $ helm install wcp-traefik-ingress \ - kubernetes/samples/charts/ingress-per-domain \ + charts/ingress-per-domain \ --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ + --values charts/ingress-per-domain/values.yaml \ --set "traefik.hostname=$(hostname -f)" \ - --set tls=SSL + --set sslType=SSL ``` Sample output: ```bash @@ -267,6 +260,8 @@ If needed, you can update the ingress YAML file to define more path rules (in se /rest wcp-domain-cluster-wcp-cluster:8888 (10.244.0.52:8888,10.244.0.53:8888) /webcenterhelp wcp-domain-cluster-wcp-cluster:8888 (10.244.0.52:8888,10.244.0.53:8888) /em wcp-domain-adminserver:7001 (10.244.0.51:7001) + /wsrp-tools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.52:8889,10.244.0.53:8889) + /portalTools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.52:8889,10.244.0.53:8889) Annotations: kubernetes.io/ingress.class: traefik meta.helm.sh/release-name: wcp-traefik-ingress meta.helm.sh/release-namespace: wcpns @@ -286,7 +281,7 @@ Namespace: wcpns Address: Default backend: default-http-backend:80 () TLS: - wcpinfra-tls-cert terminates www.example.com + wcp-domain-tls-cert terminates www.example.com Rules: Host Path Backends ---- ---- -------- @@ -297,6 +292,8 @@ Rules: /rest wcp-domain-cluster-wcp-cluster:8888 (10.244.0.52:8888,10.244.0.53:8888) /webcenterhelp wcp-domain-cluster-wcp-cluster:8888 (10.244.0.52:8888,10.244.0.53:8888) /em wcp-domain-adminserver:7001 (10.244.0.51:7001) + /wsrp-tools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.52:8889,10.244.0.53:8889) + /portalTools wcp-domain-cluster-wcportlet-cluster:8889 (10.244.0.52:8889,10.244.0.53:8889) Annotations: kubernetes.io/ingress.class: traefik meta.helm.sh/release-name: wcp-traefik-ingress meta.helm.sh/release-namespace: wcpns @@ -338,6 +335,8 @@ After setting up the Traefik (ingress-based) load balancer, verify that the doma http://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/rsscrawl http://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/rest http://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/webcenterhelp + http://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/wsrp-tools + http://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/portalTools ``` @@ -352,6 +351,9 @@ After setting up the Traefik (ingress-based) load balancer, verify that the doma https://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-SSLPORT}/rsscrawl https://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-SSLPORT}/rest https://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenterhelp + https://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-SSLPORT}/wsrp-tools + https://${LOADBALANCER_HOSTNAME}:${LOADBALANCER-SSLPORT}/portalTools + ``` @@ -371,7 +373,7 @@ $ helm delete wcp-traefik-ingress -n wcpns 1. Use Helm to install the Traefik (ingress-based) load balancer. You can use the `values.yaml` sample file and set kubernetes.namespaces as required. ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator + $ cd ${WORKDIR} $ kubectl create namespace traefik $ helm repo add traefik https://containous.github.io/traefik-helm-chart ``` @@ -384,7 +386,7 @@ $ helm delete wcp-traefik-ingress -n wcpns ```bash $ helm install traefik traefik/traefik \ --namespace traefik \ - --values kubernetes/samples/scripts/charts/traefik/values.yaml \ + --values charts/traefik/values.yaml \ --set "kubernetes.namespaces={traefik}" \ --set "service.type=NodePort" --wait ``` @@ -447,7 +449,7 @@ $ helm upgrade traefik traefik/traefik --namespace traefik --reuse-values \ #### Create IngressRouteTCP 1. For each backend service, create different ingresses, as Traefik does not support multiple paths or rules with annotation `ssl-passthrough`. For example, for `wcp-domain-adminserver` and `wcp-domain-cluster-wcp-cluster,` different ingresses must be created. -1. To enable SSL passthrough in Traefik, you can configure a TCP router. A sample YAML for `IngressRouteTCP` is available at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/tls/traefik-tls.yaml`. The following should be updated in `traefik-tls.yaml`: +1. To enable SSL passthrough in Traefik, you can configure a TCP router. A sample YAML for `IngressRouteTCP` is available at `${WORKDIR}/charts/ingress-per-domain/tls/traefik-tls.yaml`. The following should be updated in `traefik-tls.yaml`: * The service name and the SSL port should be updated in the `services`. * The load balancer host name should be updated in the `HostSNI` rule. @@ -491,6 +493,6 @@ Verify the access to application URLs exposed through the configured service. Th ```bash $ helm delete traefik -n traefik - $ cd weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/tls + $ cd ${WORKDIR}/charts/ingress-per-domain/tls $ kubectl delete -f traefik-tls.yaml ``` diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/voyager.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/voyager.md deleted file mode 100644 index 42d33aed0..000000000 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/configure-load-balancer/voyager.md +++ /dev/null @@ -1,526 +0,0 @@ -+++ -title = "Voyager" -date = 2019-02-22T15:44:42-05:00 -draft = false -weight = 3 -pre = "c. " -description = "Configure the ingress-based Voyager load balancer for an Oracle WebCenter Portal domain." -+++ - -*Voyager/HAProxy* is a popular ingress-based load balancer for production environments. -You can install and configure *Voyager/HAProxy* to load balance Oracle WebCenter Portal domain clusters and configure it for non-SSL, SSL termination, and end-to-end SSL access of the application URL. -Follow these steps to set up Voyager as a load balancer for an Oracle WebCenter Portal domain in a Kubernetes cluster: - -* [ Non-SSL and SSL termination](#non-ssl-and-ssl-termination) - - 1. [Install the Voyager load balancer](#install-the-voyager-load-balancer) - 2. [Configure Voyager to manage ingresses](#configure-voyager-to-manage-ingresses) - 3. [Verify non-SSL and SSL access](#verify-non-ssl-and-ssl-access) - -* [ End-to-end SSL configuration](#end-to-end-ssl-configuration) - 1. [Install Voyager load balancer for end-to-end SSL](#install-voyager-load-balancer-for-end-to-end-ssl) - 2. [Deploy tls to access the services](#deploy-tls-to-access-services) - 3. [Verify end-to-end SSL access](#verify-end-to-end-ssl-access) - -#### Non-SSL and SSL termination - -##### Install the Voyager load balancer - -1. Add the AppsCode chart repository: - - ```bash - $ helm repo add appscode https://charts.appscode.com/stable/ - $ helm repo update - ``` -1. Verify that the chart repository has been added: - - ```bash - $ helm search repo appscode/voyager - ``` - > **NOTE**: After updating the Helm repository, the Voyager version listed may be newer that the one shown here. Check with the Voyager site for the latest supported versions. - -1. Install the Voyager operator: - - > **NOTE**: The Voyager version you install must match the version found with the helm search. - - ```bash - $ kubectl create namespace voyager - $ helm install voyager-operator appscode/voyager --version 10.0.0 \ - --namespace voyager \ - --set cloudProvider=baremetal \ - --set apiserver.enableValidatingWebhook=false - ``` - - Wait until the Voyager operator is running. - -1. Check the status of the Voyager operator: - ```bash - $ kubectl get all -n voyager - ``` - {{%expand "Click here to see the sample output." %}} - - NAME READY STATUS RESTARTS AGE - pod/voyager-operator-b84f95f8f-4szhl 1/1 Running 0 43h - - NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE - service/voyager-operator ClusterIP 10.107.201.155 443/TCP,56791/TCP 43h - - NAME READY UP-TO-DATE AVAILABLE AGE - deployment.apps/voyager-operator 1/1 1 1 43h - - NAME DESIRED CURRENT READY AGE - replicaset.apps/voyager-operator-b84f95f8f 1 1 1 43h - - {{% /expand %}} - - See the official [installation document](https://github.com/oracle/weblogic-kubernetes-operator/blob/master/kubernetes/samples/charts/voyager/README.md#a-step-by-step-guide-to-install-the-voyager-operator) for more details. - -1. Update the Voyager operator. - Once the Voyager operator is installed, and it is running, upgrade it using the `helm upgrade` command. In this command, `voyager` is the Voyager namespace and `wcpns` is the namespace of the domain. - - ```bash - $ helm upgrade voyager-operator appscode/voyager --namespace voyager - ``` - {{%expand "Click here to see the sample output." %}} - Release "voyager-operator" has been upgraded. Happy Helming! - NAME: voyager-operator - LAST DEPLOYED: Mon Sep 28 11:53:43 2020 - NAMESPACE: voyager - STATUS: deployed - REVISION: 2 - TEST SUITE: None - NOTES: - Set cloudProvider for installing Voyager - - To verify that Voyager has started, run: - - kubectl get deployment --namespace voyager -l "app.kubernetes.io/name=voyager,app.kubernetes.io/instance=voyager-operator" - - {{% /expand %}} - -##### Configure Voyager to manage ingresses - -1. Create an ingress for the domain in the domain namespace by using the sample Helm chart. Here path-based routing is used for ingress. Sample values for default configuration are shown in the file `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/values.yaml`. By default, `type` is `TRAEFIK` , `tls` is `Non-SSL`. You can override these values by passing your values through the command line or edit the existing values in the sample `values.yaml` file. - - If needed, you can update the ingress yaml file to define more path rules (in the `spec.rules.host.http.paths` section) based on the domain application URLs that need to be accessed. You need to update the template yaml file for the Voyager (ingress-based) load balancer located at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/templates/voyager-ingress.yaml` - - ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator - $ helm install wcp-voyager-ingress kubernetes/samples/charts/ingress-per-domain \ - --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ - --set type=VOYAGER - ``` - {{%expand "Click here to check the output of the ingress per domain " %}} - ```bash - NAME: wcp-voyager-ingress - LAST DEPLOYED: Mon Jul 20 08:20:27 2020 - NAMESPACE: wcpns - STATUS: deployed - REVISION: 1 - TEST SUITE: None - ``` - {{% /expand %}} -1. For secured access (SSL) to the Oracle WebCenter Portal application, create a certificate and generate secrets: - ```bash - $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=*" - $ kubectl -n wcpns create secret tls wcpinfra-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt - ``` - > Note: The value of `CN` is the host on which this ingress is to be deployed. - -1. Deploy `ingress-per-domain` using Helm for SSL configuration. - - If needed, you can update the ingress yaml file to define more path rules (in the `spec.rules.host.http.paths section`) based on the domain application URLs that need to be accessed. You need to update the template yaml file for the Voyager (ingress-based) load balancer located at `${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/templates/voyager-ingress.yaml` - - ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator - $ helm install wcp-voyager-ingress kubernetes/samples/charts/ingress-per-domain \ - --namespace wcpns \ - --values kubernetes/samples/charts/ingress-per-domain/values.yaml \ - --set type=VOYAGER \ - --set tls=SSL - ``` - {{%expand "Click here to see the sample output of the above Commnad." %}} - ```bash - NAME: wcp-voyager-ingress - LAST DEPLOYED: Mon Jul 20 08:20:27 2020 - NAMESPACE: wcpns - STATUS: deployed - REVISION: 1 - TEST SUITE: None - ``` - {{% /expand %}} - -1. For non-SSL access to the Oracle WebCenter Portal application, get the details of the services deployed by the above ingress: - - ```bash - $ kubectl describe ingress.voyager.appscode.com/wcp-domain-voyager -n wcpns - ``` - {{%expand "Click here to see the sample output of the services supported by the above deployed ingress." %}} - Sample output: - ```bash - Name: wcp-domain-voyager - Namespace: wcpns - Labels: app.kubernetes.io/managed-by=Helm - Annotations: ingress.appscode.com/affinity: cookie - ingress.appscode.com/stats: true - ingress.appscode.com/type: NodePort - meta.helm.sh/release-name: wcp-voyager-ingress - meta.helm.sh/release-namespace: wcpns - API Version: voyager.appscode.com/v1beta1 - Kind: Ingress - Metadata: - Creation Timestamp: 2021-01-13T08:19:16Z - Generation: 1 - Managed Fields: - API Version: voyager.appscode.com/v1beta1 - Fields Type: FieldsV1 - fieldsV1: - f:metadata: - f:annotations: - .: - f:ingress.appscode.com/affinity: - f:ingress.appscode.com/stats: - f:ingress.appscode.com/type: - f:meta.helm.sh/release-name: - f:meta.helm.sh/release-namespace: - f:labels: - .: - f:app.kubernetes.io/managed-by: - f:spec: - .: - f:rules: - Manager: Go-http-client - Operation: Update - Time: 2021-01-13T08:19:16Z - Resource Version: 340890 - Self Link: /apis/voyager.appscode.com/v1beta1/namespaces/wcpns/ingresses/wcp-domain-voyager - UID: a06315c2-23ad-4916-a972-cd3555494eb8 - Spec: - Rules: - Host: * - Http: - Node Port: 30305 - Paths: - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8888 - Path: /webcenter - Backend: - Service Name: wcp-domain-adminserver - Service Port: 7001 - Path: /console - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8888 - Path: /rsscrawl - Backend: - Service Name: wcp-domain-adminserver - Service Port: 7001 - Path: /em - Events: - Type Reason Age From Message - ---- ------ ---- ---- ------- - Normal ServiceReconcileSuccessful 62s voyager-operator Successfully created NodePort Service voyager-wcp-domain-voyager - Normal ConfigMapReconcileSuccessful 62s voyager-operator Successfully created ConfigMap voyager-wcp-domain-voyager - Normal RBACSuccessful 62s voyager-operator Successfully created ServiceAccount voyager-wcp-domain-voyager - Normal RBACSuccessful 62s voyager-operator Successfully created Role voyager-wcp-domain-voyager - Normal RBACSuccessful 62s voyager-operator Successfully created RoleBinding voyager-wcp-domain-voyager - Normal DeploymentReconcileSuccessful 62s voyager-operator Successfully created HAProxy Deployment voyager-wcp-domain-voyager - Normal StatsServiceReconcileSuccessful 62s voyager-operator Successfully created stats Service voyager-wcp-domain-voyager-stats - - ``` - {{% /expand %}} - -1. For SSL access to the Oracle WebCenter Portal application, get the details of the services by the above deployed ingress: - - ```bash - $ kubectl describe ingress.voyager.appscode.com/wcp-domain-voyager -n wcpns - ``` - {{%expand "Click here to see all the services configured by the above deployed ingress." %}} - - ```bash - Name: wcp-domain-voyager - Namespace: wcpns - Labels: app.kubernetes.io/managed-by=Helm - Annotations: ingress.appscode.com/affinity: cookie - ingress.appscode.com/stats: true - ingress.appscode.com/type: NodePort - meta.helm.sh/release-name: wcp-domain-ingress - meta.helm.sh/release-namespace: wcpns - API Version: voyager.appscode.com/v1beta1 - Kind: Ingress - Metadata: - Creation Timestamp: 2021-01-15T05:40:20Z - Generation: 1 - Managed Fields: - API Version: voyager.appscode.com/v1beta1 - Fields Type: FieldsV1 - fieldsV1: - f:metadata: - f:annotations: - .: - f:ingress.appscode.com/affinity: - f:ingress.appscode.com/stats: - f:ingress.appscode.com/type: - f:meta.helm.sh/release-name: - f:meta.helm.sh/release-namespace: - f:labels: - .: - f:app.kubernetes.io/managed-by: - f:spec: - .: - f:frontendRules: - f:rules: - f:tls: - Manager: Go-http-client - Operation: Update - Time: 2021-01-15T05:40:20Z - Resource Version: 704682 - Self Link: /apis/voyager.appscode.com/v1beta1/namespaces/wcpns/ingresses/wcp-domain-voyager - UID: 1e83c6a6-336f-4e29-b38a-023e00ca5cd5 - Spec: - Frontend Rules: - Port: 443 - Rules: - http-request set-header WL-Proxy-SSL true - Rules: - Host: * - Http: - Node Port: 30305 - Paths: - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8888 - Path: /webcenter - Backend: - Service Name: wcp-domain-adminserver - Service Port: 7001 - Path: /console - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8888 - Path: /rsscrawl - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8888 - Path: /rest - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8888 - Path: /webcenterhelp - Backend: - Service Name: wcp-domain-adminserver - Service Port: 7001 - Path: /em - Tls: - Hosts: - * - Secret Name: domain1-tls-cert - Events: - Type Reason Age From Message - ---- ------ ---- ---- ------- - Normal ServiceReconcileSuccessful 54s voyager-operator Successfully created NodePort Service voyager-wcp-domain-voyager - Normal ConfigMapReconcileSuccessful 54s voyager-operator Successfully created ConfigMap voyager-wcp-domain-voyager - Normal RBACSuccessful 54s voyager-operator Successfully created ServiceAccount voyager-wcp-domain-voyager - Normal RBACSuccessful 54s voyager-operator Successfully created Role voyager-wcp-domain-voyager - Normal RBACSuccessful 54s voyager-operator Successfully created RoleBinding voyager-wcp-domain-voyager - Normal DeploymentReconcileSuccessful 54s voyager-operator Successfully created HAProxy Deployment voyager-wcp-domain-voyager - Normal StatsServiceReconcileSuccessful 54s voyager-operator Successfully created stats Service voyager-wcp-domain-voyager-stats - - ``` - {{% /expand %}} - - - -##### Verify Non-SSL and SSL access - -After setting up the Voyager (ingress-based) load balancer, verify that the Oracle WebCenter Portal domain applications are accessible through the load balancer port 30305 (both SSL and non-SSL). The application URLs for Oracle WebCenter Portal domain are: - -> Note: Port 30305 is the LOADBALANCER-Non-SSLPORT and LOADBALANCER-SSLPORT. - -##### Non-SSL configuration - - ```bash - http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/webcenter - http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/console - http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/em - http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/rsscrawl - http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/rest - http://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-Non-SSLPORT}/webcenterhelp - - ``` -##### SSL configuration - - ```bash - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenter - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/console - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/em - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rsscrawl - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rest - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenterhelp - - ``` - -##### Uninstall the chart - - To uninstall and delete the my-ingress deployment, enter the following command: - - ```bash - $ helm delete wcp-voyager-ingress -n wcpns - $ helm delete voyager-operator -n voyager - - ``` - -#### End-to-end SSL configuration - -##### Install Voyager load balancer for end-to-end SSL - -Install the Voyager load balancer as described [here](#install-the-voyager-load-balancer). - -1. Check the status of the Voyager operator. - - ```bash - $ kubectl get all -n voyager - ``` - Sample output: - - ```bash - NAME READY STATUS RESTARTS AGE - pod/voyager-operator-b84f95f8f-4szhl 1/1 Running 0 43h - - NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE - service/voyager-operator ClusterIP 10.107.201.155 443/TCP,56791/TCP 43h - - NAME READY UP-TO-DATE AVAILABLE AGE - deployment.apps/voyager-operator 1/1 1 1 43h - - NAME DESIRED CURRENT READY AGE - replicaset.apps/voyager-operator-b84f95f8f 1 1 1 43h - ``` -1. For secured access (SSL) to the Oracle WebCenter Portal application, create a certificate and generate Kuberentes secrets: - ```bash - $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls1.key -out /tmp/tls1.crt -subj "/CN=*" - $ kubectl -n wcpns create secret tls domain1-tls-cert --key /tmp/tls1.key --cert /tmp/tls1.crt - ``` -##### Deploy tls to access services - -1. Deploy tls to securely access the services. Only one application can be configured with ssl-passthrough. A sample tls file for Voyager is shown below for the service `wcp-domain-cluster-wcp-cluster` and port `8889`. All the applications running on port `8889` can be securely accessed through this ingress. For each backend service, create different ingresses as Voyager does not support multiple path/rules with annotation `ssl-passthrough`. - - ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/tls - ``` - {{%expand "Click here to see the content of the file voyager-tls.yaml" %}} - ```bash - apiVersion: voyager.appscode.com/v1beta1 - kind: Ingress - metadata: - name: voyager-ssl - namespace: wcpns - annotations: - ingress.appscode.com/type: 'NodePort' - ingress.appscode.com/stats: 'true' - ingress.appscode.com/affinity: 'cookie' - ingress.appscode.com/ssl-passthrough: "true" - spec: - tls: - - secretName: domain1-tls-cert - hosts: - - '*' - rules: - - host: '*' - http: - nodePort: '31443' - paths: - - path: / - backend: - serviceName: wcp-domain-cluster-wcp-cluster - servicePort: '8889' - - ``` - {{% /expand %}} - ```bash - $ kubectl create -f voyager-tls.yaml - ``` - {{%expand "Click here to see the services supported by the ingress" %}} - ```bash - kubectl describe ingress.voyager.appscode.com/voyager-ssl -n wcpns - Name: voyager-ssl - Namespace: wcpns - Labels: - Annotations: ingress.appscode.com/affinity: cookie - ingress.appscode.com/ssl-passthrough: true - ingress.appscode.com/stats: true - ingress.appscode.com/type: NodePort - API Version: voyager.appscode.com/v1beta1 - Kind: Ingress - Metadata: - Creation Timestamp: 2020-07-20T04:34:05Z - Generation: 1 - Managed Fields: - API Version: voyager.appscode.com/v1beta1 - Fields Type: FieldsV1 - fieldsV1: - f:metadata: - f:annotations: - .: - f:ingress.appscode.com/affinity: - f:ingress.appscode.com/ssl-passthrough: - f:ingress.appscode.com/stats: - f:ingress.appscode.com/type: - f:spec: - .: - f:rules: - f:tls: - Manager: kubectl - Operation: Update - Time: 2020-07-20T04:34:05Z - Resource Version: 340071 - Self Link: /apis/voyager.appscode.com/v1beta1/namespaces/wcpns/ingresses/voyager-ssl - UID: 4a9b2e02-1593-45b3-8ac4-ae1ac0f2832c - Spec: - Rules: - Host: * - Http: - Node Port: 31443 - Paths: - Backend: - Service Name: wcp-domain-cluster-wcp-cluster - Service Port: 8889 - Path: / - Tls: - Hosts: - * - Secret Name: domain1-tls-cert - Events: - Type Reason Age From Message - ---- ------ ---- ---- ------- - Normal ServiceReconcileSuccessful 7m37s voyager-operator Successfully created NodePort Service voyager-voyager-ssl - N ormal ConfigMapReconcileSuccessful 7m37s voyager-operator Successfully created ConfigMap voyager-voyager-ssl - Normal RBACSuccessful 7m37s voyager-operator Successfully created ServiceAccount voyager-voyager-ssl - Normal RBACSuccessful 7m37s voyager-operator Successfully created Role voyager-voyager-ssl - Normal RBACSuccessful 7m37s voyager-operator Successfully created RoleBinding voyager-voyager-ssl - Normal DeploymentReconcileSuccessful 7m37s voyager-operator Successfully created HAProxy Deployment voyager-voyager-ssl - Normal StatsServiceReconcileSuccessful 7m37s voyager-operator Successfully created stats Service voyager-voyager-ssl-stats - Normal DeploymentReconcileSuccessful 3m5s voyager-operator Successfully patched HAProxy Deployment voyager-voyager-ssl - ``` - {{% /expand %}} - -##### Verify end-to-end SSL access - -Verify that the Oracle WebCenter Portal domain application URLs are accessible through the SSLPORT `31443`: - ```bash - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenter - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rsscrawl - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/webcenterhelp - https://${LOADBALANCER-HOSTNAME}:${LOADBALANCER-SSLPORT}/rest - - ``` - -##### Uninstall the Voyager tls - - ```bash - $ cd ${WORKDIR}/weblogic-kubernetes-operator/kubernetes/samples/charts/ingress-per-domain/tls - $ kubectl delete -f voyager-tls.yaml - $ helm delete voyager-operator -n voyager - ``` diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/monitoring-domain/_index.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/monitoring-domain/_index.md index 356bb1382..abd6ac875 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/monitoring-domain/_index.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/monitoring-domain/_index.md @@ -9,278 +9,112 @@ You can monitor a WebCenter Portal domain using Prometheus and Grafana by export ### Prerequisites This document assumes that the Prometheus Operator is deployed on the Kubernetes cluster. If it is not already deployed, follow the steps below for deploying the Prometheus Operator. +### Prepare to use the setup monitoring script -#### Clone the kube-prometheus project -Refer to the compatibility matrix of [Kube Prometheus](https://github.com/coreos/kube-prometheus#kubernetes-compatibility-matrix) and clone the [release](https://github.com/coreos/kube-prometheus/releases) version of the `kube-prometheus` repository according to the Kubernetes version of your cluster. -$ git clone https://github.com/coreos/kube-prometheus.git -``` - -#### Label the nodes -Kube-Prometheus requires all the exporter nodes to be labelled with `kubernetes.io/os=linux`. If a node is not labelled, then you must label it using the following command: +The sample scripts for setup monitoring for OracleWebCenterPortal domain are available at `${WORKDIR}/monitoring-service`. -``` -$ kubectl label nodes --all kubernetes.io/os=linux -``` +You must edit `monitoring-inputs.yaml`(or a copy of it) to provide the details of your domain. Refer to the configuration parameters below to understand the information that you must provide in this file. -#### Create Prometheus and Grafana resources +#### Configuration parameters -Change to the `kube-prometheus` directory and execute the following commands to create the namespace and CRDs: +The following parameters can be provided in the inputs file. -**NOTE**: Wait for a minute for each command to process. +| Parameter | Description | Default | +| --- | --- | --- | +| `domainUID` | domainUID of the OracleWebCenterPortal domain. | `wcp-domain` | +| `domainNamespace` | Kubernetes namespace of the OracleWebCenterPortal domain. | `wcpns` | +| `setupKubePrometheusStack` | Boolean value indicating whether kube-prometheus-stack (Prometheus, Grafana and Alertmanager) to be installed | `true` | +| `additionalParamForKubePrometheusStack` | The script install's kube-prometheus-stack with `service.type` as NodePort and values for `service.nodePort` as per the parameters defined in `monitoring-inputs.yaml`. Use `additionalParamForKubePrometheusStack` parameter to further configure with additional parameters as per [values.yaml](https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/values.yaml). Sample value to disable NodeExporter, Prometheus-Operator TLS support and Admission webhook support for PrometheusRules resources is `--set nodeExporter.enabled=false --set prometheusOperator.tls.enabled=false --set prometheusOperator.admissionWebhooks.enabled=false`| | +| `monitoringNamespace` | Kubernetes namespace for monitoring setup. | `monitoring` | +| `adminServerName` | Name of the Administration Server. | `AdminServer` | +| `adminServerPort` | Port number for the Administration Server inside the Kubernetes cluster. | `7001` | +| `wcpClusterName` | Name of the wcpCluster. | `wcp_cluster` | +| `wcpManagedServerPort` | Port number of the managed servers in the wcpCluster. | `8888` | +| `wlsMonitoringExporterTowcpCluster` | Boolean value indicating whether to deploy WebLogic Monitoring Exporter to wcpCluster. | `false` | +| `wcpPortletClusterName` | Name of the wcpPortletCluster. | `wcportlet-cluster` | +| `wcpManagedServerPort` | Port number of the Portlet managed servers in the wcpPortletCluster. | `8889` | +| `wlsMonitoringExporterTowcpPortletCluster` | Boolean value indicating whether to deploy WebLogic Monitoring Exporter to wcpPortletCluster. | `false` | +| `exposeMonitoringNodePort` | Boolean value indicating if the Monitoring Services (Prometheus, Grafana and Alertmanager) is exposed outside of the Kubernetes cluster. | `false` | +| `prometheusNodePort` | Port number of the Prometheus outside the Kubernetes cluster. | `32101` | +| `grafanaNodePort` | Port number of the Grafana outside the Kubernetes cluster. | `32100` | +| `alertmanagerNodePort` | Port number of the Alertmanager outside the Kubernetes cluster. | `32102` | +| `weblogicCredentialsSecretName` | Name of the Kubernetes secret which has Administration Server’s user name and password. | `wcp-domain-domain-credentials` | -```bash -$ cd kube-prometheus +Note that the values specified in the `monitoring-inputs.yaml` file will be used to install kube-prometheus-stack (Prometheus, Grafana and Alertmanager) and deploying WebLogic Monitoring Exporter into the OracleWebCenterPortal domain. Hence make the domain specific values to be same as that used during domain creation. -$ kubectl create -f manifests/setup -$ until kubectl get servicemonitors --all-namespaces ; do date; sleep 1; echo ""; done -$ kubectl create -f manifests/ -``` +### Run the setup monitoring script -#### Provide external access -To provide external access for Grafana, Prometheus, and Alertmanager, execute the commands below: +Update the values in `monitoring-inputs.yaml` as per your requirement and run the `setup-monitoring.sh` script, specifying your inputs file: ```bash -$ kubectl patch svc grafana -n monitoring --type=json -p '[{"op": "replace", "path": "/spec/type", "value": "NodePort" },{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 32100 }]' -$ kubectl patch svc prometheus-k8s -n monitoring --type=json -p '[{"op": "replace", "path": "/spec/type", "value": "NodePort" },{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 32101 }]' -$ kubectl patch svc alertmanager-main -n monitoring --type=json -p '[{"op": "replace", "path": "/spec/type", "value": "NodePort" },{"op": "replace", "path": "/spec/ports/0/nodePort", "value": 32102 }]' +$ cd ${WORKDIR}/monitoring-service +$ ./setup-monitoring.sh \ + -i monitoring-inputs.yaml ``` +The script will perform the following steps: -**NOTE**: - -* `32100` is the external port for Grafana -* `32101` is the external port for Prometheus -* `32102` is the external port for Alertmanager - --------------- +- Helm install `prometheus-community/kube-prometheus-stack` of version "16.5.0" if `setupKubePrometheusStack` is set to `true`. +- Deploys WebLogic Monitoring Exporter to Administration Server. +- Deploys WebLogic Monitoring Exporter to `wcpCluster` if `wlsMonitoringExporterTowcpCluster` is set to `true`. +- Deploys WebLogic Monitoring Exporter to `wcpPortletCluster` if `wlsMonitoringExporterTowcpPortletCluster` is set to `true`. +- Exposes the Monitoring Services (Prometheus at `32101`, Grafana at `32100` and Alertmanager at `32102`) outside of the Kubernetes cluster if `exposeMonitoringNodePort` is set to `true`. +- Imports the WebLogic Server Grafana Dashboard if `setupKubePrometheusStack` is set to `true`. -## Set Up the WebLogic Monitoring Exporter +### Verify the results +The setup monitoring script will report failure if there was any error. However, verify that required resources were created by the script. -Set up the WebLogic Monitoring Exporter to collect WebLogic Server metrics and monitor your WebCenter Portal domain. +#### Verify the kube-prometheus-stack -#### Generate the WebLogic Monitoring Exporter Deployment Package - -Two packages are required as the listening ports are different for the Administration Server and Managed Servers. -One binary required for the Admin Server (`wls-exporter-as.war`) and one for Managed Cluster (`wls-exporter-ms.war`). -Set the required proxies and then run the script `getX.X.X.sh` to generate two binaries: +To confirm that `prometheus-community/kube-prometheus-stack` was installed when `setupKubePrometheusStack` is set to `true`, run the following command: ```bash -$ cd <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-monitoring-exporter - -$ sh get1.1.0.sh -``` - -Output: +$ helm ls -n monitoring ``` - % Total % Received % Xferd Average Speed Time Time Time Current - Dload Upload Total Spent Left Speed -100 607 0 607 0 0 357 0 --:--:-- 0:00:01 --:--:-- 357 -100 2016k 100 2016k 0 0 398k 0 0:00:05 0:00:05 --:--:-- 797k --------------------wls-exporter-ms start------------------- -created /tmp/ci-GNysQzP1kv -Copying completed -/tmp/ci-GNysQzP1kv <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-monitoring-exporter -in temp dir - adding: WEB-INF/weblogic.xml (deflated 66%) - adding: config.yml (deflated 63%) -wls-exporter-ms.war is ready --------------------wls-exporter-ms end------------------- --------------------wls-exporter-as start------------------- -Copying completed -in temp dir - adding: WEB-INF/weblogic.xml (deflated 66%) - adding: config.yml (deflated 52%) -wls-exporter-as.war is ready --------------------wls-exporter-as end------------------- -zip completed -<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-monitoring-exporter -``` - -#### Copy the WAR Files to the WebLogic Domain Home - -Copy the `wls-exporter-as.war` and `wls-exporter-ms.war` files to the domain home directory in the Administration Server pod. +Sample output: +```bash +$ helm ls -n monitoring +NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION +monitoring monitoring 1 2021-06-18 12:58:35.177221969 +0000 UTC deployed kube-prometheus-stack-16.5.0 0.48.0 +$ ``` -$ kubectl cp wls-exporter-as.war wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/ - -$ kubectl cp wls-exporter-ms.war wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/ -``` - -#### Deploy the WebLogic Monitoring Exporter - -Follow these steps to deploy the package in the WebLogic Server instances: - -1. On the Administration Server and Managed Servers, deploy the WebLogic Monitoring Exporter (`wls-exporter-ms.war`) separately using the Oracle Enterprise Manager. - - ![Wme-Deploy](images/wme-deploy.png) - -1. Select the servers to which the Exporter WAR should be deployed: - - ![Wme-Deploy-Target-Server](images/wme-deploy-target-server.png) - -1. Set the application name. The application name must be different if it is deployed separately in the Administration Server and Managed Servers. Make sure the context-root for both the deployments is `wls-exporter`: - - ![Wme-Deploy-Contextroot](images/wme-deploy-contextroot.png) - -1. Click **Install and start application**. - -1. Then deploy the WebLogic Monitoring Exporter application (`wls-exporter-ms.war`). - -1. Activate the changes to start the application. If the application is started and the port is exposed, -then you can access the WebLogic Monitoring Exporter console using this URL: `http:///wls-exporter`. - ![Wme-Test-Url](images/wme-test-url.png) +#### Verify the Prometheus, Grafana and Alertmanager setup -1. Repeat same steps for `wls-exporter-as.war`. +When `exposeMonitoringNodePort` was set to `true`, verify that monitoring services are accessible outside of the Kubernetes cluster: + +- `32100` is the external port for Grafana and with credentials `admin:admin` +- `32101` is the external port for Prometheus +- `32102` is the external port for Alertmanager -#### Configure Prometheus Operator -Prometheus enables you to collect metrics from the WebLogic Monitoring Exporter. The Prometheus Operator identifies the targets using service discovery. In order to Prometheus be able to discovery and scrape services inside the additional namespaces like `wcpns`, you must create a service monitor resource pointing to the services in `wcpns` namespace. +#### Verify the service discovery of WebLogic Monitoring Exporter -See the following sample service monitor deployment YAML configuration file located at +Verify whether prometheus is able to discover wls-exporter and collect the metrics: -`<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-monitoring-exporter/wls-exporter.yaml`. +1. Access the Prometheus dashboard at http://mycompany.com:32101/ -`ServiceMonitor` for wls-exporter: -``` -apiVersion: v1 -kind: Secret -metadata: - name: basic-auth - namespace: monitoring -data: - password: d2VsY29tZTEK # welcome1 i.e.'WebLogic password' - user: d2VibG9naWM= # weblogic i.e. 'WebLogic username' -type: Opaque ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - name: wls-exporter-wcp-domain - namespace: monitoring - labels: - k8s-app: wls-exporter -spec: - namespaceSelector: - matchNames: - - wcpns - selector: - matchLabels: - weblogic.domainName: wcp-domain - endpoints: - - basicAuth: - password: - name: basic-auth - key: password - username: - name: basic-auth - key: user - port: default - relabelings: - - action: labelmap - regex: __meta_kubernetes_service_label_(.+) - interval: 10s - honorLabels: true - path: /wls-exporter/metrics -``` +1. Navigate to Status to see the Service Discovery details. -To export metrics using `wls-exporter,` you need to set basicAuth in Prometheus. So create a Kubernetes `Secret` with the user name and password that are `base64` encoded. This Secret will be used in the ServiceMonitor deployment. +1. Verify that wls-exporter is listed in the discovered services. -When generating the base64 encoded strings for the user name and password, observe if a new line character is appended in the encoded string. This line character causes an authentication failure. To avoid a new line string, use the following example: +#### Verify the WebLogic Server dashoard -``` -$ echo -n "Welcome1" | base64 -V2VsY29tZTE= -``` +You can access the Grafana dashboard at http://mycompany.com:32100/. -In the deployment YAML configuration for `wls-exporter` shown above, `weblogic.domainName: wcp-domain` is used as a label under `spec.selector.matchLabels`, so all the services are selected for the service monitor. If you don't use this label, you should create separate service monitors for each server--if the server name is used as matching labels in `spec.selector.matchLabels`. Doing so will require you to relabel the configuration because Prometheus, by default, ignores the labels provided in the *wls-exporter*. +1. Log in to Grafana dashboard with username: `admin` and password: `admin`. -By default, Prometheus does not store all the labels provided by the target. In the service monitor deployment YAML configuration, you must mention the relabeling configuration (`spec.endpoints.relabelings`) so that certain labels provided by `weblogic-monitoring-exporter` (required for the Grafana dashboard) are stored in Prometheus. Do not delete the following section from the configuration YAML file: -``` -relabelings: - - action: labelmap - regex: __meta_kubernetes_service_label_(.+) -``` +1. Navigate to "WebLogic Server Dashboard" under General and verify. -#### Add `RoleBinding` and `Role` for the WebLogic Domain Namespace + This displays the WebLogic Server Dashboard. -The RoleBinding is required for Prometheus to access the endpoints provided by the WebLogic Monitoring Exporter. You need to add RoleBinding for the namespace under which the WebLogic Servers pods are running in the Kubernetes cluster. Edit the `kube-prometheus/manifests/prometheus-roleBindingSpecificNamespaces.yaml` file in the Prometheus Operator deployment manifests and add the `RoleBinding` for the namespace (`wcpns`) similar to the following example: + ![Wme-GP-WLS-Dashboard](images/wcp-graphana-dashboard.png) -``` -- apiVersion: rbac.authorization.k8s.io/v1 - kind: RoleBinding - metadata: - name: prometheus-k8s - namespace: wcpns - roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: prometheus-k8s - subjects: - - kind: ServiceAccount - name: prometheus-k8s - namespace: monitoring -``` -In the Prometheus Operator deployment manifests located at `kube-prometheus/manifests/prometheus-roleSpecificNamespaces.yaml,` add the `Role` for the namespace `wcpns` under which the WebLogic Servers pods are running in the Kubernetes cluster. See the following example: -``` -- apiVersion: rbac.authorization.k8s.io/v1 - kind: Role - metadata: - name: prometheus-k8s - namespace: wcpns - rules: - - apiGroups: - - "" - resources: - - services - - endpoints - - pods - verbs: - - get - - list - - watch -``` -Then apply `prometheus-roleBindingSpecificNamespaces.yaml` and `prometheus-roleSpecificNamespaces.yaml` for the `RoleBinding` and `Role` to take effect in the cluster. -``` -$ kubectl apply -f kube-prometheus/manifests/prometheus-roleBindingSpecificNamespaces.yaml +### Delete the monitoring setup -$ kubectl apply -f kube-prometheus/manifests/prometheus-roleSpecificNamespaces.yaml -``` -#### Deploy the Service Monitor +To delete the monitoring setup created by [Run the setup monitoring script](#run-the-setup-monitoring-script), run the below command: -To deploy the service monitor, use the above `wls-exporter.yaml` deployment YAML and run the following command: -``` -$ kubectl create -f <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-monitoring-exporter/wls-exporter.yaml +```bash +$ cd ${WORKDIR}/monitoring-service +$ ./delete-monitoring.sh \ + -i monitoring-inputs.yaml ``` -#### Enable Prometheus to Discover the Service - -After deploying the service monitor, Prometheus should be able to discover *wls-exporter* and export metrics. - -You can access the Prometheus dashboard at `http://mycompany.com:32101/`. - -![Wme-Service-Discovery](images/wme-service-discovery.png) - - -#### Deploy Grafana Dashboard - -To view the domain metrics, deploy the Grafana dashboard provided in the [WebLogic Monitoring Exporter](https://github.com/oracle/weblogic-monitoring-exporter/tree/master/samples/kubernetes/end2end#monitoring-weblogic-server-with-the-grafana-dashboard). - -You can access the Grafana dashboard at `http://mycompany.com:32100/`. - -1. Log in to Grafana dashboard with `admin/admin`. -1. Go to **Settings**, then select **DataSources**, and then **Add Data Source**. - - HTTP URL: Prometheus URL `http://mycompany.com:32101/` - - Auth: Enable Basic Auth - - Basic Auth Details: Weblogic credentials provided in the step [Configure Prometheus Operator](#configure-prometheus-operator) - - ![Wme-GP-Add-Datasource](images/wme-gp-add-datasource.png) - -1. Download the `weblogic_dashboard.json` file from [here](weblogic_dashboard.json). -1. Click **Add** and then **Import**. Paste the modified JSON in the **Paste JSON** block, and then load it. - - ![Wme-GP-Import-Json](images/wme-gp-import-json.png) - - This displays the WebLogic Server Dashboard. - - ![Wme-GP-WLS-Dashboard](images/wcp-graphana-dashboard.png) \ No newline at end of file diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/_index.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/_index.md index 297d4d4ac..e57909b7d 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/_index.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/_index.md @@ -7,5 +7,5 @@ pre = " " description = "Publish WebLogic Server logs into Elasticsearch." +++ -To publish WebLogic Server logs into Elasticsearch, you can configure your WebCenter Portal domain to use Fluentd or WebLogic Logging Exporter. +To publish WebLogic Server logs into Elasticsearch, you can configure your WebCenter Portal domain to use Fluentd, WebLogic Logging Exporter or Logstash. {{% children style="h4" description="true" %}} diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/fluentd/_index.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/fluentd/_index.md index bbb1c6213..e9baec49e 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/fluentd/_index.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/fluentd/_index.md @@ -24,7 +24,7 @@ A complete example of a domain definition with fluentd configuration is at the [ {{% notice note %}} These identifiers are used in the sample commands. * `wcpns`: WebCenter Portal domain namespace * `wcp-domain`: `domainUID` -* `wcpinfra-domain-credentials`: Kubernetes secret +* `wcp-domain-domain-credentials`: Kubernetes secret {{%/notice %}} The sample Elasticsearch configuration is: @@ -70,7 +70,7 @@ spec: #### Add Elasticsearch secrets to WebLogic domain credentials Configure the `fluentd` container to look for Elasticsearch parameters in the domain credentials. Edit the domain credentials and add the parameters shown in the example below. -For example, run: `kubectl edit secret wcpinfra-domain-credentials -n wcpns` and add the base64 encoded values of each Elasticsearch parameter: +For example, run: `kubectl edit secret wcp-domain-domain-credentials -n wcpns` and add the base64 encoded values of each Elasticsearch parameter: ```text elasticsearchhost: ZWxhc3RpY3NlYXJjaC5ib2JzLWJvb2tzLnNhbXBsZS5jb20= elasticsearchport: NDQz @@ -165,7 +165,7 @@ Add a container to the domain to run `fluentd` in the Administration Server and The container definition: * Defines a `LOG_PATH` environment variable that points to the log location of `bobbys-front-end`. -* Defines `ELASTICSEARCH_HOST`, `ELASTICSEARCH_PORT`, `ELASTICSEARCH_USER`, and `ELASTICSEARCH_PASSWORD` environment variables that are all retrieving their values from the secret `wcpinfra-domain-credentials`. +* Defines `ELASTICSEARCH_HOST`, `ELASTICSEARCH_PORT`, `ELASTICSEARCH_USER`, and `ELASTICSEARCH_PASSWORD` environment variables that are all retrieving their values from the secret `wcp-domain-domain-credentials`. * Includes volume mounts for the `fluentd-config` `ConfigMap` and the volume containing the domain logs. **NOTE**: For brevity, only the paths to the relevant configuration are shown. @@ -197,23 +197,23 @@ spec: valueFrom: secretKeyRef: key: elasticsearchhost - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials - name: ELASTICSEARCH_PORT valueFrom: secretKeyRef: key: elasticsearchport - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials - name: ELASTICSEARCH_USER valueFrom: secretKeyRef: key: elasticsearchuser - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials optional: true - name: ELASTICSEARCH_PASSWORD valueFrom: secretKeyRef: key: elasticsearchpassword - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials optional: true image: fluent/fluentd-kubernetes-daemonset:v1.3.3-debian-elasticsearch-1.3 imagePullPolicy: IfNotPresent @@ -259,7 +259,7 @@ spec: image: "oracle/wcportal:12.2.1.4" imagePullPolicy: "IfNotPresent" webLogicCredentialsSecret: - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials includeServerOutInPodLog: true logHomeEnabled: true httpAccessLogInLogHome: true @@ -309,22 +309,22 @@ spec: valueFrom: secretKeyRef: key: elasticsearchport - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials - name: ELASTICSEARCH_PORT valueFrom: secretKeyRef: key: elasticsearchhost - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials - name: ELASTICSEARCH_USER valueFrom: secretKeyRef: key: elasticsearchuser - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials - name: ELASTICSEARCH_PASSWORD valueFrom: secretKeyRef: key: elasticsearchpassword - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials image: fluent/fluentd-kubernetes-daemonset:v1.11.5-debian-elasticsearch6-1.0 imagePullPolicy: IfNotPresent name: fluentd @@ -355,7 +355,7 @@ spec: name: fluentd-config-volume serverStartPolicy: IF_NEEDED webLogicCredentialsSecret: - name: wcpinfra-domain-credentials + name: wcp-domain-domain-credentials ``` ##### Get the Kibana dashboard port information as shown below: diff --git a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/weblogiclogging/_index.md b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/weblogiclogging/_index.md index dcf52cb72..2c2a084a7 100644 --- a/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/weblogiclogging/_index.md +++ b/docs-source/content/wcportal-domains/manage-wcportal-domains/monitoring-and-publishing-logs/publishing-logs/weblogiclogging/_index.md @@ -92,7 +92,7 @@ $ kubectl cp setDomainEnv.sh wcpns/wcp-domain-adminserver:/u01/oracle/user_proje #### Create a Configuration File for the WebLogic Logging Exporter -1. Specify the Elasticsearch server host and port number in the file: `<$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-logging-exporter/WebLogicLoggingExporter.yaml` +1. Specify the Elasticsearch server host and port number in the file: `<$WORKDIR>/logging-services/weblogic-logging-exporter/WebLogicLoggingExporter.yaml` Example: ``` @@ -107,14 +107,9 @@ $ kubectl cp setDomainEnv.sh wcpns/wcp-domain-adminserver:/u01/oracle/user_proje 2. Copy the `WebLogicLoggingExporter.yaml` file to the domain home directory in the WebLogic Administration Server pod: ```bash -$ kubectl cp <$WORKDIR>/weblogic-kubernetes-operator/kubernetes/samples/scripts/create-wcp-domain/utils/weblogic-logging-exporter/WebLogicLoggingExporter.yaml wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/config/ +$ kubectl cp <$WORKDIR>/logging-services/weblogic-logging-exporter/WebLogicLoggingExporter.yaml wcpns/wcp-domain-adminserver:/u01/oracle/user_projects/domains/wcp-domain/config/ ``` -#### Edit the WebCenter Portal ingress (Only for Voyager Loadbalancer) - -By default, paths for wls-exporter are commented in the ingress template. In order to expose the wls-exporter end-point externally, you must edit the WebCenter Portal ingress reapply them if necessary. (See `Using Voyager Loadbalacer`) - - #### Restart the Servers in the Domain To restart the servers, stop and then start them using the following commands: diff --git a/docs-source/content/wcportal-domains/release-notes.md b/docs-source/content/wcportal-domains/release-notes.md index 1d076c0af..75d304443 100644 --- a/docs-source/content/wcportal-domains/release-notes.md +++ b/docs-source/content/wcportal-domains/release-notes.md @@ -9,5 +9,6 @@ pre: "1. " | Date | Version | Change | --- | --- | --- | -| June 30, 2021 | 21.2.3 | Only Oracle Portal 12.2.1.4 is supported and certified with the WebLogic Kubernetes operator version 3.1.1. +| June 10, 2022 | 22.2.3 | Only Oracle WebCenter Portal 12.2.1.4 is supported and certified with the WebLogic Kubernetes operator version 3.3.0. +| June 30, 2021 | 21.2.3 | Only Oracle WebCenter Portal 12.2.1.4 is supported and certified with the WebLogic Kubernetes operator version 3.1.1.