The document discusses moving a Tomcat cluster to the cloud. It describes how Tomcat uses multicast for session replication in a cluster, but this does not work in the cloud. The solution presented uses the Kubernetes API to discover cluster nodes instead of multicast, allowing session replication to function in OpenShift. The architecture includes a DynamicMembershipService that refreshes the node list from a KubernetesMemberProvider accessing the Kubernetes API. This allows a Tomcat cluster to run in OpenShift with external session replication.
Report
Share
Report
Share
1 of 22
Download to read offline
More Related Content
Tomcat from a cluster to the cloud on RP3
1. 30/06/17
Copyright @ 2014 ParisJug. Licence CC - Creative Commons 2.0 France – Paternité - Pas
d'Utilisation Commerciale - Partage des Conditions Initiales à l'Identique
www.parisjug.org
2. Tomcat: from aTomcat: from a
cluster to the Cloudcluster to the Cloud
Tomcat: from aTomcat: from a
cluster to the Cloudcluster to the Cloud
par Jean-Frederic Clere
@jfclere
par Jean-Frederic Clere
@jfclere
30/06/17
3. 30/06/17
AgendaAgenda
●
Who I am
● A cluster:
– Session replication and application.
● The cloud:
– Nope it doesn’t work from scratch.
– External session replication
● Via Infinispan and KubePing
– Modify the tomcat cluster (still not finished)
● AKA dynamic list of nodes
●
Only TCP. (8888 port exported via deployment.yml)
– Demos
● What next? Questions / Suggestions
● Who I am
● A cluster:
– Session replication and application.
● The cloud:
– Nope it doesn’t work from scratch.
– External session replication
● Via Infinispan and KubePing
– Modify the tomcat cluster (still not finished)
●
AKA dynamic list of nodes
● Only TCP. (8888 port exported via deployment.yml)
– Demos
● What next? Questions / Suggestions
4. 30/06/17
Who am I?Who am I?
● Jean-Frederic Clere
● Red Hat
● Years writing JAVA code and server software
● Tomcat committer since 2001
● Doing OpenSource since 1999
● Cyclist/Runner etc
● Lived 15 years in Spain (Barcelona)
● Now in Neuchâtel (CH)
● Jean-Frederic Clere
● Red Hat
● Years writing JAVA code and server software
● Tomcat committer since 2001
● Doing OpenSource since 1999
● Cyclist/Runner etc
● Lived 15 years in Spain (Barcelona)
● Now in Neuchâtel (CH)
6. 6
30/06/17
How to replicate sessionsHow to replicate sessions
● In cluster:
● <distributable/> in web.xml
● <Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
● Port upd 45564
● Ports tcp range 4000:4100
● In cluster:
● <distributable/> in web.xml
● <Cluster
className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
● Port upd 45564
● Ports tcp range 4000:4100
8. OPENSHIFTOPENSHIFT
● A Red Hat project / product
● See OpenShift
https://www.openshift.com/
● Docker 1.4
● Kubernetes 1.12
● A Red Hat project / product
● See OpenShift
https://www.openshift.com/
● Docker 1.4
● Kubernetes 1.12
10. Developping Tomcat App in OpenShiftDevelopping Tomcat App in OpenShift
RHEL RHEL
When a developer
creates a new
application OpenShift
start a new pod
Web Console
Eclipse IDE
Command Line
Master Node Node Node
RHEL
pod
AWS / CloudForms / OpenStack (IaaS) / RHEV (Virt) / Bare Metal
11. Getting startedGetting started
● minishift:
– Allow to demo on single box.
– Easy to setup
– Small demo
● Bare metal / VM:
– Use ansible to install
– 2 nodes + master minimal
● Tomcat webapp with sessions
– Counter demo.
● minishift:
– Allow to demo on single box.
– Easy to setup
– Small demo
● Bare metal / VM:
– Use ansible to install
– 2 nodes + master minimal
● Tomcat webapp with sessions
– Counter demo.
12. Session replication in a clusterSession replication in a cluster
● HTTP/1.1
– No transaction
– No persistent connection
● Web App:
– Using cookies to carry session ID
– Store information in the session:
● Shopping cart etc.
● Multi nodes and dynamic
– Route request to right node
– Replicate information
● HTTP/1.1
– No transaction
– No persistent connection
● Web App:
– Using cookies to carry session ID
– Store information in the session:
● Shopping cart etc.
● Multi nodes and dynamic
– Route request to right node
– Replicate information
13. From a cluster to the CloudFrom a cluster to the Cloud
RHEL RHEL
Broker Node Node Node
RHEL
! Power
COL 1 2 3 4 5 6 7 8 1 2 3 6 25 50 8012
100
10
Ether 10/100
Load balancer Tomcat node Tomcat nodeTomcat node
HTTP
D
14. Problems for a cluster to cloud...Problems for a cluster to cloud...
● Many ways to solve:
– Embed tomcat with SpringBoot
– Create a docker image
– Extend an existing docker image
– Fabric8
● Tomcat session replication:
– No multicast in the cloud.
– Need a “ping” to find the other nodes
(KubePing)
– Add view to the system account of the
project.
● Many ways to solve:
– Embed tomcat with SpringBoot
– Create a docker image
– Extend an existing docker image
– Fabric8
● Tomcat session replication:
– No multicast in the cloud.
– Need a “ping” to find the other nodes
(KubePing)
– Add view to the system account of the
project.
15. GoalsGoals
● Have something:
– Minimal modification of the tomcat configuration (server.xml)
– Reuse existing code
● Some code still missing:
– Some in Tomcat
– Documentation / tests.
● Some more stuff:
– We use ansible for the install.
– Some maven builds and shells.
● Have something:
– Minimal modification of the tomcat configuration (server.xml)
– Reuse existing code
● Some code still missing:
– Some in Tomcat
– Documentation / tests.
● Some more stuff:
– We use ansible for the install.
– Some maven builds and shells.
16. Ismaïl Senhaji, Guillaume P
ythoud
16
30/06/17
SolutionSolution
Tomcat built-in solution
Peer discovery through multicast
heartbeat messages
Does not work in a cloud environment
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Sessi
on
Data
Multicast
Our solution
Peer discovery through
Kubernetes Downward API
Works in OpenShift
Kubernetes API
17. Ismaïl Senhaji, Guillaume P
ythoud
17
30/06/17
Kubernetes APIKubernetes API
Tools for managing a
Kubernetes cluster
Accessible from the pods
within the cluster
GET
/api/v1/namespaces/tomcat-in-
the-cloud/pods
➔ Return a JSON representation of all
the pods in the cluster
Tools for managing a
Kubernetes cluster
Accessible from the pods
within the cluster
GET
/api/v1/namespaces/tomcat-in-
the-cloud/pods
➔ Return a JSON representation of all
the pods in the cluster
18. Ismaïl Senhaji, Guillaume P
ythoud
18
30/06/17
ArchitectureArchitecture
DynamicMembershipService
RefreshThread
● Call memberProvider.getMembers()
● Filter out already known Member
● Inform listeners of
new/dead members
KubernetesMemberProvider
● init():
● Get URL, cert, ... from
environment variables
● Set startTime
● getMembers():
● Call api to get pods
● Filter active pods
● Compute aliveTime
MemberProvider
● init(Properties)
● getMembers(): List<Member>
19. Where are we?Where are we?
● Main sites:
– https://docs.openshift.com
– https://github.com/Project31
– https://github.com/iSma/tomcat-
in-the-cloud/
● Thanks:
– Université de Neuchâtel
– Kurt Stam
<kstam@redhat.com>
● Main sites:
– https://docs.openshift.com
– https://github.com/Project31
– https://github.com/iSma/tomcat-
in-the-cloud/
● Thanks:
– Université de Neuchâtel
– Kurt Stam
<kstam@redhat.com>