Understanding Container-to-Container Networking

This topic provides an overview of how Container-to-Container Networking works.

The Container-to-Container Networking feature enables app instances to communicate with each other directly. When the Container-to-Container Networking feature is disabled, all app-to-app traffic must go through the Gorouter.

Architecture

Overview

Container-to-Container Networking integrates with Garden-runC in a Diego deployment. The Container-to-Container Networking BOSH release includes several core components, as well as swappable components.

To understand the components and how they work, see the diagram and tables below. The diagram highlights Pivotal Web Services (PWS) components in blue and green. The diagram also highlights swappable components in red.

c2c architecture diagram

Core Components

The Container-to-Container Networking BOSH release includes the following core components:

Part Function
Cloud Foundry Command Line Interface (CF CLI) plugin A plugin that you download to control network access policies between apps.
Policy Server A central management node that does the following:
  • Maintains a database of policies for traffic between apps. The CF CLI plugin calls an API to create or update a record in the policy database whenever you create or remove a policy.
  • Exposes a JSON REST API used by the CF CLI plugin
Garden External Networker A Garden-runC add-on deployed to every Diego cell that does the following:
  • Invokes the CNI plugin component to set up the network for each app
  • Forwards ports to support incoming connections from the Gorouter, TCP Router, and Diego SSH Proxy. This keeps apps externally reachable.
  • Installs outbound whitelist rules to support Application Security Groups (ASGs).

Swappable Components

The Container-to-Container Networking BOSH release includes the following swappable components:

Part Function
Silk CNI plugin
A plugin that provides IP address management and network connectivity to app instances as follows:
  • Uses a shared VXLAN overlay network to assign each container a unique IP address
  • Installs network interface in container using the Silk VXLAN backend. This is a shared, flat L3 network.
VXLAN Policy Agent
Enforces network policy for traffic between apps as follows:
  • Discovers desired network policies from the Policy Server Internal API
  • Updates iptables rules on the Diego cell to allow whitelisted inbound traffic
  • Tags outbound traffic with the unique identifier of the source app using the VXLAN Group-Based Policy (GBP) header

App Instance Communication

Container-to-Container Networking uses an overlay network to manage communication between app instances.

Each Diego cell assigns IP addresses to its containers using a /24 subnet range, which supports up to 250 containers per cell. The subnet range you choose for your overlay network determines how many Diego cells your network supports.

Using the /16 subnet range, Pivotal Web Services (PWS) supports up to 250 Diego cells. To support a higher or lower number of Diego cells, choose a different subnet range. For example, use /12 to support more Diego cells or /24 to support fewer Diego cells.

NOTE: The overlay network IP range must not conflict with any other IP addresses in the network. If there is a conflict, the Diego cells cannot reach any endpoint that has a conflicting IP address.

Without Container-to-Container Networking

The diagram below illustrates how two app instances communicate in a deployment without Container-to-Container Networking enabled. Traffic from App A must route out and back in through the Gorouter, which restricts performance and the protocol used to send the traffic. In this scenario, App B does not know the real source of the traffic it receives and must trust all inbound traffic.

Pre Container-to-Container Networking

With Container-to-Container Networking

The diagram below illustrates how app instances communicate in a deployment with Container-to-Container Networking enabled. In this example, the operator creates two policies to regulate the flow of traffic between App A, App B, and App C.

  • Allow traffic from App A to App B
  • Allow traffic from App A to App C

If traffic and its direction is not explicitly allowed, it is denied. For example, App B cannot send traffic to App C.

Post Container-to-Container Networking

Container-to-Container Networking versus ASGs

Both application security groups (ASGs) and Container-to-Container Networking policies affect traffic from app instances. The following table highlights differences between ASGs and Container-to-Container Networking policies.

ASGs Container-to-Container Networking Policies
Policy granularity From a space to an IP address range From a source app to a destination app
Scope For a space, org, or deployment For app to app only
Traffic direction Outbound control Policies apply for incoming packets from other app instances
Source app Is not known Is identified because of direct addressability
Policies take affect After app restart Immediately

Policies

Enabling Container-to-Container Networking for your deployment allows you to create policies for communication between app instances. The Container-to-Container Networking feature also provides a unique IP address to each app container and provides direct IP reachability between app instances.

The policies you create specify a source app, destination app, protocol, and port so that app instances can communicate directly without going through the Gorouter, a load balancer, or a firewall. Container-to-Container Networking supports UDP and TCP, and you can configure policies for multiple ports. These policies apply immediately without having to restart the app.

Alternative Network Stacks

The BOSH release that contains the Container-to-Container Networking feature is composed of a pluggable network stack. Advanced users or third-party vendors can integrate a different network stack. For more information about third-party plugins, see the Container-to-Container Networking BOSH release documentation.

Create a pull request or raise an issue on the source for this page in GitHub