Alex Jones avatar
By Alex Jones

Description

Learn the fundamental knowledge needed to understand container-to-container, pod-to-pod, and node-to-node networking within Kubernetes in this comprehensive guide.


Transcription

Introduction

In this recording, we're going to talk about some basics of networking and, hopefully, that will equip you with the fundamental knowledge you will need to understand more about container to container, pod to pod, and node to node networking within Kubernetes.

With that in mind, you can see a simple home network diagram on the screen. It's on a local area network, which describes a medium to a small network you might see across a house. We have a few devices on this network, one of which is the router. You'll receive that usually from your ISP, and the router will be effectively a device you plug in with a coaxial fiber or a twisted pair connection from the wall. And then will be connected either via cable to your games console, PC, or perhaps through a wireless network interface card to your phone.

What is a Network Interface Card or NIC?

I mentioned a few concepts, such as NIC… Network Interface Card is an essential part of this whole set of illustrations because it is how your computer joins a network. The Network Interface Card will be on any network-enabled device, and this is an example of an Ethernet NIC. Here we have an example of a phone, which should have a wireless NIC, which would be able to connect to the network.

Talking about these concepts can be pretty complicated when you think about the various physical side of things. On top of that, there is all the mystery of how it works electronically and what technologies are involved. That's why we commonly refer to the TCP/IP model in this day and age when we refer to your everyday network communication. And that is, effectively, because this is grown out of a set of protocols and domain boundaries for describing the physical, transport, network, and application layers of the various data paths required to make networking happen.

How does your home network work?

With that said, let's focus on this example and consider how your home network works. If we scroll down here, you can see that we have a representation of the TCP/IP stack. This stack, as I mentioned, is effectively a way of grouping concepts together, but also protocols. What's a protocol? It electronically sends data back and forth in a structured manner to achieve an outcome. Effectively, when we think about the application tier here, this is the highest level of our stack. The lowest level is the physical layer. We think of the physical layer as an actual router. What other technologies do we know? Switch, Hub, is also known as a repeater, cabling, etc.

Then at the top, you think of the application that would be the website loading. You will be able to see a request when you hit something with a ping in your terminal, which is the top layer of the TCP/IP model. You'll also hear me referring to the OCI or the seven-layer model, which is another way of encapsulating these concepts with more fidelity between them. But for our example here, we're thinking about how this model applies to our home network, which many of us are familiar with.

We think about the L1 at the bottom layer of the network. This includes things such as the data link layer and the physical layer. It also does mean the layers of plugging things in and the foundational technologies of how I check the machine's identity that I'm connected to and how I forward a bit of data to that machine. Many components at this L1 and L2 layer interplay and create the backbone of modern networking. That's why we start seeing familiar things like protocols on the internet or networking layer. Hence IP, which stands for Internet Protocol Address, is a way of assigning a temporary identity. It also gives way to route data to a particular device.

What is Internet Protocol Address?

The games console, the phone, the work PC, and the virtual machine on that PC may have IP addresses that enable the router to forward packets to their destination. The primary purpose of the router is to send packets to the right place. The router these days are quite sophisticated and serve a few other purposes, such as having a web UI where you can configure it and set up all sorts of additional properties. Fundamentally, the router will be assigning IP addresses through the DHCP and forwarding data at a much lower level.

What is a transport layer?

Before we arrive at that top layer of high-level protocols, let's talk about the transport layer. For example, when I'm streaming data to my games console and watching films on my mobile phone, some common protocols are extremely reliable and robust because they'll transfer data if lost. One of such protocols is TCP, and another is UDP, which is commonly used as a sort of a fire and forget very fast protocol for transmission. Also, the transport layer encapsulates a lot of those protocols and the technologies around session management by retrying on the failure of download and latency management.

The transport layer is a very effective bridge between taking the low-level data layer and converting it into a steady stream that can be consumed by the high-level application tier protocols such as HTTP. HTTP is probably familiar to us all because we think about things like http://www.google.com and that HTTP is the hypertext transfer protocol that allows us to download web pages. We also have this application layer like DHCP, which is how we can dynamically configure hosts across the network.

That's interesting because I've started talking about things like IP, hosts, and routing, and we need a bit of a cursory understanding of how this works. Well, effectively, we use something called IP address schemes to plan, out on our network, how a machine should have an identity. So, it's essential to understand perhaps four or five important things about IP addressing on your local network.

How IP addressing on your local network works?

Firstly, your machine will be assigned an IP address when you join a network. Often, if your phone joins a Wi-Fi or your gaming computer joins the network physically, you'll be quickly assigned an IP address via DHCP from the router. They look similar to internet addresses, but they will typically always start with 192.168 or 10.0, which are local IP addresses. IP addresses discussed here are the IPv4, and there are two formats of IP addresses. Typically, you get IPv4 and IPv6. IPv6 is a new standard with many more addresses because, in the IPv4 range, there is a finite amount of IP addressing.

The router will get an IP address, but the router itself will get an external IP. It will get one provided by your ISP or your internet service provider. This IP is just a loan. It's not forever. They're giving you that so that you can connect with the outside world and have data sent back to you. Some technologies allow you to move from an external IP to understand how you can go back to a local IP known as a natting or Network Address Translation. You can change the source and destination IP through Network Address Translation and modify that so it can transfer through the networks back to the correct target. This is done through various protocols, and ARP is one of them.

In ARP, we can inspect the data coming in and forward it to the correct MAC address because the one fundamental thing that doesn't change on these machines is their network interface cards will have a MAC address. It's a bit like having a license plate on your car. The MAC address doesn't tend to change in any situation on a NIC. Hence, they will both have MAC addresses that will be unchanging. That is the differentiator between the gaming PC and the games console because their network interfaces will be different and have different MAC addresses. So, the router can keep an internal lookup table and say, "I've assigned this IP address to this one, and this IP to this MAC address."

However, outside the internal home network, the Internet service provider, and wherever you've queried from, doesn't know about this. Therefore, the data stored within the router is essential to help us understand where to forward this data. That said, you can't have two computers on the same network with the same IP address because this is a key part of understanding how to do the forward routing. By the way, IP is often prefixed by TCP, and TCP stands for Transfer Control Protocol. So again, it is a simple set of rules for transmitting this information on the network.

Conclusion

The key takeaways from this video are that every device needs to have some form of network-enabled controller. An NEC, for short, whether that's a physical PC, a virtual machine running inside of your computer, a games console, or a phone, needs to have a way of joining the network. These networks, whilst they're physical, also have many electronic components on top of them that are sequenced using protocols.

It means we have protocols that constantly talk to each other across this network. As a result, even if our phone is turned off, there will be protocols ensuring that it's allocated an IP address when it rejoins. Hence, data that it requires from the Internet can not only go out but also come back in again. Some of these top protocols are HTTP and DHCP around the connectivity and transport, and all data collection are UDP and TCP. At the lower level for IP addressing and matching your destination are protocols such as IP and ARP.

I hope this has been useful because, in the following videos, we will look at how containers talk to each other within Kubernetes. It's essential to have a cursory understanding of Docker, cgroups, containers, and the ideas around the Linux kernel, and from there, we'll look at this in more detail. Thank you very much.

Don't stop now, check out your next lesson