From 2a02b848ff180d17139a9da379ecce1cc0368435 Mon Sep 17 00:00:00 2001 From: zetaloop Date: Wed, 6 May 2026 11:03:23 +0800 Subject: [PATCH] feat(k01): replace strimzi kafka with redpanda --- deploy/k01/apply-infra.sh | 2 +- deploy/k01/infra/kafka.yaml | 163 +++++++++++++++------------------ deploy/k01/install.sh | 21 +++-- deploy/k01/services/email.yaml | 4 +- deploy/k01/teardown.sh | 10 +- 5 files changed, 92 insertions(+), 108 deletions(-) diff --git a/deploy/k01/apply-infra.sh b/deploy/k01/apply-infra.sh index 333d841..a38e80d 100755 --- a/deploy/k01/apply-infra.sh +++ b/deploy/k01/apply-infra.sh @@ -47,6 +47,6 @@ kubectl -n juwan wait --for=jsonpath='{.status.phase}'=Running mongodbcommunity/ echo kafka kubectl apply -f "${INFRA_DIR}/kafka.yaml" -kubectl -n kafka wait --for=condition=Ready kafka/juwan-kafka --timeout=900s || true +kubectl -n redpanda wait --for=condition=Ready redpanda/juwan-kafka --timeout=900s || true kubectl get pods -A diff --git a/deploy/k01/infra/kafka.yaml b/deploy/k01/infra/kafka.yaml index af1946d..416bbe7 100644 --- a/deploy/k01/infra/kafka.yaml +++ b/deploy/k01/infra/kafka.yaml @@ -1,102 +1,83 @@ -apiVersion: kafka.strimzi.io/v1 -kind: KafkaNodePool -metadata: - name: controller - namespace: kafka - labels: - strimzi.io/cluster: juwan-kafka -spec: - replicas: 1 - roles: - - controller - storage: - type: persistent-claim - size: 1Gi - deleteClaim: false - resources: - requests: - cpu: 30m - memory: 200Mi - limits: - memory: 400Mi - jvmOptions: - -Xms: "128M" - -Xmx: "320M" - ---- -apiVersion: kafka.strimzi.io/v1 -kind: KafkaNodePool -metadata: - name: broker - namespace: kafka - labels: - strimzi.io/cluster: juwan-kafka -spec: - replicas: 1 - roles: - - broker - storage: - type: persistent-claim - size: 5Gi - deleteClaim: false - resources: - requests: - cpu: 50m - memory: 350Mi - limits: - memory: 600Mi - jvmOptions: - -Xms: "192M" - -Xmx: "512M" - ---- -apiVersion: kafka.strimzi.io/v1 -kind: Kafka +apiVersion: cluster.redpanda.com/v1alpha2 +kind: Redpanda metadata: name: juwan-kafka - namespace: kafka - annotations: - strimzi.io/node-pools: enabled - strimzi.io/kraft: enabled + namespace: redpanda spec: - kafka: - version: 4.2.0 - metadataVersion: 4.2-IV0 + chartRef: + chartName: redpanda + chartVersion: 26.1.3 + helmRepositoryName: redpanda + clusterSpec: + image: + tag: v26.1.6 + fullnameOverride: juwan-kafka + console: + enabled: false + external: + enabled: false + service: + enabled: false + auth: + sasl: + enabled: false + tls: + enabled: false listeners: - - name: plain + kafka: port: 9092 - type: internal - tls: false - config: - offsets.topic.replication.factor: 1 - transaction.state.log.replication.factor: 1 - transaction.state.log.min.isr: 1 - default.replication.factor: 1 - min.insync.replicas: 1 - entityOperator: - topicOperator: - resources: - requests: - cpu: 15m - memory: 130Mi - limits: - memory: 250Mi - userOperator: - resources: - requests: - cpu: 15m - memory: 130Mi - limits: - memory: 250Mi + authenticationMethod: null + tls: + enabled: false + admin: + tls: + enabled: false + rpc: + tls: + enabled: false + http: + enabled: false + schemaRegistry: + enabled: false + storage: + persistentVolume: + enabled: true + size: 5Gi + storageClass: local-path + resources: + requests: + cpu: 50m + memory: 200Mi + limits: + cpu: 500m + memory: 500Mi + statefulset: + replicas: 1 + additionalRedpandaCmdFlags: + - --overprovisioned + - --smp=1 + - --memory=350M + - --reserve-memory=0M + podTemplate: + spec: + affinity: + podAntiAffinity: null + tuning: + tune_aio_events: false + logging: + logLevel: info + usageStats: + enabled: false --- -apiVersion: kafka.strimzi.io/v1 -kind: KafkaTopic +apiVersion: cluster.redpanda.com/v1alpha2 +kind: Topic metadata: name: email-task - namespace: kafka - labels: - strimzi.io/cluster: juwan-kafka + namespace: redpanda spec: partitions: 1 - replicas: 1 + replicationFactor: 1 + cluster: + clusterRef: + name: juwan-kafka diff --git a/deploy/k01/install.sh b/deploy/k01/install.sh index 01eaee3..ba71f27 100755 --- a/deploy/k01/install.sh +++ b/deploy/k01/install.sh @@ -3,7 +3,7 @@ set -euo pipefail REGISTRY_HOST="registry.juwan.xhttp.zip" CNPG_VERSION="1.29.0" -STRIMZI_VERSION="1.0.0" +REDPANDA_OP_VERSION="v26.1.3" REDIS_OP_VERSION="0.24.0" MONGODB_OP_VERSION="1.8.0" @@ -82,17 +82,22 @@ kubectl apply --server-side --force-conflicts -f \ kubectl -n cnpg-system set resources deploy/cnpg-controller-manager \ --requests=cpu=30m,memory=40Mi --limits=cpu=200m,memory=200Mi -kubectl create namespace kafka 2>/dev/null || true -curl -sfL "https://github.com/strimzi/strimzi-kafka-operator/releases/download/${STRIMZI_VERSION}/strimzi-cluster-operator-${STRIMZI_VERSION}.yaml" \ - | sed 's/namespace: .*/namespace: kafka/' \ - | kubectl apply --server-side --force-conflicts -n kafka -f - -kubectl -n kafka set resources deploy/strimzi-cluster-operator \ - --requests=cpu=50m,memory=200Mi --limits=cpu=500m,memory=400Mi +kubectl create namespace redpanda 2>/dev/null || true helm repo add ot-helm https://ot-container-kit.github.io/helm-charts/ 2>/dev/null || true helm repo add mongodb https://mongodb.github.io/helm-charts 2>/dev/null || true +helm repo add redpanda https://charts.redpanda.com 2>/dev/null || true helm repo update +helm upgrade --install redpanda-controller redpanda/operator \ + --version "${REDPANDA_OP_VERSION}" \ + --namespace redpanda \ + --set crds.enabled=true \ + --set resources.requests.cpu=30m \ + --set resources.requests.memory=50Mi \ + --set resources.limits.cpu=100m \ + --set resources.limits.memory=128Mi + helm upgrade --install redis-operator ot-helm/redis-operator \ --version "${REDIS_OP_VERSION}" \ --namespace redis-operator --create-namespace \ @@ -111,7 +116,7 @@ helm upgrade --install mongodb-kubernetes mongodb/mongodb-kubernetes \ --set operator.resources.limits.memory=200Mi kubectl -n cnpg-system rollout status deploy/cnpg-controller-manager --timeout=300s -kubectl -n kafka rollout status deploy/strimzi-cluster-operator --timeout=300s +kubectl -n redpanda rollout status deploy/redpanda-controller --timeout=300s kubectl -n redis-operator rollout status deploy/redis-operator --timeout=300s kubectl -n mongodb-operator rollout status deploy/mongodb-kubernetes-operator --timeout=300s diff --git a/deploy/k01/services/email.yaml b/deploy/k01/services/email.yaml index b1168a0..f78326c 100644 --- a/deploy/k01/services/email.yaml +++ b/deploy/k01/services/email.yaml @@ -36,7 +36,7 @@ spec: name: user-redis key: password - name: KAFKA_BROKER - value: "juwan-kafka-kafka-bootstrap.kafka:9092" + value: "juwan-kafka-0.juwan-kafka.redpanda:9092" resources: requests: cpu: 10m @@ -89,7 +89,7 @@ spec: containerPort: 4001 env: - name: KAFKA_BROKER - value: "juwan-kafka-kafka-bootstrap.kafka:9092" + value: "juwan-kafka-0.juwan-kafka.redpanda:9092" - name: EMAIL_SMTP_HOST valueFrom: secretKeyRef: diff --git a/deploy/k01/teardown.sh b/deploy/k01/teardown.sh index 19503be..241243b 100755 --- a/deploy/k01/teardown.sh +++ b/deploy/k01/teardown.sh @@ -14,9 +14,8 @@ kubectl -n juwan delete cluster.postgresql.cnpg.io --all --wait=false 2>/dev/nul kubectl -n juwan delete redisreplication --all --wait=false 2>/dev/null || true kubectl -n juwan delete redissentinel --all --wait=false 2>/dev/null || true kubectl -n juwan delete mongodbcommunity --all --wait=false 2>/dev/null || true -kubectl -n kafka delete kafkatopic --all --wait=false 2>/dev/null || true -kubectl -n kafka delete kafka --all --wait=false 2>/dev/null || true -kubectl -n kafka delete kafkanodepool --all --wait=false 2>/dev/null || true +kubectl -n redpanda delete topic --all --wait=false 2>/dev/null || true +kubectl -n redpanda delete redpanda --all --wait=false 2>/dev/null || true echo network kubectl delete -f "${K01_DIR}/infra/envoy.yaml" --ignore-not-found --wait=false @@ -27,9 +26,8 @@ sleep 30 echo cleanup orphaned kubectl -n juwan delete pod --all --force --grace-period=0 2>/dev/null || true kubectl -n juwan delete pvc --all --wait=false 2>/dev/null || true -kubectl -n kafka delete pod -l strimzi.io/cluster=juwan-kafka --force --grace-period=0 2>/dev/null || true -kubectl -n kafka delete pvc -l strimzi.io/cluster=juwan-kafka --wait=false 2>/dev/null || true +kubectl -n redpanda delete pvc -l app.kubernetes.io/instance=juwan-kafka --wait=false 2>/dev/null || true kubectl get pods,pvc -n juwan -kubectl get pods,pvc -n kafka +kubectl get pods,pvc -n redpanda kubectl describe node | grep -A 6 Allocated