k8s部署zipkin

k8s部署zipkin

Scroll Down

创建命名空间

kubectl create ns zipkin

在RDS中新建数据库

RDS:rm-bp166jsyfxwlly26g

数据库初始化语句

CREATE TABLE IF NOT EXISTS zipkin_spans (
   `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
   `trace_id` BIGINT NOT NULL,
   `id` BIGINT NOT NULL,
   `name` VARCHAR(255) NOT NULL,
   `remote_service_name` VARCHAR(255),
   `parent_id` BIGINT,
   `debug` BIT(1),
   `start_ts` BIGINT COMMENT 'Span.timestamp(): epoch micros used for endTs query and to implement TTL',
   `duration` BIGINT COMMENT 'Span.duration(): micros used for minDuration and maxDuration query',
   PRIMARY KEY (`trace_id_high`, `trace_id`, `id`)
  ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED CHARACTER SET=utf8 COLLATE utf8_general_ci;
   
  ALTER TABLE zipkin_spans ADD INDEX(`trace_id_high`, `trace_id`) COMMENT 'for getTracesByIds';
  ALTER TABLE zipkin_spans ADD INDEX(`name`) COMMENT 'for getTraces and getSpanNames';
  ALTER TABLE zipkin_spans ADD INDEX(`remote_service_name`) COMMENT 'for getTraces and getRemoteServiceNames';
  ALTER TABLE zipkin_spans ADD INDEX(`start_ts`) COMMENT 'for getTraces ordering and range';
   
  CREATE TABLE IF NOT EXISTS zipkin_annotations (
   `trace_id_high` BIGINT NOT NULL DEFAULT 0 COMMENT 'If non zero, this means the trace uses 128 bit traceIds instead of 64 bit',
   `trace_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.trace_id',
   `span_id` BIGINT NOT NULL COMMENT 'coincides with zipkin_spans.id',
   `a_key` V

部署zipkin

# cat zipkin-deploy.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: zipkin
  name: zipkin
  namespace: zipkin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: zipkin
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: zipkin
    spec:
      containers:
      - env:
        - name: STORAGE_TYPE
          value: mysql
        - name: MYSQL_DB
          value: zipkin
        - name: MYSQL_USER
          value: mysqlforzipkin
        - name: MYSQL_PASS
          value: password
        - name: MYSQL_HOST
          value: ********************
        - name: MYSQL_TCP_PORT
          value: "3306"
        image: openzipkin/zipkin
        imagePullPolicy: IfNotPresent
        name: zipkin
        ports:
        - containerPort: 9411
          name: http
          protocol: TCP
# cat zipkin-svc.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    app: zipkin
  name: zipkin-svc
  namespace: zipkin
spec:
  ports:
  - name: http
    nodePort: 31640
    port: 9411
    protocol: TCP
    targetPort: 9411
  selector:
    app: zipkin
  sessionAffinity: None
  type: NodePort

访问地址

http://IP:31640