TranslateProject/sources/tech/20171014 Proxy Models in Container Environments.md
2017-10-25 21:10:07 +08:00

7.8 KiB
Raw Blame History

translating by 2ephaniah

Proxy Models in Container Environments

Most of us are familiar with how proxies work, but is it any different in a container-based environment? See what's changed.

Inline, side-arm, reverse, and forward. These used to be the terms we used to describe the architectural placement of proxies in the network.

Today, containers use some of the same terminology, but they are introducing new ones. Thats an opportunity for me to extemporaneously expound* on my favorite of all topics: the proxy.

One of the primary drivers of cloud (once we all got past the pipedream of cost containment) has been scalability. Scale has challenged agility (and sometimes won) in various surveys over the past five years as the number one benefit organizations seek by deploying apps in cloud computing environments.

Thats in part because in a digital economy (in which we now operate), apps have become the digital equivalent of brick-and-mortar “open/closed” signs and the manifestation of digital customer assistance. Slow, unresponsive apps have the same effect as turning out the lights or understaffing the store.

Apps need to be available and responsive to meet demand. Scale is the technical response to achieving that business goal. Cloud not only provides the ability to scale, but offers the ability to scale  automatically . To do that requires a load balancer. Because thats how we scale apps with proxies that load balance traffic/requests.

Containers are no different with respect to expectations around scale. Containers must scale and scale automatically and that means the use of load balancers (proxies).

If youre using native capabilities, youre doing primitive load balancing based on TCP/UDP. Generally speaking, container-based proxy implementations arent fluent in HTTP or other application layer protocols and dont offer capabilities beyond plain old load balancing (POLB). Thats often good enough, as container scale operates on a cloned, horizontal premise to scale an app, add another copy and distribute requests across it. Layer 7 (HTTP) routing capabilities are found at the ingress (in ingress controllers and API gateways) and are used as much (or more) for app routing as they are to scale applications.

In some cases, however, this is not enough. If you want (or need) more application-centric scale or the ability to insert additional services, youll graduate to more robust offerings that can provide programmability or application-centric scalability or both.

To do that means plugging-in proxies. The container orchestration environment youre working in largely determines the deployment model of the proxy in terms of whether its a reverse proxy or a forward proxy. Just to keep things interesting, theres also a third model sidecar that is the foundation of scalability supported by emerging service mesh implementations.

Reverse Proxy

Image title

A reverse proxy is closest to a traditional model in which a virtual server accepts all incoming requests and distributes them across a pool (farm, cluster) of resources.

There is one proxy per application. Any client that wants to connect to the application is instead connected to the proxy, which then chooses and forwards the request to an appropriate instance. If the green app wants to communicate with the blue app, it sends a request to the blue proxy, which determines which of the two instances of the blue app should respond to the request.

In this model, the proxy is only concerned with the app it is managing. The blue proxy doesnt care about the instances associated with the orange proxy, and vice-versa.

Forward Proxy

Image title

This mode more closely models that of a traditional outbound firewall.

In this model, each container node has an associated proxy. If a client wants to connect to a particular application or service, it is instead connected to the proxy local to the container node where the client is running. The proxy then chooses an appropriate instance of that application and forwards the client's request.

Both the orange and the blue app connect to the same proxy associated with its node. The proxy then determines which instance of the requested app instance should respond.

In this model, every proxy must know about every application to ensure it can forward requests to the appropriate instance.

Sidecar Proxy

Image title

This mode is also referred to as a service mesh router. In this model, each **container **has its own proxy.

If a client wants to connect to an application, it instead connects to the sidecar proxy, which chooses an appropriate instance of that application and forwards the client's request. This behavior is the same as a  _forward proxy _ model.

The difference between a sidecar and forward proxy is that sidecar proxies do not need to modify the container orchestration environment. For example, in order to plug-in a forward proxy to k8s, you need both the proxy  _and _ a replacement for kube-proxy. Sidecar proxies do not require this modification because it is the app that automatically connects to its “sidecar” proxy instead of being routed through the proxy.

Summary

Each model has its advantages and disadvantages. All three share a reliance on environmental data (telemetry and changes in configuration) as well as the need to integrate into the ecosystem. Some models are pre-determined by the environment you choose, so careful consideration as to future needs service insertion, security, networking complexity need to be evaluated before settling on a model.

Were still in early days with respect to containers and their growth in the enterprise. As they continue to stretch into production environments its important to understand the needs of the applications delivered by containerized environments and how their proxy models differ in implementation.

*It was extemporaneous when I wrote it down. Now, not so much.


via: https://dzone.com/articles/proxy-models-in-container-environments

作者:Lori MacVittie 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出