Keycloak standalone cluster on Cloud Foundry

时光毁灭记忆、已成空白 提交于 2019-11-29 09:01:05

I finally found the answer to my own question.

Go to this keycloak4cf repo if you are looking for a quick solution.


Main problems that I had to face:

Keycloak minimal version

Use the jboss/keycloak:5.0.0 or newer/latest

There is hardcoded .svc.cluster.local DNS query suffix removed with JGRP-2295.

This fix was released in JGroups 4.0.15.Final, that is used in Infinispan Core 9.4.0.Final., released with Keycloak 5.0.0 (included inifnispan-core 9.4.3.Final).

Clustering

Clustering have to be done with TCP instead of multicast UDP (there is no multicast on Cloud Foundry - thank you @DanielMikusa for the tip).

To change this config use dns.DNS_PING.cli:

embed-server --server-config=standalone-ha.xml --std-out=echo
batch
/subsystem=jgroups:write-attribute(name=default-stack,value=tcp)
/subsystem=jgroups/channel=ee:write-attribute(name=stack,value=tcp)
/subsystem=jgroups/stack=udp/protocol=PING:remove()
/subsystem=jgroups/stack=udp/protocol=$keycloak_jgroups_discovery_protocol:add(add-index=0, properties=$keycloak_jgroups_discovery_protocol_properties)
/subsystem=jgroups/stack=tcp/protocol=MPING:remove()
/subsystem=jgroups/stack=tcp/protocol=$keycloak_jgroups_discovery_protocol:add(add-index=0, properties=$keycloak_jgroups_discovery_protocol_properties)
run-batch
stop-embedded-server

Add network policy to allow connections between cluster nodes:

cf add-network-policy keycloak-cluster-poc --destination-app keycloak-cluster-poc --protocol tcp --port 7600
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!