Let us consider the case $k<0$: the case $k>0$ is studied analogously, with due modifications in the solutions (imaginary exponentials are needed). The case $k=0$ is degenerate with class of solutions given by $y(x)=A$, for any constant $A$.
If $k<0$ then the most general solution to the given ODE is
$y(x)=A\exp(\omega x)+B\exp(-\omega x)$,
with $A,B$ constants and $\omega:=\sqrt{-k}$. Note that $\omega^2:=-k>0$.
The periodic conditions $y(-\pi)=y(\pi)$ and $y'(-\pi)=y'(\pi)$ are equivalent to the system of equations
$\beta(A+B)=0\cap \beta(A-B)=0$,
with $\beta=\sin(\pi\omega)$.
If $\beta\neq 0$, then we arrive at the trivial solution $y(x)=0$ as $A=B=0$ is the only solution of the above system.
If $\beta= 0$, i.e. $\sin(\pi\omega)=0 \Leftrightarrow \pi\omega=2\pi r\Leftrightarrow \omega=2r \Leftrightarrow -k=4r^2$, for some $r\in \mathbb Z$, then the original problem has solution(s)
$y(x)=A\exp(2r x)+B\exp(-2r x)$.
With these information you could proceed to answer to your question.