Step 1: Write the characteristic equation.
The characteristic equation for a matrix \( A \) is given by:
\[
\det(A - \lambda I) = 0,
\]
where \( \lambda \) represents the eigenvalues of the matrix \( A \), and \( I \) is the identity matrix.
For the matrix \( A \), the characteristic polynomial is found by calculating the determinant of \( A - \lambda I \):
\[
A - \lambda I =
\begin{pmatrix}
1 - \lambda & 0 & 1 \\
0 & k - \lambda & 0 \\
3 & 0 & -1 - \lambda
\end{pmatrix}.
\]
The determinant of this matrix is:
\[
\det(A - \lambda I) = (1 - \lambda) \left( (k - \lambda)(-1 - \lambda) \right) - 3 \cdot 0 + 1 \cdot 0.
\]
This simplifies to:
\[
\det(A - \lambda I) = (1 - \lambda)(k - \lambda)(-1 - \lambda).
\]
Step 2: Use the given eigenvalues.
We know that the eigenvalues of the matrix are \( -2 \), \( 1 \), and \( 2 \), so we can factor the characteristic polynomial as:
\[
(\lambda + 2)(\lambda - 1)(\lambda - 2) = 0.
\]
Expanding the factors:
\[
(\lambda + 2)(\lambda^2 - 3\lambda + 2) = \lambda^3 - \lambda^2 - 4\lambda + 4.
\]
This is the characteristic polynomial for the matrix \( A \). Now, we compare this expanded polynomial with the determinant expression from earlier.
Step 3: Compare the coefficients.
The coefficient of \( \lambda^2 \) in the expanded characteristic polynomial is \( -1 \).
The coefficient of \( \lambda^2 \) from expanding \( (1 - \lambda)(k - \lambda)(-1 - \lambda) \) is \( k - 1 \).
So we equate:
\[
k - 1 = -1
\Rightarrow k = 1.
\]
Thus, the value of \( k \) is \( \boxed{1} \).