Jesus knew the outcome of His obedience, the outcome of His daily obedience and the outcome of His final obedience. The outcome (provision, reward, blessing) of His obedience had been written down long before He arrived on the scene. He only needed to believe the promise of provision, blessing and reward to set those blessings in motion.
Psalm 15 was about Him, Psalm 16, 17, 91, 89 and on. There were about Him. The prophets had declared in advance the outcome of His life.
This is why He could have a great attitude at all times, even on the cross. This is why He laid His life down. Not one could take His life, but for the sake of the reward, He laid it down.
Hebrews 12:1 Therefore, since we have so great a cloud of witnesses surrounding us, let us also lay aside every encumbrance, and the sin which so easily entangles us, and let us run with endurance the race that is set before us, 2 fixing our eyes on Jesus, the author and perfecter of faith, who for the joy set before Him endured the cross, despising the shame, and has sat down at the right hand of the throne of God. NASB
He endured the cross, despising the shame, for the joy set before Him. Here is the secret to having a great attitude in all that God calls you do. Do it for the joy set before you. Do you count the joy? Have you studied the joy? Do you know what the joy is? Have you magnified the joy? Here we are told that He went through the horrific experience of bearing the sin of the whole world because He made the reward, the provision, the blessing His sole focus.