Hello and welcome to Inside Kubernetes Networking, a KubeCon and CloudNativeCon Euro 2021 presentation. I am Dominic Tornot, Principal Engineer at Cisco. I focus on systems modeling, specifically conceptual and formal modeling to support the development and documentation of complex software systems. Kubernetes Networking is a core abstraction of Kubernetes. Kubernetes Networking ensures components within cluster boundaries and components across cluster boundaries can communicate. Kubernetes Networking is split into the Kubernetes Networking specification and the Kubernetes Networking implementation. In fact, many alternative implementations called Kubernetes Network Plugins exist today. The details of the Kubernetes Network implementation depend on the details of the Kubernetes Network plugin, no two are alike. Therefore, instead of discussing a complete picture based on one particular network plugin or an incomplete picture based on the least common denominator of all network plugins, in this presentation we will discuss an idealized implementation. Accordingly, this presentation is split into two parts. The first part discussing the specification, the second part discussing an idealized implementation. So first up, the Kubernetes Networking specification. From the point of view of the Kubernetes Networking specification, a Kubernetes cluster consists of a set of nodes. Each node hosts a set of parts and each part executes a set of containers. Additionally, each node hosts a set of processes called demons. In the context of Kubernetes, network addressable elements, that is, elements with an IP address, consist of nodes and parts. However, keep in mind that the ultimate producers and consumers of messages are not nodes and parts, but are instead containers and demons. The Kubernetes Networking specification is a set of constraints on the message exchange between containers and containers and containers and demons. The Kubernetes Network specification addresses three different concerns, container-to-container communication, part-to-part communication and demon-to-part communication. First, we will discuss container- to-container communication. The specification requires that a container C1 that is executing in the context of a Part P can communicate with any other container C2 that is also executing in the context of P via local host or via the IP address of P. Again, represented graphically, a container C1 that is executing in the context of a Part P can communicate with any other container C2 that is also executing in the context of P via local host or via the IP address of P. Next, we will discuss part-to-part communication. The specification requires that a container C1 that is executing in the context of a Part P1 can communicate with any other container C2 that is executing in the context of any other Part P2 via the address of P2. Again, represented graphically, a container C1 that is executing in the context of a Part P1 can communicate with any other container C2 that is executing in the context of any other Part P2 via the address of P2. Please note that this requirement does not include the node P1 or P2 is hosted on. Therefore, P1 could be hosted on the same or a different node as P2. Next, we will discuss demon-to-part communication. The specification requires that a demon D that is hosted on a node N can communicate with any container C that is executing in the context of a Part P that is also hosted on N via the address of P. Again, represented graphically, a demon D that is hosted on a node N can communicate with any container C that is executing in the context of a Part P that is also hosted on N via the address of P. Please note that this requirement does include the node D and P are hosted on. Additionally, however, strictly speaking, not part of Kubernetes networking but provided on top of Kubernetes networking, Kubernetes provides Kubernetes services and Kubernetes ingress. We will discuss Kubernetes services, both cluster IP services and node port services, as well as ingress when we discuss the idealized implementation of Kubernetes networking. Next up, the idealized Kubernetes networking implementation. In this presentation, we will rely on conceptual instead of actual implementations of a Kubernetes network to reason about the life of a message in the Kubernetes cluster. So the model we are about to discuss describes a conceptual network plugin. It does not describe an actual network plugin. We use this model as an educational model. Before we discuss a model of Kubernetes networking in particular, we will briefly discuss a model of networking in general. A communicating system can be modeled as a graph. The nodes of the graph consists of a set of containers and a set of switches. Again, here, a switch is a conceptual component, not an actual component. A switch can be modeled as a function and a forward information base. A switch can match any part of a message, typically the source address, source port, target address, and target port against its forward information base to determine the next action. Here, we assume that a switch may either drop a message, deliver a message to a container or demon, forward a message to another switch, or translate a message before calling itself recursively with the translated message. The links or edges of the graph consist of links between containers and switches and links between switches and switches. Messages may only travel between links. So as long as a network of switches, their forward information bases and their connections satisfy the constraints of the Kubernetes network specification, it is a valid Kubernetes network implementation. We will now discuss one possible network. As discussed, we will reason about the Kubernetes network in terms of a network graph. But how does a network graph, that is a valid Kubernetes network implementation, satisfying the Kubernetes network specification, actually look like? From here on out, we will use a simple Kubernetes cluster as an example. The cluster consists of two nodes, N1 and N2. Each node hosts a demon, for example the Kubelet, D1 and D2. Additionally, each node hosts two pods, P1 and P3, as well as P2 and P4. And finally, each pod executes two containers. Again, elements with an IP address consist of nodes and pods. And finally, in this example, the first container of each pod listens on port 8080, and the second container of each pod listens on port 9090. So for this example, what does a possible network graph look like? First, we assume that for every pod, there exists a corresponding switch from here on out called pod switch. For every container executing in the context of a pod, there exists a link from the container to the corresponding pod switch. Next, we assume that for every node, there exists a corresponding switch from here on out called node switch. For every pod hosted on a node, there exists a link from the corresponding pod switch to the corresponding node switch. Additionally, for every demon hosted on a node, there exists a link from the demon to the corresponding node switch. And finally, there exists a link from every node switch to every other node switch. Now to complete the network graph, we must determine the forward information base for node switches and pod switches. The forward information base of a pod switch contains three types of entries. First, local delivery via local host. Next, local delivery via the pod's IP address. And next, any other message will be forwarded to the linked node switch. Similarly, the forward information base of a node switch contains two types of entries. First, messages that target a pod that is hosted on the corresponding node are forwarded to the corresponding pod switch. And next, messages that target a pod that is not hosted on the corresponding node are forwarded to the node switch corresponding to the node that does host the pod. Later on, we will expand the forward information base of node switches to accommodate for Kubernetes services and add rules to translate messages. This network, consisting of containers and demons, as well as pod switches and node switches, in combination with the aforementioned forward information basis, constitutes a valid Kubernetes network. In this last section, we will walk through a sequence of examples, highlighting container-to-container communication, pod-to-pod communication, demon-to-pod communication, services, and Ingress. A fair warning. This section is tediously repetitive. But if you follow along, you will gain a solid understanding of the underlying mechanics. In this example, we will discuss container-to-container communication. Here, we focus on container-C1.1 and C1.2, executing in the context of pod-P1. Container-C1.1 will communicate with C1.2 via localhost. Recall that C1.2 is listening on port 1990. First, container-C1.1 will send a message M via its edge to pod-switch P1. The target address of M is localhost. The target port of M is 1990. The pod-switch P1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod-switch to deliver the message to container-C1.2. Pod-switch P1 will send the message M via its edge to container-C1.2. And finally, the container will receive the message. Next, in this example, we will discuss pod-to-pod communication. The pods are located on the same node. Here, we focus on container-C1.1, executing in the context of pod-P1 and on container-C3.1, executing in the context of pod-P3. Both P1 and P3 are hosted on the node N1. Container-C1.1 will communicate with C3.1 via the address of P3. We call that C3.1 is listening on port 8080. First, container-C1.1 will send a message M via its edge to pod-switch P1. The target address of M is the address of pod-P3. The target port of M is 8080. The pod-switch P1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod-switch to forward the message to node switch N1. Pod-switch P1 will send the message M via its edge to node switch N1. The node switch N1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the node switch to forward the message to pod-switch P3. Node-switch N1 will send the message M via its edge to pod-switch P3. The pod-switch P3 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod-switch to deliver the message to container 3-1. Pod-switch P3 will send the message M via its edge to container 3-1. And finally, the container will receive the message. Next, in this example, we will discuss pod-to-pod communication. However, this time the pods are located on different nodes. Here we focus on container C1.1. Executing in the context of pod P1 hosted on node N1 and on container C2.1 executing in the context of pod P2 hosted on node N2. Container C1.1 will communicate with C2.1 via the address of P2. Recall that C2.1 is listening on port 8080. First, container C1.1 will send a message M via its edge to pod-switch P1. The target address of N is the address of pod P2. The target port of N is 8080. The pod-switch P1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod switch to forward the message to node switch N1. Pod-switch P1 will send the message M via its edge to node switch N1. The node switch N1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the node switch to forward the message to node switch N2. Node switch N1 will send the message M via its edge to node switch N2. The node switch N2 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the node switch to forward the message to pod switch P2. The node switch N2 will send the message M via its edge to pod switch P2. The pod switch P2 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod switch to deliver the message to container C2.1. Pod-switch P2 will send the message M via its edge to container C2.1. Finally, the container will receive the message. Next, in this example, we will discuss daemon to pod communication. Here, we focus on daemon D1 hosted on node N1 and on container C1.1 executing in the context of pod P1 also hosted on N1. Daemon D1 will communicate with C1.1 via the address of P1. Recall that C1.1 is listening on port 8080. First, daemon D1 will send a message M via its edge to node switch N1. The target address of N is the address of pod P1. The target port of M is 8080. The node switch N1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the node switch to forward the message to pod switch P1. N1 will send the message M via its edge to pod switch P1. The pod switch P1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod switch to deliver the message to container C1.1. Pod switch P1 will send the message M via its edge to container C1.1. And finally, the container will receive the message. Next, in this example, we will discuss Kubernetes services. Here, cluster IP services. Some understanding of services will be beneficial. Kubernetes services is an anycast domain, where a message that is sent to the anycast domain is routed to an arbitrary member of the anycast domain. A cluster service is intended for internal communication. That is, the source of the message is a container executing in the context of a pod on the same cluster. The service is identified via a service IP address. This listing defines a service that selects all pods with a label value pair of foo bar and map support 80 to port 8080. Kubernetes will allocate an IP address for this service and configure the forward information base so that a message with a target address of the service IP address and the target port of 80 will be received by a container of any pod, matching the selector listening on port 8080. Here, we focus on container C1.1 executing in the context of pod P1, hosted on node N1, and on the container C2.1 and C4.1 executing in the context of pod P2 and P4, both hosted on node N2. Note that both P2 and P4 have a label value pair of foo bar. Container C1.1 will communicate with the service with the IP address of the service on port 80. First, container 1.1 will send a message M via its edge to pod switch P1. The target address of M is the address of the service. The target port of M is 80. The pod switch P1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the pod switch to forward the message to node switch N1. Pod switch P1 will send the message M via its edge to node switch N1. The node switch N1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the node switch to translate the target address to the address of pod P2 and the target port to 8080 or to translate the target address to the address of pod P4 and the target port to 8080. Here, we assume the target address is translated to the address of pod P2 and the target port is translated to 8080. The node switch will call itself and match the new message against its forward information base. And from here, we already know what is going to happen. Next, in this example, we will discuss Kubernetes services. Here, node port services. Again, some understanding of services will be beneficial. A node port service is intended for external communication. That is, the source of the message is a process outside the cluster. On the network, the service is identified via a node IP address and a port. This listing defines a service that selects all pods with a label value pair of foo bar and maps the node port 30,000 to port 8080. Kubernetes will configure the forward information base so that a message with a target address of any node's IP address in the target port of 30,000 will be received by a container of any pod, matching the selector listening on port 8080. Here, the source of the message is outside the cluster and we focus on the containers C2.1 and C4.1 executing in the context of pod P2 and P4, both hosted on node N2. Note that both P2 and P4 have a label value pair of foo bar. Here, we start our journey with the receive event of message M at node switch N1. The target address of M is the address of the node this node switch corresponds with. The target port of M is 30,000. The node switch N1 will match the message against its forward information base. It will find a relevant entry that instructs the node switch to translate the target address to the address of pod P2 and the target port to 8080 or to translate the target address to the address of pod P4 and the target port to 8080. Here, we assume the target address is translated to the address of pod P2 and the target port is translated to 8080. The node switch will call itself and match the new message against its forward information base. And again, from here, we already know what is going to happen. In this extensive example, we will put everything together and discuss Kubernetes Ingress. Some understanding of Ingress will be beneficial. Kubernetes Ingress is an API gateway for HTTP messages. This listing defines an Ingress that consists of two request level routing rules. A proxy is responsible to process these routing rules. Here, the proxy is fronted by a node port service to admit external messages. HTTP requests with a host header of example.org and the path A will be proxied to service foo on port 8080. HTTP requests with a host header of example.org and a path B will be proxied to service bar on port 8181. Here, we start our journey with the receive event of message M at node switch N1. The target address of M is the address of the node this node switch corresponds with. The target port of M is 30,000. Additionally, but not shown in the picture, the message is an HTTP message with a host header of example.org and a path of A. The node switch N1 will match the message against its forward information base. It will find a relevant entry that instructs the node switch to translate the target address to the address of port P1 that hosts the proxy and the target port to 8080. The target address is translated to the address of port P1 and the target port is translated to 8080. The node switch will call itself and match the new message against its forward information base. It will find a relevant entry that instructs the node switch to forward the message to port switch P1. Node switch N1 will send the message M via its edge to port switch P1. The port switch N1 will receive the message and match the message against its forward information base. It will find a relevant entry that instructs the port switch to deliver the message to the proxy. Port switch P1 will send the message M via its edge to the proxy. And finally the proxy will receive the message. Next the proxy performs request level routing. The proxy matches the HTTP host header and the path of the message against its decision table. It will find a relevant entry that instructs the proxy to proxy the message to service foo on port 8080. Finally the proxy will send a message M via its edge to node switch P1. The target address of M is the address of service foo the target port of M is 8080. And again from here on out we already know what is going to happen. With this we conclude today's presentation. If you would like to read up on today's material please visit my blog post inside Kubernetes Networking. If you are watching this presentation during the conference I'd be happy to answer your questions online. If you are watching this presentation after the conference I'd be happy to answer your questions on social media. But either way thank you for watching Inside Kubernetes Networking.


