2 levels of Warlock are enough for full Eldritch Blast damage
You are absolutely right, there is not much reason to go above level 2 with Warlock from an optimization standpoint, if you only want Eldritch Blast.
You get every benefit from Eldritch Blast, without giving up much in return, since cantrips scale with your character level, not your class level. You will have to consider however that Eldritch Blast requires Charisma, and that one is the usual dump stat of an Eldritch Knight. So you will either be quite bad at blasting, or sword swinging. Or both. There is no synergy in stats, playstyles, preferred distance, equipment, nothing.
It is great for others
As every DnD edition with character options, 5E rewards specialization. You either excel at standing in the back rows and sniping enemies, or be a front liner. There is not much middle ground.
For a Sorcerer or Bard, 2 levels of Warlock is golden, to have a really strong cantrip when they run out of real spells. But not for a Fighter.
So can you take 2 levels of Warlock, for full Eldritch Blast progression? Yes
Is Eldritch Blast worth it from an optimization standpoint for a Fighter? No
Other parts of Warlock might work better for you
However, if you do not focus on EB, Warlock can be a really good addition.
- Hex improves your DPR quite a bit, considering how many times a Fighter can attack on higher levels. Temporary hit points on a kill are also nice (Dark One's Blessing)
- 2 levels of Warlock double the number of slots per day, and you can get improved darkvision, even more hit points, or free Detect Magic (Invocations)
- 3 levels can give you quite a lot of great spells not belonging to the abjuration or evocation schools. Invisibility, Mirror Image, Phantasmal Force or Misty Step, all excellent for a Fighter
- An invisible scout (Pact of Chain) or rituals (Pact of Tome)
- 4 levels give you an ASI
- 5 levels can give you Fireball, Stinking Cloud, Blink, Fear, Counterspell, or Vampiric Touch and an invocation
- 6 levels can give you a teleport+invisibility, Temporary Hit Points, or Advantage on an attack depending on your patron
I would go like this:
- 1 Fighter level (saving throw/armor proficiencies)
- 2 Warlock levels (2 spell slots, 2 invocations, patron feature)
- 5 more Fighter levels (Extra Attack, ASI)
- 3 more Warlock levels (3rd level spells, 1 invocation, ASI, pact)
- Remaining levels in Fighter