I have perhaps a bit of a different take on this. Sort of the same, but maybe a little more practical in use.
You ask if it's ok to play a pentatonic scale over the harmonized chords of the scale.
Yes...it is. And no, it isn't.
You know that a full scale has seven notes. Also, it has seven harmonized chords, based on seven modes, using Ionian (what people often think of as "the major mode") as the root.
You can apply the same thinking to pentatonic. There's only five notes in the pentatonic scale. No coincidence that there's five standard pentatonic positions, which again, would suggest it maps to five modes and chords.
Which two are missing? Again, use Ionian as the root. Pentatonic Major really is just "abbreviated Ionian". It leaves out the 4th and 7th. Those map to the Lydian and Locrian modes. Good thing; those two modes can be difficult to apply correctly, especially for the newer player.
So, let's talk scale of C Major.
Penatatonic: C D E G A C (no fourth or seventh).
That'll work fine for any of the typically harmonized chords of CMajor that map to those modes. Say for instance the composition is:
C major, D minor 7, G7, C major.
All those chords have roots in the pentatonic scale, and there are shapes for all of them (the same notes, just starting from a different root). So (naively) you could jump around the neck, starting from a given root, and play the appropriate pentatonic shape for that chord.
Now we get into why I say "yes...and no", which can lead to a much longer discussion: the notion that "all the notes are the same in every position so I can use any position over any chord in that scale" is true in one way and false in another. This is the "I'm playing the right scale why does it sound terrible" problem. For instance, while playing that G7 chord, the soloist leans on the note C. It sounds not-so-good. Why? Look at the chord; you're playing a C over a G7 chord. In terms of the chord, you are now overlaying a fourth (C is the fourth of G) onto that chord. At a basic level, sonically, it's almost certainly not what you want (try it, you'll see).
Let's analyze the chord: the tones of G7 are G B D F; neither B or F are in C pentatonic (isn't that interesting...those are the notes intentionally left out of C major pentatonic...which leads to a much longer discussion...).
So, what would be a safe choice from the scale? G and D are in G7, so those are going to be fine. A would be the 9th (2nd) of G7, and that's usually pretty safe (especially if you use a trill or something). B and F would both work, but neither of those are in the scale, so we omit them. So G, D, and to a slightly lesser degree A, are reasonable choices to land your runs on.
(By "land your runs on", I don't mean "only play those notes". I mean, as you're moving through the pentatonic pattern, be mindful what notes you stress).
Anyway, that aside, regardless of the fact that pentatonics are supposed to be "easy", you STILL need to be aware of the harmony you are playing over. And that's the thing that traps so many players. They think they can just use a single pentatonic scale over the entire composition. Again, they're right in a kind of naive way (the "math" way), but wrong in a very important way (the "sonic" way).
So what to do if there is a 4 or 7 chord (which would be chords that map to the Lydian and Locrian modes)?
Look at the notes in the chords. In C major, the 4 would be F (Lydian). We'll keep it basic and assume the #4 of Lydian is not in the chord.
F A C E
We know F isn't in C pentatonic. The rest of the notes are. So you're good. Being mindful of notes that may not be sonically straightforward (for instance, the D would be the 6th (or 13th) of F, which can create complexity you might not be looking for), you're pretty safe.
How about the 7 chord (Locrian), which would be B min7 b5?
B D F A
There's two notes in that chord that aren't in the scale. The other two are. Again, listening to those two notes, pick the one that seems to work sonically. Even though there's no pentatonic position that maps to this chord, you can still employ the pentatonic scale to create melodies and improvise over it.
There are some eclectic extensions to this conversation; modal pentatonics and such (there is inevitably a clever example of how somebody broke a given "rule"), but I think if you get what I wrote above, you'll have some fairly solid (and practical) ground to work on.
And fortunately, this applies directly to the full scale as well. The same exact thinking. Two things I never liked about how pentatonics are taught is that usually they start with the minor pentatonic (theory is based on the major scale but players are commonly taught the minor pentatonic shape first...IMHO that is a mistake, I know it held me back for a while, the whole "convert to minor" thing is a fairly advanced concept, thank you Mr. Martino), and that somehow pentatonic thinking is different or easier than regular scales. There may be less notes but the foundational thinking and concepts are identical.
Hope that helps.