一、kafka
apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: dev-message-router-kafka namespace: onap labels: app: message-router-kafka chart: message-router-kafka-2.0.0 release: dev heritage: Tillerspec: replicas: 1 template: metadata: labels: app: message-router-kafka release: dev spec: initContainers: - name: message-router-kafka-seed-kafka-topics command: - /bin/bash - -c - > if [ -d /tmp/topics/ECOMP-PORTAL-INBOX-0 ]; then echo "nothing to do"; else git clone -b 2.0.0-ONAP --single-branch http://gerrit.onap.org/r/dmaap/messagerouter/messageservice.git /tmp/gerrit; echo "Clone complete. Copying from /tmp/gerrit/oom-projects/data-kafka/kafka-logs/* to /tmp/topics"; cp -var /tmp/gerrit/oom-topics/data-kafka/kafka-logs/* /tmp/topics; echo "Done."; fi image: "registry.hub.docker.com/oomk8s/ubuntu-init:2.0.0" imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /tmp/topics name: kafka-data - command: - /root/ready.py args: - --container-name - message-router-zookeeper env: - name: NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace image: "oomk8s/readiness-check:2.0.0" imagePullPolicy: IfNotPresent name: message-router-kafka-readiness containers: - name: message-router-kafka image: "docker.io/wurstmeister/kafka:1.1.0" imagePullPolicy: IfNotPresent ports: - containerPort: 9092 livenessProbe: tcpSocket: port: 9092 initialDelaySeconds: 10 periodSeconds: 10 readinessProbe: tcpSocket: port: 9092 initialDelaySeconds: 10 periodSeconds: 10 env: - name: KAFKA_ZOOKEEPER_CONNECT value: "message-router-zookeeper:2181" - name: KAFKA_ADVERTISED_HOST_NAME value: "message-router-kafka" - name: KAFKA_BROKER_ID value: "0" - name: KAFKA_ADVERTISED_LISTENERS value: PLAINTEXT://message-router-kafka:9092 - name: KAFKA_ADVERTISED_PORT value: "9092" - name: KAFKA_PORT value: "9092" volumeMounts: - mountPath: /etc/localtime name: localtime readOnly: true - mountPath: /var/run/docker.sock name: docker-socket - mountPath: /kafka name: kafka-data volumes: - name: localtime hostPath: path: /etc/localtime - name: docker-socket hostPath: path: /var/run/docker.sock - name: kafka-data persistentVolumeClaim: claimName: dev-message-router-kafka imagePullSecrets: - name: "onap-docker-registry-key"
二、zookeeper
apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: dev-message-router-zookeeper namespace: onap labels: app: message-router-zookeeper chart: message-router-zookeeper-2.0.0 release: dev heritage: Tillerspec: replicas: 1 template: metadata: labels: app: message-router-zookeeper release: dev spec: initContainers: - name: message-router-zookeeper-seed-zookeeper-topics command: - /bin/bash - -c - > if [ -d /tmp/topics/version-2 ]; then echo "nothing to do"; else git clone -b 2.0.0-ONAP --single-branch http://gerrit.onap.org/r/dmaap/messagerouter/messageservice.git /tmp/gerrit; echo "Clone complete. Copying from /tmp/gerrit/oom-projects/data-zookeeper/* to /tmp/topics"; cp -var /tmp/gerrit/oom-topics/data-zookeeper/* /tmp/topics; echo "Done."; fi image: "registry.hub.docker.com/oomk8s/ubuntu-init:2.0.0" imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /tmp/topics name: zookeeper-data containers: - name: message-router-zookeeper image: "docker.io/wurstmeister/zookeeper:latest" imagePullPolicy: IfNotPresent ports: - containerPort: 2181 livenessProbe: tcpSocket: port: 2181 initialDelaySeconds: 10 periodSeconds: 10 readinessProbe: tcpSocket: port: 2181 initialDelaySeconds: 10 periodSeconds: 10 volumeMounts: - mountPath: /etc/localtime name: localtime readOnly: true - mountPath: /opt/zookeeper-3.4.9/data name: zookeeper-data volumes: - name: localtime hostPath: path: /etc/localtime - name: zookeeper-data persistentVolumeClaim: claimName: dev-message-router-zookeeper imagePullSecrets: - name: "onap-docker-registry-key"
三、启动docker脚本
docker run -d -p 2181:2181 --name message-router-zookeeper docker.io/wurstmeister/zookeeper:latestdocker run -d -p 9092:9092 --name message-router-kafka -e KAFKA_ZOOKEEPER_CONNECT=172.17.0.25:2181 -e KAFKA_ADVERTISED_HOST_NAME=message-router-kafka -e KAFKA_BROKER_ID=0 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://10.109.30.170:9092 -e KAFKA_ADVERTISED_PORT=9092 -e KAFKA_PORT=9092 docker.io/wurstmeister/kafka:1.1.0