SB 3.3.19

bhagavān api viśvātmā
 loka-veda-pathānugaḥ
kāmān siṣeve dvārvatyām
 asaktaḥ sāṅkhyam āsthitaḥ
Synonyms: 
bhagavān — the Personality of Godhead; api — also; viśva-ātmā — the Supersoul of the universe; loka — customary; veda — Vedic principles; patha-anugaḥ — follower of the path; kāmān — the necessities of life; siṣeve — enjoyed; dvārvatyām — in the city of Dvārakā; asaktaḥ — without being attached; sāṅkhyam — knowledge in Sāṅkhya philosophy; āsthitaḥ — being situated.
Translation: 
Simultaneously, the Personality of Godhead enjoyed life in the city of Dvārakā, strictly in conformity with the Vedic customs of society. He was situated in detachment and knowledge, as enunciated by the Sāṅkhya system of philosophy.
Purport: 

While Mahārāja Yudhiṣṭhira was the Emperor of the earth, Lord Śrī Kṛṣṇa was the King of Dvārakā and was known as Dvārakādhīśa. Like other subordinate kings, He was under the regime of Mahārāja Yudhiṣṭhira. Although Lord Śrī Kṛṣṇa is the supreme emperor of the entire creation, while He was on this earth He never violated the principles of the Vedic injunctions because they are the guide for human life. Regulated human life according to the Vedic principles, which are based on the system of knowledge called Sāṅkhya philosophy, is the real way of enjoyment of the necessities of life. Without such knowledge, detachment and custom, the so-called human civilization is no more than an animal society of eat, drink, be merry and enjoy. The Lord was acting freely, as He willed, yet by His practical example He taught not to lead a life which goes against the principles of detachment and knowledge. Attainment of knowledge and detachment, as very elaborately discussed in Sāṅkhya philosophy, is the real perfection of life. Knowledge means to know that the mission of the human form of life is to end all the miseries of material existence and that in spite of having to fulfill the bodily necessities in a regulated way, one must be detached from such animal life. Fulfilling the demands of the body is animal life, and fulfilling the mission of the spirit soul is the human mission.