This instructions will lead you to getting start with using Servicecomb-service-center-istio
This tool can be used both inside a k8s cluster and a standalone service running on a VM.
For both ways you have to install dependencies first.
You can follow K8S installation instruction to install a K8S cluster
Follow this instruction to install istio
note: the instruction is just a show case of how to install and use istio, if you want to use it in production, you have to use a production ready installation profile
As any Servicecomb service center service will be translated to Serviceentry in K8S, while Kubernetes provides DNS resolution for Kubernetes Services out of the box, any custom ServiceEntrys will not be recognized. In addition to capturing application traffic, Istio can also capture DNS requests to improve the performance and usability of your mesh
Use the following command to install istio DNS:
cat <<EOF | istioctl install -y -f - apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: meshConfig: defaultConfig: proxyMetadata: # Enable basic DNS proxying ISTIO_META_DNS_CAPTURE: "true" # Enable automatic address allocation, optional ISTIO_META_DNS_AUTO_ALLOCATE: "true" EOF
Servicecomb service center could be installed in K8S or on VM. Install Servicecomb service center follow this instruction
You don’t need to build from source to use Servicecomb-service-center-istio (binaries in apache nexus ), but if you want to try out the latest and greatest, Servicecomb-service-center-istio can be easily built.
go build -o servicecomb-service-center-istio cmd/main.go
docker build -t servicecomb-service-center-istio:dev .
./servicecomb-service-center-istio --sc-addr=?SERVICE_CENTER_ADDRESS --kube-config=?KUBE_CONFIG_FILE_PATH
# make sure you modified the input args in the deployment.yaml file first, specify you service center address kubectl apply -f manifest/deployment.yaml
We will use consumer-provider example to show how to use this tool.
We have two services: Provider and Consumer:
provider
is the provider of a service which calculates and returns the sum of the square root from 1 to a user provided parameter x
.consumer
performs as both provider and consumer. As a consumer, it calls the api provided by provider
to get the result of the sum of square roots; as a provider
, it provides a service externally which returns the result it gets from provider
to its clients.While Provider uses servicecomb service center tech stack, Consumer uses istio tech stack. Origionaly, Provider and Consumer couldn't discover each other.
In this demo, we are going to adopt our servicecomb-service-center-istio to brake the barrier between Provider and Consumer.
> docker build --target consumer -t consumer:dev .
Make sure you have already configed the registry related configuration (provider/conf/chassis.yaml)
> docker build --target provider -t provider:dev .
Because Consumer is Istio-based service, so it has to be run in the Kubernetes. We have our deploument yaml file to deploy consumer into Kubernetes
> kubectl apply -f manifest/consumer.yaml
Provider service could be deployed either on a VM
or Kubernetes
cluster.
For VM
# go to provider folder and run > ./provider
For Kubernetes
> kubectl apply -f manifest/provider.yaml
Now you can try to request consumer
service and you can get the response which is actually return from provider
service.
> curl http://${consumerip}:${consuemrport}/sqrt?x=1000 Get result from microservice provider: Sum of square root from 1 to 1000 is 21065.833111