Rewrite Bookinfo project using
hertz
,kitex
If you don't have an existing K8S cluster, you can use minikube to quickly launch one
- install minikube
minikube start
Refer to the doc of Istio to deploy a set of istio to the K8S cluster
Refer to the doc of Helm to install the helm command-line tool
helm install --set admissionWebhooks.certManager.enabled=false \
opentelemetry-operator open-telemetry/opentelemetry-operator
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
helm install bookinfo ./manifest/bookinfo/workloads
After successful deploy, you can see that the pods are running:
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}
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