k8s部署kafka
k8s部署kafka
·
---
apiVersion: v1
kind: Service
metadata:
name: kafka-headless
namespace: arts-system
spec:
ports:
- name: client
port: 9092
protocol: TCP
targetPort: 9092
nodePort: 30092
- name: api
port: 9093
protocol: TCP
targetPort: 9093
nodePort: 30093
type: NodePort
selector:
app: kafka
#type: ClusterIP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka
namespace: arts-system
spec:
podManagementPolicy: OrderedReady
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: kafka
serviceName: kafka-headless
template:
metadata:
labels:
app: kafka
spec:
containers:
- env:
- name: KAFKA_ENABLE_KRAFT
value: 'yes'
- name: KAFKA_CFG_PROCESS_ROLES
value: broker,controller
- name: KAFKA_CFG_CONTROLLER_LISTENER_NAMES
value: CONTROLLER
- name: KAFKA_CFG_LISTENERS
value: PLAINTEXT://:9092,CONTROLLER://:9093
- name: KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP
value: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
- name: KAFKA_KRAFT_CLUSTER_ID
value: LelM2dIFQkiUFvXCEcqRWA
- name: KAFKA_CFG_CONTROLLER_QUORUM_VOTERS
value: 1@kafka-headless.arts-system:9093
- name: ALLOW_PLAINTEXT_LISTENER
value: 'yes'
- name: KAFKA_HEAP_OPTS
value: '-Xmx512M -Xms256M'
- name: KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE
value: 'true'
- name: KAFKA_CFG_ADVERTISED_LISTENERS
#value: PLAINTEXT://101.35.51.132:30092
value: PLAINTEXT://192.168.73.100:30092 #需要填写实际IP,才能远程连接
- name: KAFKA_BROKER_ID
value: '1'
- name: KAFKA_KRAFT_MODE
value: 'true'
- name: POD_INDEX
valueFrom:
fieldRef:
fieldPath: metadata.name
image: bitnami/kafka:3.3.1
imagePullPolicy: IfNotPresent
name: kafka
ports:
- containerPort: 9092
name: client
protocol: TCP
- containerPort: 9093
name: api
protocol: TCP
resources: {}
volumeMounts:
- name: kafka-data
mountPath: /bitnami/kafka
subPath: "artsdata/kafka/"
#subPathExpr: "artsdata/kafka/kafka-$(POD_INDEX)"
volumes:
- name: kafka-data
persistentVolumeClaim:
#claimName: arts-pvc
claimName: arts-pvc
restartPolicy: Always
更多推荐
已为社区贡献25条内容
所有评论(0)