Skip to content

Commit

Permalink
[alveolus] Add Kafka local stack
Browse files Browse the repository at this point in the history
  • Loading branch information
fpapon committed Aug 20, 2024
1 parent 4c400c4 commit e35b1f2
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 0 deletions.
29 changes: 29 additions & 0 deletions alveolus/kafka-local/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2021 - present - Yupiik SAS - https://www.yupiik.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>alveolus</artifactId>
<groupId>io.yupiik.alveoli</groupId>
<version>1.0.28-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>kafka-local</artifactId>
<name>BundleBee :: Alveolus :: Kafka Local</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (c) 2021 - present - Yupiik SAS - https://www.yupiik.com
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

apiVersion: v1
kind: ConfigMap
metadata:
name: kafka-local-config
labels:
app: kafka-local
data:
broker.id: "{{kafka-local.brokerId:-kafka-local}}"
log.dirs: "/usr/share/kafka/data"
JAVA_OPTS: "{{kafka-local.javaOpts:--Dbundlebee=true}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# Copyright (c) 2021 - present - Yupiik SAS - https://www.yupiik.com
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

kind: PersistentVolume
apiVersion: v1
metadata:
name: kafka-pv-volume
labels:
type: local
app: kafka-local
finalizers: []
spec:
storageClassName: local-storage
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
claimRef:
name: kafka-pv-claim
namespace: "{{bundlebee.kube.namespace:-default}}"
hostPath:
path: "{{kafka-local.mountPath:-/data/kafka-local}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Copyright (c) 2021 - present - Yupiik SAS - https://www.yupiik.com
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: kafka-pv-claim
labels:
app: kafka-local
spec:
storageClassName: local-storage
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (c) 2021 - present - Yupiik SAS - https://www.yupiik.com
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

apiVersion: v1
kind: Service
metadata:
name: kafka
labels:
app: kafka-local
spec:
type: NodePort
ports:
- port: 9092
targetPort: 9092
name: kafka-internal
- port: 9093
targetPort: 9093
name: kafka-external
selector:
app: kafka-local
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Copyright (c) 2021 - present - Yupiik SAS - https://www.yupiik.com
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka-local
labels:
app: kafka-local
spec:
serviceName: "kafka-local"
replicas: 1
selector:
matchLabels:
app: kafka-local
template:
metadata:
labels:
app: kafka-local
spec:
initContainers:
- name: chmod-kafka-data-folder-workaround
image: alpine:latest
command:
- chown
- -R
- 1000:1000
- /usr/share/kafka/data
volumeMounts:
- name: pv-data
mountPath: /usr/share/kafka/data
containers:
- name: kafka
image: "{{kafka-local.image:-apache/kafka:3.8.0}}"
envFrom:
- configMapRef:
name: kafka-local-config
ports:
- containerPort: 9092
name: kafka
volumeMounts:
- name: pv-data
mountPath: /usr/share/kafka/data
volumes:
- name: pv-data
persistentVolumeClaim:
claimName: kafka-pv-claim
47 changes: 47 additions & 0 deletions alveolus/kafka-local/src/main/resources/bundlebee/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"alveoli": [
{
"//": "Setup \"${project.artifactId}\" which runs an Apache Kafka instance usable by other applications.",
"name": "${project.groupId}:${project.artifactId}:${project.version}",
"descriptors": [
{
"name": "${project.groupId}_${project.artifactId}.configmap",
"interpolate": true
},
{
"name": "${project.groupId}_${project.artifactId}.persistencevolume",
"interpolate": true
},
{
"name": "${project.groupId}_${project.artifactId}.persistencevolumeclaim",
"interpolate": true
},
{
"name": "${project.groupId}_${project.artifactId}.service"
},
{
"name": "${project.groupId}_${project.artifactId}.statefulset",
"interpolate": true
}
],
"placeholdersDoc": [
{
"name": "kafka-local.image",
"description": "The Apache Kafka image to use."
},
{
"name": "kafka-local.brokerId",
"description": "The Apache Kafka broker id."
},
{
"name": "kafka-local.javaOpts",
"description": "The JAVA_OPTS value."
},
{
"name": "kafka-local.mountPath",
"description": "Where to store Apache Kafka data on the host."
}
]
}
]
}
1 change: 1 addition & 0 deletions alveolus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<module>grafana-simple</module>
<module>monitoring-alveolus</module>
<module>minio-local</module>
<module>kafka-local</module>
</modules>

<build>
Expand Down
5 changes: 5 additions & 0 deletions bundlebee-documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
<artifactId>minio-local</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}.alveoli</groupId>
<artifactId>kafka-local</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down

0 comments on commit e35b1f2

Please sign in to comment.