Hi, I'm Zor. Welcome to Unisor Education. We continue talking about theory of probabilities. Today's topic is random variables. That's introduction to random variables. I do suggest you to study this material, watching this lecture on Unisor.com, because the lectures over there are presented with notes, and also registered students can take exams and just do some self-study, especially if it's about the problem-solving lectures. Before going into any problem-solving lecture, watching this lecture, it would be very beneficial if you will just try to solve these problems yourself. I mean, that's the purpose of the entire course, actually, to teach you to solve problems. All right, now, this is a more theoretical material. It's not anything related to problems. I have to introduce a new concept, a concept of random variable. That's what it is. Okay, theory of probabilities historically was developed based on basically the games, the gambling, if you wish. People wanted to analyze the chances of having this or that particular game won or lost. Now, obviously, with each game, there was some kind of a monetary financial arrangement. So, people were winning or losing money. So, there is certain quantitative characteristic of the game, amount you are winning or amount you are losing. So, that's where the roots of the random variables actually are. So, not only we want to evaluate all the different results of our random experiments, all the different elementary events, but we also want to have certain quantitative characteristics of each event. All right, now, let me give you an example. You are flipping a coin. Not only you are interested in whether it actually shows the heads or the tails and whether you can guess it in this way or that, you probably bet money on it. So, let's consider you bet $1 on heads.  So, the partner flips the coin and if it falls showing the heads, then you win and he pays you $1. If it's tails, you lose and you are paying him $1. Well, that seems to be a fair game, right? So, what is a dollar? A dollar is a quantitative measurement of the event. So, what's our sample space? Sample space contains two different elementary events, heads and tails. So, this is my omega. This is my sample space. It has two elementary events. Now, what are the probabilities of these events? Well, the probabilities are P of heads equals 1.5 and P of tails equals 1.5 and obviously, the sum of these is equal to 1 because that's the total probability of anything happening. Now, I associate with these two different elementary events two different numbers. One number is 1 with heads and another number is minus 1 with tails. This is my winning $1. This is my losing $1. So, basically, the game when I am betting on the heads can be described in these terms. Now, what are these? Well, this is actually an example of a random variable. Random variable is basically a function, if you wish, which is defined on these two elementary events and taking values in corresponding with two different numerical values, real values. So, usually random function, random variable is introduced in exactly this fashion. You have to have certain sample space with elementary events and for each elementary event, you have certain numerical characteristics of this. Not necessarily, by the way, different. Sometimes they might be similar, same or whatever. So, this basically has this property of being a quantitative characteristic of the winning or losing. So, these are elementary events. These are the probabilities of these events and these are random variables, different values of random variable which is defined on this set of elementary events. So, again, you can actually think about random variable as a function which has certain domain where it's defined and it has certain values. So, where it's defined is the set of elementary events and the set of values are real numbers. Okay, next. Next, let me give you a couple of examples. Okay, couple of examples of random variables. Very simple examples. The sample first is you have a certain number, let's say, 10 people in a room. A, B, C, D, E, F. Well, let's have sex. I don't want to have 10 too many. All right. Now, the random experiment is picking a simple, one simple pick, simple pick of one person. All right. So, you're picking one person from the room. So, each person has certain age. All right, let's say this has 23, this has 20, this has 22, this has 20, this has 30 and this is 55. So, if I am selecting a particular person out of this set and this person has certain age. So, the age is basically a result of a numerical result of the random experiment of selecting the person. So, if I am selecting with equal chances, then each one of these has one six probability. There are six of them, right? So, the probability associated with each elementary event is one six. So, my random variable takes values 23, 20, 20, 30 and 55, with probabilities correspondingly one six, one six, one six, one six, one six and one six. Now, what's interesting, by the way, that two different values, they're not really different, right? So, if I'm asking what's the probability of my random variable to take the value 20, well, that's one six and one six. So, it's actually two six, which is one third. So, the probability of taking the value 20 is greater than the probability of taking 23 or 22 or 30 or 55. All right, in any case, this is an example of a random variable where the set where it's defined, the elementary events is a set of six people and the value of the random variable is the age of randomly selected person. Next example. Next example is the game of roulette. Now, the game of roulette and there are certain variations in America. The game of roulette has numbers from one to 36 and then zero and double zero. So, it's 38 different position on the wheel and the ball is actually spinning and the wheel is spinning and wherever the ball stops, that's the number. Now, there are also some other aspects of this game like the color of the number, etc. But let's just completely forget about all this. We are talking about the game when you have to guess a number. So, let's say you are predicting that the number will be 23.  That's what you lose if you don't really guess correctly. Well, considering there are 38 different positions of the ball, only one of them is the winning position and each of them probably is equal chances if the casino is playing a fair game. So, the probability of each position is 138. So, the probability of your winning is 138. So, with the probability of 138, you get 36 dollars and the probability of 37, 38, so all other cases you are losing a dollar. Well, which seems to be relatively fair. Obviously, there is something which casino is winning but we will talk about this later.  So, that's basically how it works. But in any case, I wanted to present this case as an example of a random variable which takes two values, 36 and minus 1. One is the probability of 138 and another is with the probability of 37, 38. Now, the elementary events where this function actually is defined is all these numbers. So, omega is 1 to 36, 0 and double 0 and the probability of each is equal to 1 over 38. So, these are elementary events and only on one of these events, the 23, which I am predicting, I am winning my 36 dollars and in all other cases, I am losing my dollar. So, that's how the function is defined on this set of values. All these except 23 are associated with a number minus 1 and the 23 is associated with a number 36. That's my numerical function.  Alright, and I have a third example. The third example is the following. Let's say you have a nuclear reactor and the engineer actually is measuring the temperature. The temperature should always be watched because if it's rising, then we have to pull the fuel rod from the reactor to cool it down and if it's to cool, then it should be pushed back. So, basically, the temperature is a very important characteristic. So, at certain time, like every hour or something like this, an engineer is measuring temperature and he knows that the normal temperature is supposed to be, let's say, 800 degrees Celsius or whatever. I don't know what it is. But, its actual reading of the temperature are different obviously because sometimes he has 790, sometimes he has 802, sometimes he has 810, etc. So, basically, all these experiments which he is making, one after another, after another, give you certain event, certain elementary event. And let's say you're observing the whole thing for 24 hours. So, your set of 24 different temperature measurements are the values of your random variable. So, the time when you make this measurement can be your, let's say you have 12 o'clock, 1 o'clock, etc., up to 23 o'clock in military time. So, every time, no, that's actually zero supposed to be. If it's military, it's zero, right? So, from zero to 23. So, these 24 different elementary events correspond to 24 different temperatures. And that's basically your set of elementary events and numerical equivalent of your experiment. That's the random variable. So, you might say, observing your random variable during a certain period of time, like in this case 24 hours, you can say that, okay, it takes certain values with certain probabilities. And you can actually observe that something around 800 is occurring more often than further from the 800, which means the reactor is working normally. So, just an example, and that's, in this particular case, it might be related actually with certain fluctuations within the nuclear reactor, whatever the nuclear reaction is actually occurring. Okay, so, examples, fine. Now, let me point out that in this particular course, we're talking about theory of probabilities, which is related to finite number of elementary events. So, whatever the experiment is, we have certain finite number of elementary events. And for each of these elementary events, we have the function defined as a random variable on it, right? So, let's consider it this way. You have elementary events, e1, e2, et cetera, en. Now, not necessarily they have equal chances of occurring. Sometimes it has, they have equal, sometimes not. But so, let's consider a general case. So, the probability of event ei, where i is just an index from 1 to n, is equal, let's say, it's pi. So, you have probabilities of this thing. Now, the random variable, as I was saying, is basically a function. Well, in, I used to use the Greek letter c for a function. And so, the function of e1, let's say, will be value x1 for e2, it will be x2, et cetera, and for en, it will be xn. So, these are values which my random variable takes on each of these elementary events. Now, what's important, actually, to understand that to analyze how the random variable acts, it's not really necessary to go to the elementary events. What is necessary is to go to the probabilities of these elementary events, because sometimes two different elementary events can lead to the same value of the function. Like, you saw it on, with example, with roulette, for instance. Everything except number 23 had a value of the random variable equals to minus 1, right? So, and only 23 had 36. So, what makes sense is to analyze the probabilities of the random variable to take certain values. So, what I can say right now is that the probability of random variable c equals to x1 is equal to p1, p1, that's not pi, p. The probability of random variable c to equal to x2 is equal to p2. And the probability of random variable c to equal to any xi is actually pi. So, that's what's important. This is basically, they're saying it's a distribution of the random variable among different values. That's what it's describing here. So, this value with this probability, this value with this probability, etc. So, that's basically enough to analyze the behavior of the random variable. The probabilities of having this random variable take certain values. So, we need to know the values and we need to know the probabilities of these values. And that's enough to analyze our random variable. So, in these terms, if you go back to our game of roulette, you can say that the probability of c equals to 36 equals to 138, when you are guessing one number out of 36 numbers, zero and double zero. And the probability of c equals to minus one equals to 37, 38. So, our variable, random variable c takes only two values, 36 and minus one, with these probabilities. And that's basically a sufficient description of the random variable, because after that, we can do something like an average dispersion, etc., etc., all the different properties, which will be addressed later in a different lecture. So, right now, I'm just introducing you to the concept of what is random variable. So, on one hand, that's a function defined on a set of elementary events. For each elementary event, there is some kind of a numerical value. But if you will abstract out the fact that these are elementary events and just concentrate on the probabilities, because the probabilities is what's important, actually. Yes, you can describe this function in a different manner. c of one is equal to minus one, c of two is equal to minus one, etc., c of 22 is equal to minus one, c of 23 is equal to 36, and c of 24 is equal to again minus one, etc., c of zero is equal to minus one, and c of zero is equal to that. So, this is also a description. But this is not basically as interesting and as short, actually, as this one, because to analyze the function c, you really don't need this. What's sufficient is to have just these two. Okay, it takes two values, all these are minus one, and there are 37 of them. That's why it's 37, 38, and this one is only one single value, and that's why it's 36, with a one over 38 probability. All right, so that's my introduction to the concept of a random variable. Obviously, the random variables are much more studied and analyzed than the pure elementary events, per se, because what's interesting about elementary events, only their probability, whether it happens or it doesn't happen with certain probability. With random variables, we can do numerical manipulation. We can add them, we can multiply them. I mean, there are many different things which we can do with random variables. And that's actually where the theory of probabilities goes into really depths, really very deep analysis. And that's where we can learn something about events. We can learn about averaging, about dispersion, standard deviation, and stuff like this. But that's in future lectures. All right, so that's just an introduction. Thanks very much for listening to me. Maybe it makes sense, actually, to read again on unizor.com notes to this lecture. They contain basically the same material, but maybe slightly differently presented. And it's always good to repeat whatever, whatever you have learned here from the lecture. Thanks a lot and good luck.


