Skip to content

Commit

Permalink
Merge pull request #1 from ashishchalak/master
Browse files Browse the repository at this point in the history
Adding NFS support to WCSites
  • Loading branch information
vivek-sam authored Apr 30, 2020
2 parents 7bcdd2c + 894d702 commit 4582d6b
Show file tree
Hide file tree
Showing 14 changed files with 3,582 additions and 3,546 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ spec:
- ReadWriteMany
# Valid values are Retain, Delete or Recycle
persistentVolumeReclaimPolicy: Retain
hostPath:
# nfs:
# server: %SAMPLE_STORAGE_NFS_SERVER%
#hostPath:
nfs:
server: %NFS_SERVER%
path: "/scratch/K8SVolume/WCSitesDB"
---
kind: PersistentVolumeClaim
Expand Down
Original file line number Diff line number Diff line change
@@ -1,117 +1,117 @@
# Copyright 2020, Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
import xml.dom.minidom
import re
import sys

def getManagedServerCount(domainHome):
# use the parse() function to load and parse an XML file
doc = xml.dom.minidom.parse(domainHome + "/config/config.xml")
servers = doc.getElementsByTagName("server")
print "Total Configured Managed Servers: %d " % (servers.length - 1)
return servers.length - 1;


# Method to uncomment and comment the required tag and save back
def replaceXml(domainHome, ms_server):
f = open(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/ticket-cache.xml","r+w")
filecontent = f.read()
#Uncomment the one to be used
filecontent = re.sub ( r'<!--<cacheManagerPeerProviderFactory','<cacheManagerPeerProviderFactory', filecontent,1)
filecontent = re.sub ( r'cas_tgt" />-->','cas_tgt" />', filecontent,1)
#Comment the one not used
filecontent = re.sub ( r'<cacheManagerPeerProviderFactory','<!--cacheManagerPeerProviderFactory', filecontent,1)
filecontent = re.sub ( r'propertySeparator="," />','propertySeparator="," -->', filecontent,1)
f.seek(0)
f.write(filecontent)
f.write("\n\n\n")
f.close()

# Method to replace the properties
def replaceRmiUrlsInCache(domainHome, prefix, n, ms_server, excludedServerNumber, filename, port):
doc = xml.dom.minidom.parse(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/" + filename)
abc = doc.getElementsByTagName("cacheManagerPeerProviderFactory")
processString = "peerDiscovery=manual,rmiUrls=//localhost:<port>/notifier"

for element in abc:
element.setAttribute("properties", processString)

for x in range (1,n-1):
processString = processString + "|//localhost:<port>/notifier"

# We should have got the properties attribute now tokenized with localhost and 41001. Exclude 1 add the rest
for i in range (1,n+1):
if i <> int(excludedServerNumber):
processString = re.sub ( r'localhost',prefix + str(i), processString,1)
processString = re.sub ( r'<port>',str(port), processString,1)

element.setAttribute("properties", processString)
print(processString)
ghi = doc.getElementsByTagName("cacheManagerPeerListenerFactory")
for element in ghi:
processString = element.getAttribute("properties")
processString = "hostName="+prefix+ str(excludedServerNumber) +",port=" + str(port) +",remoteObjectPort=" + str(int(port)+1) + ",socketTimeoutMillis=12000"
element.setAttribute("properties", processString)
myfile = open(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/" + filename , "w")
myfile.write(doc.toxml())
myfile.close()
print("Updated " + filename)

# Method to replace the properties
def replaceRmiUrls(domainHome, prefix, n, ms_server, excludedServerNumber, port):
doc = xml.dom.minidom.parse(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/ticket-cache.xml")
abc = doc.getElementsByTagName("cacheManagerPeerProviderFactory")
processString = ""

for element in abc:
processString = element.getAttribute("properties")

for x in range (1,n-1):
processString = processString + "|//localhost:41001/cas_st|//localhost:41001/cas_tgt"

# We should have got the properties attribute now tokenized with localhost and 41001. Exclude 1 add the rest
for i in range (1,n+1):
if i <> int(excludedServerNumber):
processString = re.sub ( r'localhost',prefix + str(i), processString,1)
processString = re.sub ( r'41001',str(port), processString,1)
processString = re.sub ( r'localhost',prefix + str(i), processString,1)
processString = re.sub ( r'41001',str(port), processString,1)

element.setAttribute("properties", processString)
print(processString)
ghi = doc.getElementsByTagName("cacheManagerPeerListenerFactory")
for element in ghi:
processString = element.getAttribute("properties")
processString = "hostName=" + prefix + str(excludedServerNumber) + ",port=" + str(port) + ",remoteObjectPort=" + str(int(port)+1) + ",socketTimeoutMillis=12000"
element.setAttribute("properties", processString)
myfile = open(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/ticket-cache.xml", "w")
myfile.write(doc.toxml())
myfile.close()
print("Updated " + "ticket-cache.xml")

def main():
# count the arguments
arguments = len(sys.argv) - 1
print ("The script is called with %i arguments" % (arguments))
domainHome = sys.argv[1]
serverPrefix = sys.argv[2]
ms_server = sys.argv[3]
port = sys.argv[4]
excludedServerNumber = ms_server[-1]
print("Host prefix set to " + serverPrefix)
print("Managed Server set to - " + ms_server)
print("Excluded Server Number set to - " + excludedServerNumber)
print("Starting port set to - " + port)
replaceXml(domainHome, ms_server)
servercount = getManagedServerCount(domainHome)
replaceRmiUrls(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, port)
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "linked-cache.xml", int(port) + 2)
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "cs-cache.xml", int(port) + 4)
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "cas-cache.xml", int(port) + 6 )
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "ss-cache.xml", int(port) + 8 )


if __name__ == "__main__":
# calling main function
main()

# Copyright 2020, Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
import xml.dom.minidom
import re
import sys

def getManagedServerCount(domainHome):
# use the parse() function to load and parse an XML file
doc = xml.dom.minidom.parse(domainHome + "/config/config.xml")
servers = doc.getElementsByTagName("server")
print "Total Configured Managed Servers: %d " % (servers.length - 1)
return servers.length - 1;


# Method to uncomment and comment the required tag and save back
def replaceXml(domainHome, ms_server):
f = open(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/ticket-cache.xml","r+w")
filecontent = f.read()
#Uncomment the one to be used
filecontent = re.sub ( r'<!--<cacheManagerPeerProviderFactory','<cacheManagerPeerProviderFactory', filecontent,1)
filecontent = re.sub ( r'cas_tgt" />-->','cas_tgt" />', filecontent,1)
#Comment the one not used
filecontent = re.sub ( r'<cacheManagerPeerProviderFactory','<!--cacheManagerPeerProviderFactory', filecontent,1)
filecontent = re.sub ( r'propertySeparator="," />','propertySeparator="," -->', filecontent,1)
f.seek(0)
f.write(filecontent)
f.write("\n\n\n")
f.close()

# Method to replace the properties
def replaceRmiUrlsInCache(domainHome, prefix, n, ms_server, excludedServerNumber, filename, port):
doc = xml.dom.minidom.parse(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/" + filename)
abc = doc.getElementsByTagName("cacheManagerPeerProviderFactory")
processString = "peerDiscovery=manual,rmiUrls=//localhost:<port>/notifier"

for element in abc:
element.setAttribute("properties", processString)

for x in range (1,n-1):
processString = processString + "|//localhost:<port>/notifier"

# We should have got the properties attribute now tokenized with localhost and 41001. Exclude 1 add the rest
for i in range (1,n+1):
if i <> int(excludedServerNumber):
processString = re.sub ( r'localhost',prefix + str(i), processString,1)
processString = re.sub ( r'<port>',str(port), processString,1)

element.setAttribute("properties", processString)
print(processString)
ghi = doc.getElementsByTagName("cacheManagerPeerListenerFactory")
for element in ghi:
processString = element.getAttribute("properties")
processString = "hostName="+prefix+ str(excludedServerNumber) +",port=" + str(port) +",remoteObjectPort=" + str(int(port)+1) + ",socketTimeoutMillis=12000"
element.setAttribute("properties", processString)
myfile = open(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/" + filename , "w")
myfile.write(doc.toxml())
myfile.close()
print("Updated " + filename)

# Method to replace the properties
def replaceRmiUrls(domainHome, prefix, n, ms_server, excludedServerNumber, port):
doc = xml.dom.minidom.parse(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/ticket-cache.xml")
abc = doc.getElementsByTagName("cacheManagerPeerProviderFactory")
processString = ""

for element in abc:
processString = element.getAttribute("properties")

for x in range (1,n-1):
processString = processString + "|//localhost:41001/cas_st|//localhost:41001/cas_tgt"

# We should have got the properties attribute now tokenized with localhost and 41001. Exclude 1 add the rest
for i in range (1,n+1):
if i <> int(excludedServerNumber):
processString = re.sub ( r'localhost',prefix + str(i), processString,1)
processString = re.sub ( r'41001',str(port), processString,1)
processString = re.sub ( r'localhost',prefix + str(i), processString,1)
processString = re.sub ( r'41001',str(port), processString,1)

element.setAttribute("properties", processString)
print(processString)
ghi = doc.getElementsByTagName("cacheManagerPeerListenerFactory")
for element in ghi:
processString = element.getAttribute("properties")
processString = "hostName=" + prefix + str(excludedServerNumber) + ",port=" + str(port) + ",remoteObjectPort=" + str(int(port)+1) + ",socketTimeoutMillis=12000"
element.setAttribute("properties", processString)
myfile = open(domainHome + "/config/fmwconfig/servers/" + ms_server + "/config/ticket-cache.xml", "w")
myfile.write(doc.toxml())
myfile.close()
print("Updated " + "ticket-cache.xml")

def main():
# count the arguments
arguments = len(sys.argv) - 1
print ("The script is called with %i arguments" % (arguments))
domainHome = sys.argv[1]
serverPrefix = sys.argv[2]
ms_server = sys.argv[3]
port = sys.argv[4]
excludedServerNumber = ms_server[-1]
print("Host prefix set to " + serverPrefix)
print("Managed Server set to - " + ms_server)
print("Excluded Server Number set to - " + excludedServerNumber)
print("Starting port set to - " + port)
replaceXml(domainHome, ms_server)
servercount = getManagedServerCount(domainHome)
replaceRmiUrls(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, port)
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "linked-cache.xml", int(port) + 2)
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "cs-cache.xml", int(port) + 4)
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "cas-cache.xml", int(port) + 6 )
replaceRmiUrlsInCache(domainHome, serverPrefix, servercount, ms_server, excludedServerNumber, "ss-cache.xml", int(port) + 8 )


if __name__ == "__main__":
# calling main function
main()

Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Copyright 2020, Oracle Corporation 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, VOYAGER
type: TRAEFIK
#type: VOYAGER

# WLS domain as backend to the load balancer
wlsDomain:
domainUID: wcsitesinfra
adminServerName: adminserver
adminServerPort: 7001
wcsitesClusterName: wcsites_cluster
wcsitesManagedServerPort: 8001

# Voyager specific values
voyager:
# web port
webPort: 30305
# stats port
statsPort: 30317
# Copyright 2020, Oracle Corporation 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, VOYAGER
type: TRAEFIK
#type: VOYAGER

# WLS domain as backend to the load balancer
wlsDomain:
domainUID: wcsitesinfra
adminServerName: adminserver
adminServerPort: 7001
wcsitesClusterName: wcsites_cluster
wcsitesManagedServerPort: 8001

# Voyager specific values
voyager:
# web port
webPort: 30305
# stats port
statsPort: 30317
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ namespace: wcsites-ns
# 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
weblogicDomainStorageType: NFS

# 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
weblogicDomainStorageNFSServer: %NFS_SERVER%

# Physical path of the persistent storage.
# When weblogicDomainStorageType is set to HOST_PATH, this value should be set the to path to the
Expand All @@ -39,5 +39,4 @@ weblogicDomainStoragePath: /scratch/K8SVolume/WCSites
weblogicDomainStorageReclaimPolicy: Retain

# Total storage allocated to the persistent storage.
weblogicDomainStorageSize: 10Gi

weblogicDomainStorageSize: 10Gi
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ to create the domain home for other use cases. You can modify the generated doma
To start the domain, apply the above `domain.yaml`:
```bash
$ kubectl apply -f kubernetes/samples/scripts/create-wcsites-domain/output/weblogic-domains/wcsitesinfra/domain.yaml
domain.weblogic.oracle/wcsitesinfra created
```
```bash
$ kubectl apply -f kubernetes/samples/scripts/create-wcsites-domain/output/weblogic-domains/wcsitesinfra/domain.yaml
domain.weblogic.oracle/wcsitesinfra created
```

#### Verify the WebCenter Sites Domain
Verify that the domain and servers pods and services are created and in the READY state:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,11 @@ elasticsearch ClusterIP 10.100.11.154 <none> 9200/TCP,9300/TCP 4m
kibana NodePort 10.97.205.0 <none> 5601:31884/TCP 4m32s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 71d
```
You can access the Kibana dashboard at `http://mycompany.com:kibana-nodeport/`. In our example, the node port would be 31884.
You can access the Kibana dashboard at `http://mycompany.com:kibana-nodeport/`. In our example, the node port would be 31884.

##### Create an Index Pattern in Kibana
Create an index pattern `logstash*` in **Kibana > Management**. After the servers are started, you will see the log data in the Kibana dashboard:

![WLE-Kibana-Dashboard](images/logstash-kibana-1.png)

![WLE-Kibana-Dashboard](images/logstash-kibana-2.png)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ RoleBinding is required for Prometheus to access the endpoints provided by the W
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: monitoring
namespace: monitoring
```
Similarly, add the `Role` for the namespace under which the WebLogic Servers pods are running in the Kubernetes cluster. Edit `kube-prometheus/manifests/prometheus-roleSpecificNamespaces.yaml` in the Prometheus Operator deployment manifests and add the `Role` for the namespace (`wcsites-ns`) similar to the following example:
```
Expand Down Expand Up @@ -254,6 +254,11 @@ To deploy the service monitor, use the above wls-exporter.yaml deployment YAML a
```
$ kubectl create -f kubernetes/samples/scripts/create-wcsites-domain/utils/weblogic-monitoring-exporter/wls-exporter.yaml
```

#### Additional Setup For Voyager Load Balancer

In step 2 of [Configure Voyager to Manage Ingresses]({{< relref "/wcsites-domains/manage-wcsites-domains/loadbalancer-voyager-setup-for-wcsites-domain-setup-on-k8s#configure-voyager-to-manage-ingresses">}}), for wcsites-cluster, enable the last rule for path ‘wls-exporter’ and then re-deploy Voyager Load Balancer.

#### Enable Prometheus to Discover the Service

After the deployment of the service monitor, Prometheus should be able to discover wls-exporter and export metrics.
Expand All @@ -262,7 +267,6 @@ 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).
Expand Down
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4582d6b

Please sign in to comment.