At the Passover feast, Judas is already preparing to betray Jesus. Jesus takes off His outer robe and washes the feet of His disciples. Such washing by the master is unheard of in the tradition of ritual washing.
Even knowing the betrayal, and the prophecy from Psalm 41 that Jesus will be betrayed by an intimate friend, Jesus is hurt by the knowledge of Judas’ sin. Jesus gives Judas the morsel, a piece of honor at the Passover feast, asking Judas to do what he will do.
Judas leaves, and Jesus tells them that He is now glorified, but that the apostles cannot follow where He is going. Jesus then gives a new commandment, that they love one another as He has loved them. Peter protests that He wants to follow Him, and Jesus prophesies that Peter will betray Him that very night.
Several apostles have objections or comments now, and Jesus uses these as an opportunity to explain His relationship with the Father and promise the coming of the Holy Spirit.
Jesus also tells the other Judas that those who love Him keep His commandments, reinforcing a theme that John has developed in his gospel.