Greetings, everyone. I don't know where you're at. Oh, there you are. Well, we're here and I say we because I've got my daughter. Look, it's Avery. We're gonna sit here live and say hi to everybody while we're at the WEBA conference. So for those of you that have not made it or heard about WEBA, the Women in Behavior Analysis Conference, it is absolutely amazing. We love it. So this has been a fun day so far. It's only a two-day event. I am here on behalf of Mary Baldwin University, which is my employer. I'm a professor there in the ABA program and this is one of the conferences that we sponsor. So I'm here and there's everybody else. There's Avery as well. But there's everybody going crazy down there. Well, I don't know. If you come find me, I think we'll do a couple of things first off. Let's talk about one of the themes that's really popped up this year, which is supervision. So you effing dude guy. Thank you, Brad. So maybe you should join us in here live as well. I couldn't get Brad to Nashville this year because, you know, we live off of YouTube money and that's just not much at all. Anyway, let's see. So supervision has been a huge, huge, huge topic this year at this conference and it continues to be. And there's another session coming up on OER Money, Brad says. And there's another session coming up out here at 5.15. And we're gonna go to that. But there's a thing that SiteCore's been working on a little bit. I'm dropping a little hint here because it's possible that our silence over the last couple of months or silence-ish has been because we're distracted. Because we might be working on something. What is it that we're working on, you say? You wonder? Supervision people. We got something coming for you. And it fits wonderfully with what's going on in the field right now. So we're excited for that. The other thing we got coming up for you is Test Prep. You know, past the bigs down there. We love past the bigs. They're good folks. We love all of them. They're good folks. But we got something fun coming for you too.  You can sit on our website. And it's almost ready, but it's not quite ready. It's one of those weird things that we gotta wait a little bit before we release it. But it should be just a few weeks and then we should be live with that again. Let's see what else. Oh, come find me. First five people that find me, I'm gonna say get you your choice of some type of shirt swag or something from our swag store. I don't know. Avery gives us a thumbs up. We don't have enough money to buy all the swag for everybody here. And we certainly didn't set up a booth this year. But next year we probably will just to support Weeba because these folks are just wonderful. Let's see what else. What's that? Sure. You wanna say hi? Avery wants to say hi. I wanna say something. Okay, go ahead. Look at the green dot. The green dot? That's what the people. Come find us. I dare you. Yeah, find us. We're not in behavior analysis jail. Sometimes it feels like it. It's just that we're hiding away from all the people. Next year's booth. It's great to be crazy cool. Yes, it is Janna. So Janna says hi. Brad's Janna. Brad and Janna? Janna? That. Oh, we got people coming up. Hi. No way. We're going better. We're live. Welcome aboard. Hi. I'll make this. Oh my God. Brad and I work hard to make that happen for everybody. We love it. You're welcome. Thanks for saying hi. I don't know if that counts if you should give a T-shirt away for that one or not. She didn't hung around. Anyway. So there you go, folks. Come find us. We got some swag. Brad says stickers. We'll send stickers out. We'll send all the stickers. We got tons of stickers. We got more coming. We almost got some ordered in time, but the idea popped up just a little too late to get in here for Weeba. So come find me, folks, hanging out in Nashville.  I'll just be hanging out here for the next couple of hours and all day tomorrow. So take care. See you.


