1 The history of microservices

Microservices from Martin proposed to today, generally after four generations.

Generation 1 (1.0) : Service discovery phase. After the development of single service to microservice, the original communication mode from in-process function call to process call between different services on different servers, such a change of architecture, the key problem to be solved first is the registration and discovery of services. The technology is dubbo versus GRPC and BRPC frameworks.

Generation 2 (2.0) : When the service discovery problem is solved, the next challenge is service governance. In addition to communication between services, service governance also needs to take into account the failure retry, fault tolerance, degradation, monitoring, security, gray level, flow control and energy issues between services.

The third generation (3.0 era) : The micro services 2.0 era has brought a hundred flowers of solutions, each side of the song, our side of the stage, the same problem of different solutions have appeared, a time of the storm, very lively. Gateway solutions include Zuul, Gateway; Full link monitoring has pinpoint, Zipkin, Jaeger and so on. The endless emergence of various service governance solutions has brought many positive effects, but also the negative impact, that is, the inconsistency of standards, different maintenance methods. Service governance has become the mutual grafting of various middleware, and the quality of service governance depends on the technical level of engineers. Based on this, the demand for standardization and consistency of service governance is becoming stronger and stronger, so the service grid comes into being. The idea of a service grid is to standardize service governance and sink uniformly down to the infrastructure layer.

The fourth generation (4.0) : the era of no service, namely the era of servess, said the fashionable point is the era of decentralization. This is not mature at present, this article will not talk about.


2 Istio

Istio is a product of the Microservices 3.0 era and a representative product of Service Mesh. Created by Google and IBM. With the help of Google’s flagship product, K8S, it blew up the gods.

Istio includes the following features:

  • Automatic load balancing for HTTP, gRPC, WebSocket and TCP communications
  • Pluggable policy layer and configuration API that supports access control, rate limiting and quotas
  • Automatic measurement, logging, and tracking of all traffic within the cluster, including entry and exit points to the cluster
  • Secure inter-service communication in a cluster with powerful identity – and authentication-based authentication and authorization
  • Fine-grained control of traffic behavior through rich routing rules, retry, failover, and failover

In a nutshell, Istio is responsible for traffic management of network packets, secure of services, policies (e.g., blacklisting) and observability (e.g., monitoring).


3 Istio use

After introducing a lot of theories (in fact, I don’t like theories at all), I started installing Istio.

3.1 download Istio

If you use the following statement to download Istio, the download speed will be slow. How slow? He who tries knows. And it breaks from time to time, so you have to keep an eye on it, and if it fails, you have to do it again. It’s like when you’re taking a piss and someone’s always pushing you behind you, making the whole thing very awkward and unpleasant.

# curl -L https://istio.io/downloadIstio | sh -
Copy the code

During the download process, if you encounter the following error:

# Unable to get latest Istio version. Set ISTIO_VERSION env var and re-run. For example: exportISTIO_VERSION = 1.0.4
Copy the code

You will need to set up the version of ISTIO you want to download as follows:

# exportISTIO_VERSION = 1.4.5
Copy the code

The screenshot after the successful download is as follows:

3.2 installation Istio

Before installing Istio, decompress:

#The tar - ZXVF istio - 1.4.5 - Linux. Tar. Gz
Copy the code

The following figure shows the decompressed directory structure:

Key directories are described as follows:

Samples # istio install/kubernetes # istio resource file bin/istioctl # istio client tool for manually injecting envoyCopy the code

3.3 Configuring the Istioctl Tool Path

Istioctl is an Istio client tool that manually infuses sidecar as an envoy container as follows:

# cdIstio - 1.4.5
# export PATH=$PATH:$PWD/bin
Copy the code

Once configured, istioctl can be automatically completed using the Tab key in bash. But is it enough? Perfect? Of course not. We have higher standards.

Because istioctl has many configuration items, using the TAB key can only auto-complete istioctl, but cannot auto-complete subcommands such as istioctl manifest. Therefore, we need to set up enhanced autocomplete function.

3.4 Realizing the istioctl automatic completion function

Copy the istioctl.bash file from the tools directory in the Istio installation package to the root directory of the user.

#Cp istio/istio - 1.4.5 / tools/istioctl bash ~
Copy the code

Edit the ~/.bash_profile file and add the following at the end:

# source ~/istioctl.bash
Copy the code

After the configuration is added, load the configuration to make it take effect:

# source ~/.bash_profile
Copy the code

Then type istioctl and press TAB twice to see that enhanced autocomplete has taken effect:

3.5 Installing Istio for Learning

To reduce the cost of learning, we chose to install the learning version of Istio. If you want to install Istio directly in your production environment, refer to my subsequent chapters.

Execute the following statement to install Istio Learning:

# istioctl manifest apply --set profile=demo
Copy the code

The screenshot after installation is as follows:

Don’t scream with joy when you see Installation Complete! Because the installation does not report a mistake does not mean that you are successful, just like you see a beautiful, sexy, hot, pure, noble, gorgeous set a woman to you when you come to think that people think you grow handsome bubble you the same truth.

Run the following command to check the Istio service status:

# kubectl get svc -n istio-system
Copy the code

The execution result is as follows:

Services using the LoadBalancer type are generally useful only if supported by third-party cloud vendors. Use NodePort if you are building your own K8S cluster. The following statement is executed:

kubectl patch svc -n istio-system istio-ingressgateway -p ‘{“spec”: {“type”: “NodePort”}}’

After execution, check the SVC again to find that the LoadBalancer type has been changed to NodePort, and external-IP has changed from pending to not needed.

View the POD running status of Istio:

# kubectl get pod -n istio-system
Copy the code

The running status of all pods is in the running state:

Since then, the whole Istio environment has been blown away by you. Now you can stop, go to the bathroom, drink and scream.

3.6 uninstall istio

But if you don’t feel good enough, the pleasure of building something and the pleasure of not destroying something is not enough for your technical life, you can easily complete Istio by executing the following sentence.

# istioctl manifest generate --set profile=demo | kubectl delete -f -
Copy the code

4 summarizes

All right, we’re back to square one. It’s a lot like how you feel when you meet someone of the opposite sex, fall in love, and then dump them. But after looking at disappeared all the black screen, you may be disconsolate, you will ask yourself in the dead of night, whether the feeling of abandonment is really happy? If not, go back to the beginning and try again. Maybe when you’re done, you’ll get back to your loved one.