在OpenShift 4中Red Hat将Istio,Jaeger,Kiali和3scale Istio Adapter集成在Openshift Service Mesh环境中。在OpenShift 4中借助Operator可以通过非常简单的过程创建一套Service Mesh的运行环境,并在此之上部署运行Istio微服务,并使用Kiali监控微服务网格的运行。
以下操作需要OpenShift 4.2运行环境(OpenShift 4.1或更高版本应该也可以)。
Red Hat OpenShift Service Mesh会用到Kiali Operator、Jaeger Operator。在OpenShift 4.2中无需单独安装Kiali Operator、Jaeger Operator步骤,Service Mesh可自动安装这两个Operator。
上一步是安装Operator,本步骤是基于Service Mesh Operator创建Istio的运行环境。
$ oc new-project istio-system
$ oc get pod -n istio-system
NAME READY STATUS RESTARTS AGE
grafana-b67df64b6-6m254 2/2 Running 0 118m
istio-citadel-79979464d-n8bbs 1/1 Running 0 146m
istio-egressgateway-7d897695c4-6rwpc 1/1 Running 0 119m
istio-galley-6bb46858c5-zn2b9 1/1 Running 0 142m
istio-ingressgateway-8465bbf788-q286r 1/1 Running 0 119m
istio-pilot-54b65495c4-fhzxt 2/2 Running 0 120m
istio-policy-5fc74b8697-n625g 2/2 Running 0 140m
istio-sidecar-injector-65cd4c8c6f-dd7bs 1/1 Running 0 119m
istio-telemetry-69cb778b9-pzsl8 2/2 Running 0 140m
jaeger-57776787bc-dcf9k 2/2 Running 0 142m
kiali-6d6f9cf658-l9n9p 1/1 Running 0 105m
prometheus-b8bdc6b77-jt969 2/2 Running 0 144m
$ oc get route -n istio-system
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
grafana grafana-istio-system.apps-crc.testing grafana <all> reencrypt None
istio-ingressgateway istio-ingressgateway-istio-system.apps-crc.testing istio-ingressgateway 8080 None
jaeger jaeger-istio-system.apps-crc.testing jaeger-query <all> reencrypt None
kiali kiali-istio-system.apps-crc.testing kiali <all> reencrypt None
prometheus prometheus-istio-system.apps-crc.testing prometheus <all> reencrypt None
apiVersion: maistra.io/v1
kind: ServiceMeshMemberRoll
metadata:
name: default
spec:
members:
- istio-tutorial
$ oc new-project istio-tutorial
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/catalog/kubernetes/catalog-service-template.yml
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/partner/kubernetes/partner-service-template.yml
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/gateway/kubernetes/gateway-service-template.yml
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/catalog/kubernetes/Service.yml
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/partner/kubernetes/Service.yml
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/gateway/kubernetes/Service.yml
$ oc get pod -n istio-tutorial
NAME READY STATUS RESTARTS AGE
catalog-v1-6b576ffcf8-g6b48 2/2 Running 0 1m
partner-v1-68b4854c79-s5vnd 2/2 Running 0 2m
gateway-7b6bb9dcf7-zb8br 2/2 Running 0 1m
$ oc apply -f https://raw.githubusercontent.com/liuxiaoyu-git/OpenShift-HOL/master/service-mesh-gw.yaml -n istio-tutorial
$ oc -n istio-system get route istio-ingressgateway -o jsonpath='{.spec.host}'
$ curl GATEWAY_URL
gateway => partner => catalog v1 from '6b576ffcf8-g6b48': 1
$ while true; do curl GATEWAY_URL; sleep 1;done
$ oc get route kiali -n istio-system -o template --template='{{.spec.host}}'
部署v2版的catalog微服务,然后配置Gateway引流,将请求发给v1和v2。
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/catalog-v2/kubernetes/catalog-service-template.yml
$ oc get pod -l application=catalog -w
NAME READY STATUS RESTARTS AGE
catalog-v1-6b576ffcf8-g6b48 2/2 Running 0 31m
catalog-v2-7764964564-hj8xl 2/2 Running 0 49s
$ while true; do curl GATEWAY_URL; sleep 1; done
$ oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/istiofiles/destination-rule-catalog-v1-v2.yml
oc create -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/istiofiles/virtual-service-catalog-v2.yml
$ oc replace -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/istiofiles/virtual-service-catalog-v1.yml
$ oc delete VirtualService catalog
$ oc replace -f https://raw.githubusercontent.com/gpe-mw-training/ocp-service-mesh-foundations/master/istiofiles/virtual-service-catalog-v1-mirror-v2.yml