Kubernetes kafka

deplopyment

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kafka-deployment
labels:
app: kafka-deployment
spec:
replicas: 1
selector:
matchLabels:
app: kafka-deployment
template:
metadata:
labels:
app: kafka-deployment
spec:
containers:
- image: wurstmeister/kafka
imagePullPolicy: IfNotPresent
name: kafka-deployment
ports:
- containerPort: 9092
- containerPort: 30092
env:
- name: KAFKA_ADVERTISED_HOST_NAME
value: "35.198.224.244"
- name: KAFKA_ADVERTISED_PORT
value: "9092"
- name: KAFKA_BROKER_ID
value: "1"
- name: KAFKA_ZOOKEEPER_CONNECT
value: 10.47.250.170:2181
- name: KAFKA_CREATE_TOPICS
value: "ethex:1:1"

注意:KAFKA_ADVERTISED_HOST_NAME 填ServiceIP

Service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
apiVersion: v1
kind: Service
metadata:
labels:
app: kafka-service
name: kafka-service
spec:
type: LoadBalancer
ports:
- name: kafka-port
port: 9092
targetPort: 9092
selector:
app: kafka-deployment