In a school, there are 2021 students, each having exactly $k$ friends. There aren't three students such that all three are friends with each other. What is the maximum possible value of $k$?
1. **Graph Representation and Problem Restatement**:
   - We represent the problem using a graph \( G \) with \( n = 2021 \) vertices, where each vertex has exactly \( k \) friends (i.e., \( G \) is \( k \)-regular).
   - The graph is triangle-free, meaning there are no three vertices that are mutually connected.

2. **Bipartite Graph Argument**:
   - Suppose \( G \) is bipartite, split into two sets \( X \) and \( Y \).
   - In a bipartite graph, the sum of degrees in each partition must be equal:
     \[
     \sum_{v \in X} d(v) = \sum_{v \in Y} d(v) \implies k|X| = k|Y| \implies |X| = |Y|
     \]
   - Since \( n = 2021 \) is odd, it is impossible to split \( G \) into two equal parts. Therefore, \( G \) cannot be bipartite.

3. **Odd Cycle and Degree Constraints**:
   - Let \( C \) be an odd cycle in \( G \) with minimal length \( r \). Since \( G \) is triangle-free, \( r \geq 5 \).
   - For any vertex \( v \notin C \), \( v \) can have at most 2 neighbors in \( C \). If \( v \) had 3 or more neighbors in \( C \), it would create a smaller odd cycle, contradicting the minimality of \( r \).

4. **Summing Degrees**:
   - Consider the sum of degrees of vertices in \( C \):
     \[
     \sum_{v \in C} d(v) \leq 2(n - r) + 2r = 2n
     \]
   - This inequality arises because each vertex in \( C \) can have at most 2 neighbors outside \( C \) and 2 neighbors within \( C \).

5. **Deriving the Upper Bound for \( k \)**:
   - Since \( G \) is \( k \)-regular, each vertex in \( C \) has degree \( k \):
     \[
     kr \leq 2n
     \]
   - Given \( r \geq 5 \), we have:
     \[
     k \leq \frac{2n}{r} \leq \frac{2 \cdot 2021}{5} = 808.4
     \]
   - Since \( k \) must be an integer, the maximum possible value of \( k \) is \( 808 \).

The final answer is \( \boxed{ k \leq 808 } \).