2. The domain of the function $f(x)$ is $D$. If it satisfies:
(1) $f(x)$ is a monotonic function in $D$;
(2) There exists $[a, b] \subseteq D$ such that the range of $f(x)$ on $[a, b]$ is $[a, b]$, then $y=f(x)$ is called a "closed function".

Given that $f(x)=\sqrt{x+2}+k$ is a closed function, the range of values for $k$ is ( ).
(A) $\left(-\frac{9}{4},+\infty\right)$
(B) $\left[-\frac{5}{2},+\infty\right)$
(C) $\left[-\frac{5}{2},-\frac{9}{4}\right)$
(D) $\left(-\frac{9}{4},-2\right]$
2.D.

Since $f(x)=\sqrt{x+2}+k=x$ has two distinct real roots, thus, $x^{2}-(2 k+1) x+k^{2}-2=0$, and $\left\{\begin{array}{l}x \geqslant-2, \\ x \geqslant k .\end{array}\right.$
Solving this, we get $k \in\left(-\frac{9}{4},-2\right]$.