Krishna is one of the greatest devotees of Lord shiva. As per mahabharata, krishna is believed to be the reincarnation of Narayan maharshi, who was also one of the greatest devotee of lord shiva. The Mahabharat and Shaiva puranas clearly say that Krishna was devoted to Lord shiva even in his past lives. Krishna explained 'Siva sahasranama' to yudhistara(Dharmaraja) and also told him how he got the supreme Advaita jnana (nondual knowledge) because of lord shiva. It was explained in Anushasan parva of mahabharat.
Rudra bhakthya thu krishnena jagat vyaptham mahathmana,
Tham prasadhya thadha devam bhadaryam kila bharatha.
Arthath priya harathwam cha sarva lokeshu vai yadhaa,
Prapthavaaneva rajendra suvarnaakshan maheswaraath.
The great Lord Krishna, due to his devotion to Supreme lord Rudra,Has spread all over the universe, Oh Bharatha, Oh king of kings,After making Lord Shiva pleased by his penance in Bhadri,He has attained the state of being more dear,Than all the worlds and all aspects of knowledge.
Yuge yuge thu krushnena thoshitho vai maheswara,
Bhakthya paramaya chaiva prathi sruthwa mahatmana.
Lord Maheshwara becomes pleased and happy yugas after yugas, by this Krishna who is devotee of Lord Shiva.
Krishna got several boons from lord shiva even in his past life as Narayana muni.
Bhagavatam explicitly states that Krsna worshiped Lord Shiva .
prayayus te 'mbikā-vanam ( SB 10.34.1)
One day Gopala along with his mates, eager to take a trip to worship Lord Śiva, traveled by bullock carts to the Ambikā forest ( SB 10.34.1)
tatra snātvā sarasvatyāḿ
devaḿ paśu-patiḿ vibhum
ānarcur arhaṇair bhaktyā
devīḿ ca ṇṛpate 'mbikām ( SB 10.34.2)
"O King, after arriving there, Krsna along with his mates bathed in the Sarasvatī River and then devotedly worshiped with various paraphernalia the All powerful and all pervading Godhead Lord Paśupati [devaḿ paśu-patiḿ vibhum] and his consort, goddess Ambikā. ( SB 10.34.2)
Shiva Blessing Vishnu by giving Sudarshana Chakra as a Boon for his devotion towards him.