says, I am in the process of converting our in-house email server to an Exchange Online Office 365 and could use some help. I have an end user that has three mailboxes, only three, at different domains. How do I go about migrating their email over for each of their different accounts and give them access to be able to manage each account individually without having to pay for extra licenses? Why do they have three? And can that be consolidated? Is this that we've always done it that way? And where are these two domains? Are they on the in-house server, which would kind of bring up why are you doing this in the first place? If they're on external servers, there really isn't an issue. You can add those to the client. I thought we decided we were not going to judge people on the decisions they make. We were just going to help them. Just asking questions. No, we never made that. It's more info. Yeah, I'm not an Exchange person, but the first thing that comes to mind when I hear the question is, are we talking about three separate email accounts or three aliases that reflect different domains? Good point. So how would you answer it knowing that it might be aliases, Hal and Joy, and whoever else might know Exchange? Never find a way to say. There really isn't anything to do because an alias is a secondary reference to an existing mailbox. You can have, I have one mailbox right now that I've got an alias with. I can log into the mailbox with either username. Yeah, but it's one mailbox, not more. So that was going to be my question on the online account. Yeah, how do you send it out? Can you send it out as either email? Because I don't know Exchange. So if it's an alias, you can pick the send from the seal. Yes. Then there's really nothing to manage in that scenario, right? It's all one thing. So the question leads me to presume that it is technically three separate accounts. Which is not a problem without look anyway. You can, like I think we all have multiple accounts that are logged into a single account. So I can manage all those things. It's the last part of this question. So whether it's three aliases on one domain, which doesn't sound like what he's saying, I think he's three different emails. Three different tenants that he has access into, which again, all of us on this call, we all have that. The last part, without having to pay for extra licenses. You pay for the license, well, I guess it's a mailbox. You pay for the license for Outlook, right?  But you have to have the license for the mailbox. So who controls those domains? Is it a subdomain that they have bought? Like the company has been acquired and now ABC company bought XYZ company and now you can create that as a, use that as a registered domain in your tenant. I don't know. So yeah, you can use it as an alias. I think this goes back to our initial question of why? Like what is the purpose? Because at the end of the day, if they have three separate like other emails that they're using out somewhere else, maybe those would make good groups. That's a lot of times at the end of the day, they're using an email for the wrong reasons. So they've got an email set up to like get information from somebody, which maybe that's a good SharePoint site. Maybe you need to use OneDrive for that instead. Maybe they're using it to communicate in which case, could you switch that to just simply a new group which would have a group inbox and then you just basically put people on that group inbox, take them on and off as they need it. If it's a subdomain, if it's something else, you could just simply add a new alias and let them use it that way. And there's a lot of simple solutions to this. The big question is what are they doing now and what is the purpose? Because that could ultimately give you different reasons to do different things. Yeah. And shared mailboxes don't require a license either. You can use a shared mailbox. But depending on where you're coming from. So I have my collab talk. I've got my rencor. I've got my techie gurus. I've got my Gmail. Well, all of those feed into Outlook. And so I'm able to go into one version of Outlook and I'm able to do that. If I'm receiving email, I can filter the view on that. If I'm sending out, I can change which one account it's coming from. So there's that part of it. But I have my MVP account, my collab talk account, which I'm paying for individually. Company paid the other one. And then another company is paying for those. So there's payments being made. So that's how I interpreted this. If I'm paying for those other domains and it goes back to the why question.  And so you can't get out of doing that. But you can manage all of that from a single Outlook instance. Exactly. In the migration scenario, are you able to have some users on the on-prem exchange and others in the online with the same domain? So you can have that hybrid experience. Is that something that's possible? I believe so because I've got a client that has multiple domains. And I know they have some in the on-prem. I know they have some in the online. I'm pretty sure that they've got them using both domains. But I wouldn't like, don't quote me on it, but I think that's okay. That's one area that I would say, I look, you know, in the cloud world, email has the longest life of being cloud. And it's the most stable and secure of any cloud instance of any product or service that's out there. I would, again, for organizations and if not, because it's usually the first place when companies were starting to move the cloud, the first thing that we do is move to email. It's just the, it's the hardiest of the solutions that are out there. Thank you, Christian, for that. You've got mail in my head from the original. You've got mail from AOL. I didn't need that in my- Remember when we used to wait for that? Like we'd sit and wait for it? Yes. Now we get one more email. I was like, oh, it's like- No more mail. Well, there's something about the tactile experience, hearing the shoo that it went out. Yes. You don't hear it. You're like, wait, did that just send? It sent. Did it go? Oh.


