[Zipkin] 将数据持久化到elasticsearch,并在istio-k8s中运行

zipkin自带支持elasticsearch数据库,所以只要修改两个环境变量STORAGE_TYPEES_HOSTS就好了;

但是只运行zipkin会发现没法看到依赖图,elasticsearch里面也只有span的信息,没有dependencies的数据,还需要运行zipkin-dependencies镜像:

--- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: zipkin
  namespace: istio-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: zipkin
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      containers:
      - name: zipkin         image: docker.io/openzipkin/zipkin:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9411         env:
        - name: STORAGE_TYPE           value: elasticsearch
        - name: ES_HOSTS           value: elasticsearch.logging:9200
        - name: POD_NAMESPACE           valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace

--- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: zipkin-dependencies
  namespace: istio-system
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: zipkin-dependencies
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      containers:
      - name: zipkin         image: openzipkin/zipkin-dependencies:1.9.2
        imagePullPolicy: IfNotPresent
        env:
        - name: STORAGE_TYPE           value: elasticsearch
        - name: ES_HOSTS           value: elasticsearch.logging:9200
        - name: ES_INDEX           value: zipkin
        - name: POD_NAMESPACE           valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
--- apiVersion: v1
kind: List
items:
- apiVersion: v1   kind: Service
  metadata:
    name: zipkin
    namespace: istio-system
  spec:
    type: NodePort
    ports:
    - name: http       port: 9411
      nodePort: 30005
    selector:
      app: zipkin
- apiVersion: v1   kind: Service
  metadata:
    name: zipkin-dependencies
    namespace: istio-system
  spec:
    ports:
    - name: http       port: 9412
    selector:
      app: zipkin-dependencies
--- 

* 另外,发现如果不加zipkin-dependencies的service(因为感觉它并不对外提供port访问,所以一开始没加spec.ports,但是部署时提示service必须明确spec.ports才能创建,所以我把service删了),zipkin-dependencies的pod运行会报错,我也不知道为什么,所以就随便指定了一个9412的端口给它,运行成功后发现它其实在不停重启?貌似是隔一段时间分析一下依赖,然后把依赖关系发到elasticsearch然后就completed了?有哪位旁友弄懂了这个zipkin-dependencies是怎么运行的,务必留言解答一下!

最后的elasticsearch会多出两个index:zipkin-spanzipkin-dependencies
[Zipkin] 将数据持久化到elasticsearch,并在istio-k8s中运行_第1张图片

你可能感兴趣的:(微服务)