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 \), we have:
\[
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)
= (k - \lambda)
\begin{vmatrix}
1 - \lambda & 1 \\
3 & -1 - \lambda
\end{vmatrix}.
\]
\[
= (k - \lambda)\left[(1 - \lambda)(-1 - \lambda) - 3\right].
\]
\[
= (k - \lambda)\left(\lambda^2 - 1 - 3\right)
= (k - \lambda)(\lambda^2 - 4).
\]
Thus, the characteristic polynomial is:
\[
(k - \lambda)(\lambda - 2)(\lambda + 2).
\]
Step 2: Use the given eigenvalues.
The eigenvalues are given as \( -2, 1, 2 \). Hence, the characteristic polynomial must be:
\[
(\lambda + 2)(\lambda - 1)(\lambda - 2).
\]
Comparing with:
\[
(k - \lambda)(\lambda - 2)(\lambda + 2),
\]
we see that:
\[
k - \lambda = \lambda - 1.
\]
Step 3: Solve for \( k \).
Comparing coefficients:
\[
k = 1.
\]
Final Answer:
\[
\boxed{1}
\]