https://github.com/ebean-orm/ebean-k8scache
L2 Cache support running in Kubernetes
https://github.com/ebean-orm/ebean-k8scache
Last synced: 10 months ago
JSON representation
L2 Cache support running in Kubernetes
- Host: GitHub
- URL: https://github.com/ebean-orm/ebean-k8scache
- Owner: ebean-orm
- License: apache-2.0
- Created: 2017-12-08T06:15:35.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-02T20:46:38.000Z (over 3 years ago)
- Last Synced: 2025-01-18T01:32:20.134Z (12 months ago)
- Language: Java
- Size: 62.5 KB
- Stars: 0
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ebean-k8scache
L2 Cache support running in Kubernetes
## Steps
1. Add ebean-k8scache as a dependency
2. Configure the kubernetes service name and port
### Example configuration
```yaml
ebean:
cluster:
active: true
serviceName: my-service
namespace: my-namespace
podName: ${POD_NAME}
port: 9911
```
The above means that ebean-k8scache will discover all the pods for
`my-service` and join them as a cluster using port 9911.
**Note:** To discovery process succeed the k8s ServiceAccount must have access to request api
`/api/v1/namespaces/${namespace}/endpoints/${serviceName}` and the Pod must expose the `POD_NAME` system variable to the container.
All the pods will run a L2 Cache and cache invalidation messages will
be propagated to all the pods in the cluster as needed.
## Configuration
As an example of configuration via code:
```java
ContainerConfig container = new ContainerConfig();
container.setActive(true);
container.setPort(9911);
container.setServiceName("my-service");
container.setNamespace("my-namespace");
config.setPodName(System.getenv("POD_NAME"));
// On the ServerConfig of the default Server
// set the ContainerConfig
ServerConfig serverConfig = new ServerConfig();
serverConfig.setContainerConfig(container);
// When the container of the default starts it will discover
// the other pods and join them as a cluster
EbeanServer defaultServer = EbeanServerFactory.create(serverConfig);
```
## Runtime membership checking
Periodically the membership of the cluster is checked. By default this is done every
minute and back off to every 5 minutes.
## Logging
Set logging on `io.ebean.cluster.K8s` to DEBUG or TRACE for this plugin.
Set logging on `io.ebean.cache` to DEBUG or TRACE to view L2 cache activity
such as GETs, PUTs etc.