There is no doubt that Jesus knew that he would be killed. Even more important though was that he knew he was dying so that he would rise again. He submitted to the will of God even in death and showed his power over death by rising from the dead. Jesus said this about his willingness to die:
“The reason my Father loves me is that I lay down my life—only to take it up again. No one takes it from me, but I lay it down of my own accord. I have authority to lay it down and authority to take it up again. This command I received from my Father.” John 10.17-18
It was the eternal plan of Almighty God that the power of life and victory of righteousness should be shown to all the world. Jesus Christ accepted this role for himself. He freely died so that he could live again by the power given to him by God. No one should think that the death of Jesus was a defeat. It was his greatest victory.