Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kafka resources for ephemeral usage #1207

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion deploy/debezium-connector.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: kafka-connectors
Expand All @@ -7,6 +7,8 @@ objects:
kind: KafkaConnector
metadata:
name: ${CONNECTOR_NAME}
annotations:
strimzi.io/use-connector-resources: "true"
labels:
strimzi.io/cluster: ${KAFKA_CONNECT_INSTANCE}
spec:
Expand All @@ -21,6 +23,7 @@ objects:
database.password: ${DB_PASSWORD}
topic.prefix: ${TOPIC_PREFIX}
table.whitelist: ${TABLE_LIST}
table.include.list: ${TABLE_LIST}
transforms: outbox
transforms.outbox.type: io.debezium.transforms.outbox.EventRouter
transforms.outbox.table.field.payload: ${PAYLOAD_NAME}
Expand Down
134 changes: 134 additions & 0 deletions deploy/kafka-connect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: kafka-template
objects:
- apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
name: rbac-kafka
spec:
entityOperator:
template:
pod:
metadata:
labels:
service: strimziKafka
topicOperatorContainer:
env:
- name: STRIMZI_USE_FINALIZERS
value: 'false'
tlsSidecar:
resources:
limits:
cpu: 100m
memory: 100Mi
requests:
cpu: 50m
memory: 50Mi
topicOperator:
resources:
limits:
cpu: 200m
memory: 500Mi
requests:
cpu: 50m
memory: 250Mi
userOperator:
resources:
limits:
cpu: 400m
memory: 500Mi
requests:
cpu: 50m
memory: 250Mi
kafka:
config:
offsets.topic.replication.factor: '1'
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 600Mi
version: 3.7.0
template:
perPodService:
metadata:
labels:
service: strimziKafka
pod:
metadata:
labels:
service: strimziKafka
storage:
type: ephemeral
replicas: 1
jvmOptions: {}
listeners:
- name: tcp
port: 9092
tls: false
type: internal
zookeeper:
replicas: 1
resources:
limits:
cpu: 350m
memory: 800Mi
requests:
cpu: 200m
memory: 400Mi
storage:
type: ephemeral
template:
nodesService:
metadata:
labels:
service: strimziKafka
pod:
metadata:
labels:
service: strimziKafka

- apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaConnect
metadata:
name: rbac-kafka-connect
annotations:
strimzi.io/use-connector-resources: "true"
# annotations:
# # use-connector-resources configures this KafkaConnect
# # to use KafkaConnector resources to avoid
# # needing to call the Connect REST API directly
# strimzi.io/use-connector-resources: "true"
spec:
template:
pod:
imagePullSecrets:
- name: quay-cloudservices-pull
- name: rh-registry-pull
- name: quay.io
image: quay.io/cloudservices/kafka-connect@sha256:57decfca1b637ecaffeb13ff61309c6578791ae93b0da5ba9b051878928762ac
version: 3.7.0
replicas: 1
bootstrapServers: rbac-kafka-kafka-bootstrap:9092
resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 250m
memory: 512Mi
config:
config.providers: secrets
config.providers.secrets.class: io.strimzi.kafka.KubernetesSecretConfigProvider
group.id: rbac-kafka-connect-cluster
offset.storage.topic: rbac-kafka-connect-cluster-offsets
config.storage.topic: rbac-kafka-connect-cluster-configs
status.storage.topic: rbac-kafka-connect-cluster-status
# -1 means it will use the default replication factor configured in the broker
config.storage.replication.factor: '1'
offset.storage.replication.factor: '1'
status.storage.replication.factor: '1'
9 changes: 9 additions & 0 deletions scripts/connector-params.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DB_SERVERNAME=rbac-db
DB_NAME=${secrets:rbac-db:db.name}
DB_HOSTNAME=${secrets:rbac-db:db.host}
DB_PORT=${secrets:rbac-db:db.port}
DB_USER=${secrets:rbac-db:db.user}
DB_PASSWORD=${secrets:rbac-db:db.password}
TOPIC_PREFIX=rbac
CONNECTOR_NAME=rbac-connector
KAFKA_CONNECT_INSTANCE=rbac-kafka-connect
43 changes: 43 additions & 0 deletions scripts/kafka.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Function to display usage
usage() {
echo "Usage: $0 -n <NAMESPACE> | --namespace <NAMESPACE>"
exit 1
}

# Check if no arguments are provided
if [ $# -eq 0 ]; then
usage
fi

# Parse command-line arguments
while [[ "$1" =~ ^- ]]; do
case "$1" in
-n|--namespace)
shift
if [[ -n "$1" ]]; then
NAMESPACE="$1"
else
echo "Error: Argument for $1 is missing."
usage
fi
shift
;;
*)
echo "Unknown option: $1"
usage
;;
esac
done

# Check if the NAMESPACE variable is set
if [ -z "$NAMESPACE" ]; then
echo "Error: NAMESPACE is required."
usage
fi

# Example operation using the NAMESPACE
echo "The provided namespace is: $NAMESPACE"
oc process -f ../deploy/kafka-connect.yml --namespace=$NAMESPACE | oc apply --namespace=$NAMESPACE -f -
oc process -f ../deploy/debezium-connector.yml --param-file=connector-params.env --namespace=$NAMESPACE | oc apply --namespace=$NAMESPACE -f -