My question involves civil rights in the State of: California

I was pulled over today for a traffic violation in Orange County California. When the officer approached my car the first thing he said to me was "Where are your going?" Are they allowed to ask that? It's none of their business where I'm going. My response was "Why are you asking" and "Why did you pull me over?" I didn't understand the officer's explanation for why I was pulled over. He said something about a light not working. I was pulled over during broad daylight. I looked at my brake lights a little after I was let go and the lights were working fine except for the brake light in the interior at the base of my rear window.

My attitude was brusque from the beginning because so much of the job of police is tax collection through extortion by frivolous ticketing, and I was almost sure there was no good reason to pull me over. He asked me get to out of my car and stand on the sidewalk where he proceeded to frisk me. He then told me to sit on the curb while he looked me up on the computer. Then he asked if he could search my car. I complied to avoid further harassment. After searching my car he told me I was free to leave. When he said I could leave I asked for his business card which he gave me. Was it legal for him to even ask to search my vehicle or frisk me? Aren't police required to have probable cause to search a person or vehicle? Thanks for any replies.