Skip to content

Latest commit

 

History

History
167 lines (140 loc) · 4.07 KB

README.md

File metadata and controls

167 lines (140 loc) · 4.07 KB

Bookinfo

Rewrite Bookinfo project using hertz, kitex

Architecture

img.png

Lane

lane.png

QuickStart

Prerequisites

Kubernetes cluster

If you don't have an existing K8S cluster, you can use minikube to quickly launch one

  1. install minikube
  2. minikube start

Istio

Refer to the doc of Istio to deploy a set of istio to the K8S cluster

Helm

Refer to the doc of Helm to install the helm command-line tool

OpenTelemetry

install opentelemetry operator
helm install --set admissionWebhooks.certManager.enabled=false \
  opentelemetry-operator open-telemetry/opentelemetry-operator
deploy opentelemetry collector

We are here just for demo, so we will only export spans and metrics to the log. For the production environment, set up your opentelemetry-collector as needed

kubectl apply -f - <<EOF
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: bookinfo-demo
spec:
  mode: statefulset
  replicas: 3
  config: |
    receivers:
      otlp:
        protocols:
          grpc:
    processors:

    exporters:
      logging:

    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: []
          exporters: [logging]
        metrics:
          receivers: [otlp]
          processors: []
          exporters: [logging]          
EOF

Deploy Bookinfo Application

helm install bookinfo ./manifest/bookinfo/workloads

After successful deploy, you can see that the pods are running:

img.png

Expose Bookinfo by Istio Ingress Gateway

kubectl apply -f bookinfo/manifest/bookinfo/traffic/bookinfo-gateway.yaml

Use the minikube tunnel feature to assign LB IPs to istio ingress:

minikube tunnel

Then you can request the address on the command line

curl http://localhost/api/v1/products/1

You see the following output, indicating that the deployment was successful!

{"ID":"1","Title":"《Also sprach Zarathustra》","Author":"Friedrich Nietzsche","Description":"Thus Spoke Zarathustra: A Book for All and None, also translated as Thus Spake Zarathustra, is a work of philosophical fiction written by German philosopher Friedrich Nietzsche between 1883 and 1885.","Rating":0}

Traffic routing example

Define routing rules

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reviews
spec:
  hosts:
    - reviews
  http:
    - match:
        - headers:
            baggage:
              exact: "env=dev"
      route:
        - destination:
            host: reviews
            subset: v2
          weight: 100
    - route:
        - destination:
            host: reviews
            subset: v1
          weight: 80
        - destination:
            host: reviews
            subset: v3
          weight: 20

---

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ratings
spec:
  hosts:
    - ratings
  http:
    - match:
        - headers:
            baggage:
              exact: "env=dev"
      route:
        - destination:
            host: ratings
            subset: v2
          weight: 100
    - route:
        - destination:
            host: ratings
            subset: v1
          weight: 100

Request base lane service, rating 0 or 1 randomly

bookinfo_1.png bookinfo_2.png

Set the request coloring flag through the browser mod-header plugin

bookinfo_3.png

Click the refresh button again, you can find that the request hits the branch lane, and the rating becomes 5

bookinfo_4.png

View Tracing

tracing-topo tracing

View Topology

operation-topo