Skip to content

Commit eb8e75e

Browse files
committed
Add first Kubernetes example based on Bonita 10.0 / 2024.1
0 parents  commit eb8e75e

13 files changed

+491
-0
lines changed

README.md

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Install Minikube
2+
3+
```
4+
curl -LO https://storage.googleapis.com/minikube/releases/v1.33.1/minikube-linux-amd64
5+
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
6+
```
7+
8+
```
9+
minikube version
10+
minikube version: v1.33.1
11+
commit: 5883c09216182566a63dff4c326a6fc9ed2982ff
12+
```
13+
14+
```
15+
minikube start --kubernetes-version 1.28.4
16+
```
17+
18+
# Create test namespace
19+
20+
```
21+
kubectl create ns bonita
22+
```
23+
24+
# Deploy PostgreSQL
25+
26+
```
27+
kubectl -n bonita create configmap db-scripts --from-file=db_scripts/
28+
kubectl -n bonita apply -f postgresql.yaml
29+
```
30+
31+
Test connection
32+
33+
```
34+
kubectl -n bonita run psql-client --image postgres:15.7 --rm --tty -i --command -- /bin/bash
35+
```
36+
37+
```
38+
export PGPASSWORD=testpassword
39+
psql -h postgres-db -p 5432 -U postgres postgres
40+
postgres=# show max_connections;
41+
max_connections
42+
-----------------
43+
100
44+
(1 ligne)
45+
46+
postgres=# \list
47+
List of databases
48+
Name | Owner | Encoding | Collate | Ctype | Access privileges
49+
-----------+------------+----------+------------+------------+-----------------------
50+
bizdata | bizuser | UTF8 | en_US.utf8 | en_US.utf8 |
51+
bonita | bonitauser | UTF8 | en_US.utf8 | en_US.utf8 |
52+
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
53+
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
54+
| | | | | postgres=CTc/postgres
55+
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
56+
| | | | | postgres=CTc/postgres
57+
(5 rows)
58+
```
59+
60+
61+
# Deploy Bonita
62+
63+
Add Docker registry credentials
64+
```
65+
DOCKER_SEVER=bonitasoft.jfrog.io
66+
DOCKER_USERNAME=...
67+
DOCKER_TOKEN=...
68+
kubectl create secret docker-registry imagepullsecret --docker-server="${DOCKER_SEVER}" --docker-username="${DOCKER_USERNAME}" --docker-password="${DOCKER_TOKEN}" -n bonita
69+
```
70+
71+
Request a Bonita license compatible with Kubernetes into the [Customer service center](https://csc.bonitacloud.bonitasoft.com/apps/CustomerServices)
72+
73+
Add this bonita license
74+
```
75+
cp BonitaSubscription-10.0-Test-20240312-20240908.lic bonita-license.lic
76+
kubectl -n bonita create configmap bonita-license --from-file=bonita-license.lic
77+
```
78+
79+
```
80+
kubectl -n bonita create configmap bonita-scripts --from-file=bonita_scripts/
81+
```
82+
83+
```
84+
kubectl -n bonita apply -f bonita_secrets.yaml
85+
kubectl -n bonita apply -f bonita_cm.yaml
86+
kubectl -n bonita create serviceaccount bonitaserviceaccount
87+
kubectl -n bonita apply -f bonita_rbac.yaml
88+
kubectl -n bonita apply -f bonita_deployment.yaml
89+
kubectl -n bonita apply -f bonita_service.yaml
90+
```
91+
92+
Test connection
93+
```
94+
kubectl -n bonita port-forward service/bonita-test 8080:8080
95+
```
96+
97+
Open http://127.0.0.1:8080 in your browser and use admin / myAdminSecret credentials.
98+
99+
# Scale up Bonita
100+
101+
Once bonita finished its startup
102+
```
103+
kubectl -n bonita logs --selector app.kubernetes.io/instance=bonita-test | grep "Server startup in" | jq .message
104+
"Server startup in [20896] milliseconds"
105+
```
106+
107+
```
108+
kubectl -n bonita get deployment
109+
NAME READY UP-TO-DATE AVAILABLE AGE
110+
bonita-test 1/1 1 1 11m
111+
```
112+
113+
You can scale up
114+
```
115+
kubectl -n bonita scale --current-replicas=1 --replicas=2 deployment/bonita-test
116+
```
117+
118+
```
119+
kubectl -n bonita get deployment
120+
NAME READY UP-TO-DATE AVAILABLE AGE
121+
bonita-test 2/2 2 2 16m
122+
```
123+
124+
In case of success you will have this kind of message
125+
```
126+
kubectl -n bonita logs --selector app.kubernetes.io/instance=bonita-test | grep Members | jq .message
127+
"[10.244.0.9]:5701 [bonita-test] [5.3.5] \n\nMembers {size:2, ver:2} [\n\tMember [10.244.0.9]:5701 - e633ecf6-a670-448b-bd69-f1fdab39299a this\n\tMember [10.244.0.10]:5701 - 90903a8a-c5d9-49f7-9021-e81e958e995a\n]\n"
128+
```
129+
130+
# Clean test
131+
132+
```
133+
kubectl delete ns bonita
134+
```

UNLICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

bonita_cm.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: bonita-test
5+
data:
6+
BDM_DS_CONNECTION_POOL_INITIAL_SIZE: "1"
7+
BDM_DS_CONNECTION_POOL_MAX_IDLE: "10"
8+
BDM_DS_CONNECTION_POOL_MAX_TOTAL: "20"
9+
BDM_DS_CONNECTION_POOL_MIN_IDLE: "1"
10+
BIZ_DB_NAME: bizdata
11+
BIZ_DB_USER: bizuser
12+
BONITA_DS_CONNECTION_POOL_INITIAL_SIZE: "2"
13+
BONITA_DS_CONNECTION_POOL_MAX_IDLE: "20"
14+
BONITA_DS_CONNECTION_POOL_MAX_TOTAL: "50"
15+
BONITA_DS_CONNECTION_POOL_MIN_IDLE: "2"
16+
BONITA_PLATFORM_PERSISTENCE_USE_SECOND_LEVEL_CACHE: "false"
17+
# 1 hour in seconds
18+
BONITA_RUNTIME_CLUSTER_HTTP_SESSION_TIMEOUT: "3600"
19+
# 1 hour in milliseconds
20+
BONITA_RUNTIME_SESSION_DURATION: "3600000"
21+
BONITA_SERVER_LOGGING_FILE: /opt/custom-init.d/log4j2-appenders.xml,/opt/bonita/conf/logs/log4j2-loggers.xml
22+
CLUSTER_MODE: "true"
23+
DB_HOST: postgres-db
24+
DB_NAME: bonita
25+
DB_PORT: "5432"
26+
DB_USER: bonitauser
27+
DB_VENDOR: postgres
28+
HTTP_API: "false"
29+
HTTP_MAX_THREADS: "20"
30+
JAVA_OPTS: -Djava.awt.headless=true -XX:+UseContainerSupport -XX:InitialRAMPercentage=60
31+
-XX:MaxRAMPercentage=60 -XX:MinRAMPercentage=60 -XX:+HeapDumpOnOutOfMemoryError
32+
-XX:+UseG1GC -Dbonita.client.home=/opt/bonita_lic
33+
KUBERNETES_NAME: bonita-test
34+
KUBERNETES_NAMESPACE: bonita
35+
REMOTE_IP_VALVE_ENABLED: "true"
36+
TZ: Europe/Paris

bonita_deployment.yaml

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: bonita-test
5+
spec:
6+
progressDeadlineSeconds: 600
7+
replicas: 1
8+
revisionHistoryLimit: 10
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/instance: bonita-test
12+
app.kubernetes.io/name: bonita
13+
strategy:
14+
rollingUpdate:
15+
maxSurge: 25%
16+
maxUnavailable: 25%
17+
type: RollingUpdate
18+
template:
19+
metadata:
20+
labels:
21+
app.kubernetes.io/instance: bonita-test
22+
app.kubernetes.io/name: bonita
23+
spec:
24+
serviceAccountName: bonitaserviceaccount
25+
hostname: bonita
26+
containers:
27+
- envFrom:
28+
- secretRef:
29+
name: bonita-test-creds
30+
- configMapRef:
31+
name: bonita-test
32+
image: bonitasoft.jfrog.io/docker/bonita-subscription:10.0.0
33+
imagePullPolicy: IfNotPresent
34+
livenessProbe:
35+
failureThreshold: 10
36+
httpGet:
37+
httpHeaders:
38+
- name: Authorization
39+
value: Basic bW9uaXRvcmluZzpteU1vbml0b3JpbmdTZWNyZXQ=
40+
- name: User-Agent
41+
value: BonitaHealthCheck/1.0
42+
path: /bonita/healthz
43+
port: 8080
44+
scheme: HTTP
45+
periodSeconds: 15
46+
successThreshold: 1
47+
timeoutSeconds: 5
48+
name: bonita
49+
ports:
50+
- containerPort: 5701
51+
name: hazelcast
52+
protocol: TCP
53+
- containerPort: 8080
54+
name: bonita
55+
protocol: TCP
56+
resources:
57+
limits:
58+
cpu: 2
59+
memory: 2000Mi
60+
requests:
61+
cpu: 2
62+
memory: 2000Mi
63+
securityContext:
64+
runAsGroup: 1000
65+
runAsUser: 1000
66+
startupProbe:
67+
failureThreshold: 20
68+
httpGet:
69+
httpHeaders:
70+
- name: Authorization
71+
value: Basic bW9uaXRvcmluZzpteU1vbml0b3JpbmdTZWNyZXQ=
72+
- name: User-Agent
73+
value: BonitaHealthCheck/1.0
74+
path: /bonita/healthz
75+
port: 8080
76+
scheme: HTTP
77+
initialDelaySeconds: 120
78+
periodSeconds: 15
79+
successThreshold: 1
80+
timeoutSeconds: 5
81+
volumeMounts:
82+
- name: bonita-scripts
83+
mountPath: /opt/custom-init.d
84+
- name: bonita-lic
85+
mountPath: /opt/bonita_lic
86+
dnsPolicy: ClusterFirst
87+
imagePullSecrets:
88+
- name: imagepullsecret
89+
restartPolicy: Always
90+
schedulerName: default-scheduler
91+
securityContext: {}
92+
terminationGracePeriodSeconds: 30
93+
volumes:
94+
- name: bonita-scripts
95+
configMap:
96+
name: bonita-scripts
97+
items:
98+
- key: bonita_setup.sh
99+
path: bonita_setup.sh
100+
- key: log4j2-appenders.xml
101+
path: log4j2-appenders.xml
102+
- key: bonita-platform-sp-cluster-custom.properties
103+
path: bonita-platform-sp-cluster-custom.properties
104+
- name: bonita-lic
105+
configMap:
106+
name: bonita-license
107+
items:
108+
- key: bonita-license.lic
109+
path: bonita-license.lic

bonita_rbac.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: hazelcast-role
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- endpoints
10+
verbs:
11+
- get
12+
- list
13+
---
14+
apiVersion: rbac.authorization.k8s.io/v1
15+
kind: RoleBinding
16+
metadata:
17+
name: hazelcast-role-binding
18+
roleRef:
19+
apiGroup: rbac.authorization.k8s.io
20+
kind: Role
21+
name: hazelcast-role
22+
subjects:
23+
- kind: ServiceAccount
24+
name: bonitaserviceaccount
25+
namespace: bonita
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
bonita.cluster.group.name={{KUBERNETES_NAME}}
2+
3+
bonita.platform.cluster.hazelcast.multicast.enabled=false
4+
bonita.platform.cluster.hazelcast.tcpip.enabled=false
5+
bonita.platform.cluster.hazelcast.aws.enabled=false
6+
bonita.platform.cluster.hazelcast.kubernetes.enabled=true
7+
8+
bonita.platform.cluster.hazelcast.kubernetes.namespace={{KUBERNETES_NAMESPACE}}
9+
bonita.platform.cluster.hazelcast.kubernetes.serviceName={{KUBERNETES_NAME}}
10+
bonita.platform.cluster.hazelcast.kubernetes.resolveNotReadyAddresses=false
11+
bonita.platform.cluster.hazelcast.diagnostics.enabled=false
12+
bonita.platform.cluster.hazelcast.diagnostics.metric.level=info
13+
bonita.platform.cluster.hazelcast.partitionGroup.enabled=true
14+
bonita.platform.cluster.hazelcast.partitionGroup.groupType=ZONE_AWARE
15+
16+
## Monitor locks on cluster
17+
org.bonitasoft.engine.monitoring.metrics.cluster.locks.enable=true

bonita_scripts/bonita_setup.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
3+
set -euxo pipefail
4+
5+
BONITA_DIR="/opt/bonita"
6+
7+
# Use setup tool to configure Bonita Tomcat bundle
8+
9+
cd ${BONITA_DIR}/setup
10+
./setup.sh pull
11+
12+
# configure logging
13+
cp /opt/custom-init.d/log4j2-appenders.xml ${BONITA_DIR}/conf/logs/log4j2-appenders.xml
14+
15+
# configure cluster
16+
if [[ "${CLUSTER_MODE}" == "true" ]]; then
17+
sed -e 's/{{KUBERNETES_NAME}}/'"${KUBERNETES_NAME}"'/g' \
18+
-e 's/{{KUBERNETES_NAMESPACE}}/'"${KUBERNETES_NAMESPACE}"'/g' \
19+
/opt/custom-init.d/bonita-platform-sp-cluster-custom.properties \
20+
> ${BONITA_DIR}/setup/platform_conf/current/platform_engine/bonita-platform-sp-cluster-custom.properties
21+
fi
22+
23+
cd ${BONITA_DIR}/setup
24+
./setup.sh configure
25+
./setup.sh push

0 commit comments

Comments
 (0)