Hello and welcome to this session in which we will discuss the par value method when it comes to treasury stock. Now, we have to understand there are two methods to account for treasury stock. One is called the cost method and the other one is called the par value or the legal method. Now, the first thing we need to understand is what is treasury stock? Well, treasury stock is when the company buys back its own stock. For example, company A, they will buy back company A stock. Why am I making this distinguishment? Because company A could also buy company B, buy B stock. They can buy C stock. Well, when they do buy stocks other than their companies, it's called some sort of an investment. So that's the first thing we need to understand. There's a difference between buying back your own stock and buying back other company stocks. Now, why do companies buy back their stock? Well, I discussed this in the cost method. Could be many reasons. One is they want to show confidence in their own stock. Two, they want to reward the stockholders. Therefore, they buy back the stock. The stock price will go up. Three, they want to avoid maybe a takeover. That's why they buy back their own stock. It doesn't matter what the reason is. In this session, we need to understand how to account for treasury stock using the par value method or the legal method. Legal method or sometimes it's called the stated method. Let's go ahead and get started. Let's review real quick what we learned about in the cost method. Under the cost method, we account for any in quote gain, any in quote loss when we reissue the stock. So first we buy the stock, then down the road we might reissue the stock, that same treasury stock. When we reissue the stock, we might have a gain in quote or a loss in quote. At that point, when we reissue the treasury stock, when we reissue the treasury stock, we account for the gain or the loss. Under the par value method, when do we account for the gain or the loss when we re-purchase the treasury stock? So the point that we re-purchase the treasury stock, this is when we account for it. So under the par value method, that's what happens, but bear in mind, gain and loss, I keep them in quote. To remind you, those are not reported on the income statement. Yes, you have more money, sometimes you have less money by purchasing treasury stock. Although it appears, it looks, it smells, it acts like a gain or a loss, but it's not reported on the income statement. Same thing with the cost method. Simply put, transaction with the owners because you are buying back the stocks from the owners. You are selling the stock back to the owners. Don't report any transaction with the owners on the income statement. That's the key to remember, unless of course you're a company called Enron and you are cooking the books, then the gain or the loss would be reported on the income statement. And the absence of that, remember transaction with owners don't go on the income statement, whether it's a gain or whether it's a loss. So a few things to remember about treasury stock in general. No effect on the income statement. I keep saying this, but it's worth repeating. When you have a gain, it will not increase retained earnings. So hold on a second. So if I have a gain, what am I going to do? Well, it's going to increase some sort of paid in capital. And we'll see in an example, decreased retained earnings. Yes, sometimes you might incur a loss and the loss would reduce retained earnings. So retained earnings could be reduced by the loss, but it cannot be increased. So retained earnings cannot be increased with treasury stock. The best way to illustrate this is to take a look at an example to show you the effect of these transactions. Before we proceed any further, I have a public announcement about my company, farhatlectures.com. Farhat Accounting Lectures is a supplemental educational tool that's going to help you with your CPA exam preparation as well as your accounting courses. My CPA material is aligned with your CPA review course such as Becker, Roger, Wiley, Gleam, Miles. My accounting courses are aligned with your accounting courses broken down by chapter and topics. My resources consist of lectures, multiple choice questions, true-false questions as well as exercises. Go ahead, start your free trial today. No obligation, no credit card required. Adam Company issued 100,000 shares, a $1 power value for $5 per share. Now it's very important to know what was the original issuance of the shares. Well, $5. Let's start with this transaction. Let's first issue the share. Start with cash. It's easy. Cash, 100,000 shares times $5, that's half a million. Then we record common stock. Common stock is the number of shares times the power value. Make sure you know this. Number of shares. I'm going to write this here. It's very important times the power value. And this is called the power value method. The power value is important. Therefore, we credit common stock 100,000 and always additional paid in capital is a plug figure. Therefore, what's left is 400,000 additional paid in capital, common stock. So what we did is we issued the shares. That's all what we did. Now we are going to start to repurchase. We're going to repurchase 10,000 shares and we're going to pay $7. So look, we sold the shares at $5 initially. We issued them to the shareholders. Now we're buying back the shares at $7. Now from the company perspective, are we better off or less off? Well, think about it.  Now the shareholders are happy because if they bought them at $5, you are buying them back from them at $7, but we are not doing accounting for the shareholders. We are doing accounting for the company. So if you repurchase 10,000 shares at $7, start with cash. The company will have to issue a check for $70,000, 10,000 shares times $7. The next thing you do is you debit an account called treasury stock. Now since we are using the par value method for treasury stock, since we are using this method, it's called the par value, we're going to debit treasury stock and we're going to credit treasury stock at par, whether we debit or credit. So we're going to debit treasury stock at par. What's the par? Well, it's very important to notice. Don't lose track. The par is a dollar. I kept it a dollar easy. The par could be any number. So we're going to debit treasury stock at 10,000. Now what is treasury stock? Treasury stock is a contra equity account. So it's an equity, but it's the opposite of equity. That's why it takes a debit balance when you are increasing it and it reduces your equity. It's a contra equity. Well, what else do we need to know next? So we started with cash. That's easy. We debit treasury stock at par. That's easy. What's next? Well, next determine whether you have a gain or a loss. Well, think about it. From the company's perspective, they are $2 worse off for each share and they purchased back 10,000 shares. Well, they have a loss. Again, a loss. I'm going to put a loss in quote because it's not a loss that goes on the income statement of $20,000. How do you record this loss? Here's how you record this loss. First thing you do is you would look to see if you have an account called paid in capital treasury stock. If you have any amount and paid in capital treasury stock, the loss will go against this amount. But in this example, I showed you, I showed you no paid in capital treasury stock. So you assume that paid in capital treasury stock is zero. Well, if the paid in capital treasury stock is zero, what do you have to do? Then you have to take the loss and debit retained earnings for $20,000. So what is paid in capital treasury stock? So how does this account comes into life? This account where we book the in quote, the gain in case we have a gain. So in case we had a gain in the past and now we have a loss, the loss can be used to offset the gain. But in this example, I'm telling you, there's no gain. But if there is a gain, if they're giving you statements of equity and there's paid in capital, again, treasury stock, and there's a number there and you incur the loss, first the loss will go against that paid in capital treasury stock to bring the paid in capital treasury stock down to zero. Once you no longer have paid in capital treasury stock, anything remaining from the loss would go to retained earnings. So I'm assuming here I already have a zero in paid in capital. That's good. Now the transaction does not balance. The last thing you book is additional paid in capital common stock. Basically, you book this account, you reduce additional paid in capital treasury stock, and this is a plug. Now, I consider this a plug. Some CPA review course, they would say, no, this is not really a plug. This is, yeah, there's another way to compute this. It is 10,000 shares times the additional paid in capital. What is the additional paid in capital? Look, I'm sorry, the additional paid in capital, the additional paid in capital. What's the additional paid in capital? Well, remember, we issued each share for five. One dollar was par. The additional paid in capital was four. So it's 10,000 times four dollars because this is the additional paid in capital is 40,000. Well, I would like to look at it as a plug. If you want to look at it as this is your reverse the additional paid in capital, it's up to you. I believe it's easier to always remember that additional paid in capital common stock is a plug. Let's look at another scenario. Adam repurchased 20,000 shares now at $3. Well, start with cash. If we repurchase 20,000 shares at $3, we have to pay 60,000. Credit cash, 60,000. That's fine. The next thing, again, we are buying treasury stock. Debit treasury stock at par, which is 20,000 shares times a dollar, 20,000. Now determine whether you have a gain or a loss because under the par value, you have to determine the gain or the loss when you repurchase the shares. You issued the shares at five. Now you're buying them at three. Do you have a gain or do you have a loss? Well, you have a $2.  So you have a gain of $40,000. Now how do you book this gain? Easy. You always book the gain paid in capital treasury stock. And this is how paid in capital treasury stock now exists. Before we did not have any balance. Now we have $40,000 balance. Okay. So we don't credit retained earnings. So we don't go back and say, well, we reduce retained earnings. We're going to go back and reverse it. Transaction with owners don't increase retained earnings paid in capital treasury stock. What's left? The transaction does not balance. It's always against additional paid in capital common stock. Additional paid in capital. Notice this is common stock is 80,000, which is the plug to make the entry balance. And if you want to take a look at it as it's at 20,000 and I'm reversing $4 additional paid in capital. That's gives you also 80,000. It does not matter. So notice here what I did. I issued the stock at five. I showed you when it's issued at a loss for the company. Again, from the company, it's a loss when it's issued at seven from the shareholder. It's a gain, but our concern is not the shareholder. And when we issue it at a gain, we book the in quote gain in an additional paid in capital. Now we're going to go back and start to the issue treasury stock. Now Adam reissued 5,000 shares at $8 and those 5,000 shares are from the treasury stock. Because remember, we bought 10,000. We have 30,000. We're going to issue 5,000. That's fine. Debit cash for 40,000. That's easy. Start with cash. Now, since you are issuing the treasury stock, you have to get rid of the treasury stock. You always debit and credit treasury stock for the par value. This is the par value method. Par value method for treasury stock. Therefore, I'm going to credit treasury stock 5,000 shares times $1. That's the par value. And guess what? Anything left is paid in capital. Common stock 45,000. So notice here, I issued them at 8. Let's issue the shares at $2. Issue 10,000 treasury stock at $2. Again, at $2, I'm going to get 10,000 shares times $2. It's going to give me 20,000. I'm going to remove the treasury stock at par 10,000 shares times 1. And anything left, it's additional paid in capital, $10,000. What should you do now? You should go to far hat lectures and look at additional MCQs, true, false, additional resources, exercises, the cost method that's going to help you to account for treasury stock. Remember, treasury stock will have the cost method, will have the par value method. Now, in the real world, also in college courses, they always teach you the cost method because that's the one that most commonly used. But on the CPA exam, they hold you accountable for the cost method as well as the par value method for treasury stock. Study it, learn it. I'm always here for you. Good luck. Study hard and, of course, stay safe.